Hello,
I am a starter in ARM programming and I am using MKE04Z8VTG4 MCU.
I am a bit unsure if I understood the reference manual correctly. If I use fixed frequency clock for timer clock source the frequency will be about 37.5kHz?
Is there any way to determine the exact frequency if I use 20MHz external crystal?
Also how do I determine the exact system clock if I use an external 20MHz crystal?
Are there any advantages/disadvantages for either of the clock sources (except the higher frequency of course)? I will require 10kHz frequency so I think it does not matter which one I choose.
Another problem I am having is writing to CnSC and CnV registers (FTM2). I can't seem to be able to figure it out how to do it.
For other registers I use for example: FTM2 -> POL |= (1 << 5)
So how do I write to these two in the same (similar) way?
I am still having a bit of problems figuring a lot of stuff out so I appreciate all the help (everyone was a beginner once) :smileyhappy:.
With regards, Jure
Solved! Go to Solution.
Hi Jure Stojs,
Please download KEXX_DRIVERS_V1.2.1_DEVD, the driver library package, it also contains a lot of examples for Keil.
Hi Jure Stojs,
Please download KEXX_DRIVERS_V1.2.1_DEVD, the driver library package, it also contains a lot of examples for Keil.
Thank you for posting this, I got everything I needed (and a lot more).
I got the timer configured properly and now it works.
Hi Jure Stojs,
If you want a 10kHz, then, you have to use an external crystal.
MKE04 provides an internal low range reference clock, but this clock frequency can be multiplied by FLL or PLL to a very high frequency such like 20MHz.
For coding issue, I would suggest referencing demos of FRDM-KE04Z which can be downloaded from the below link:
Freescale Freedom Development Platform for th|Freescale
the file name is FRDM-KE04_QSP.
I hope it helps!
I got the frequency and timing figured out, an external 20MHz crystal will be used (the same as for the system clock).
Unfortunately I can not open the examples since I use Keil uVision5 and there is still the problem with CnV and CnSC registers.
Another question about the timer functionality.
When the value in CnV register reaches a predefined value (1562) it sets the output to high.
Will the timer still count until it reaches the value stored in MOD register?
If yes that means I can use the timer interrupt to clear the previously set pin?
For example: The timer counts to 100 and at 100 it sets a pin high and continues to count.
The value in the MOD register equals a time of 110 so when the timer counts to this value it sets the interrupt and resets.
In the ISR i then turn the pin low and disable the timer (I enable the timer in another ISR).
So the pin would be 100us low, then 10us high and then low again.
I hope I was clear of what I am trying to achieve and if this is even possible. I read the datasheet and nowhere was written that this could not work but I am still unsure if it is possible :smileyhappy:.
Thank you for helping.