Hello to everyone,
i have a strange problem with a kinetis k12d microcontrollers, i'm trying to configure FTM0 peripherals with a desiderate frequency of 1kHz, to check correct frequency settings i toggle a pin in the FTM0 interrupt function and see it with oscilloscope. the result is a wrong frequency of 135 kHz, this may be due to wrong settings of MOD and PRESCALER register but i noted that if i change them the frequency result don't change the output frequency looks like indipendent of MOD and PRESCALER settings. I set the FTM0 as follow:
SIM_SCGC6|=SIM_SCGC6_FTM0_MASK;
FTM0_CNTIN = FTM_CNTIN_INIT(0);
FTM0_MOD= 10000 - 1;
FTM0_SC|= FTM_SC_TOIE_MASK | FTM_SC_CLKS(1)|
FTM_SC_PS(0) | FTM_SC_TOIE_MASK;
I set the bus frequency to 25 Mhz
have someone some idea about the problem ?
thank you
I forget an imporatant things, to test that the bus freqency is correct, i try to set the pin tooggle at 1 khz by setting the PIT frequency and it work ok.
Hello Matteo,
I don't know what other things you are doing during your project, but it seems rare that any change on MOD register does not impact the timing period for the pin that you are toggling, however, I was able to create a basic project for FRDM-K20D50M which uses a MK20D50 MCU which is compatible with MK12DX.
I am attaching this basic project (maybe it serves you as guidance) and also I am adding an image that shows a 1-kHz toggling frequency.
Hope this helps!
Regards,
Isaac
Thank you :smileywink: