Hello,
I am using the FTM2 in Output Compare mode. This timers get the reference clock through external clock (100 KHz), so it overflows each 655.4ms. I am interested in using the Channel Match interrupt capabilities of this peripheral, but the content of FTM2_C0V is never updated. The reference manual said that this register is updated in the next count of FTM2 after FTM2_C0V was written (in my case, CLKS !=0 and FTMEN=0) but it always remains the same value. Check this simple code:
PE_ISR(FTM2_overflow)
{
FTM2_C0SC &= (uint32_t)~0x80UL; //Clear flag
sendUart(FTM2_C0V); //Print FTM2_C0V value
}
void setTimer(void)
{
FTM2_C0V=0x7FFF;
FTM2_C0SC &= (uint32_t)~0x80UL; //Clear flag to clean previous channel matches
FTM2_C0SC |= (uint32_t)0x40UL; // Channel match interrupt enabled
}
When setTimer function is called, UART send the FTM2_C0V value each 655.4 ms, but this value is always 0x0000 (the default value) instead 0x7FFF.
Thank you
Jose
We have not found out the solution :smileysad:. Anyone can help me?
Dear Jose Garcia Doblado,
Thank you for your post, however please consider moving it to the right community place for better visibility.
For details please see general advice https://community.freescale.com/docs/DOC-99909
Thank you for using Freescale Community.
Regards,
Wlodek_D.
Hi,
can you tell me which controller you are using?
Thanks and Regards,
Robin
I am using a Kinetis K30 microcontroller, the MK30DN512ZVLQ10.
Thanks,
Jose
Like
void setTimer(void)
{
FTM2_MOD=0xFFFF;
FTM2_C0V=0x7FFF;
FTM2_C0SC &= (uint32_t)~0x80UL; //Clear flag to clean previous channel matches
FTM2_C0SC |= (uint32_t)0x40UL; // Channel match interrupt enabled
}
Thanks n Regards,
Robin
I have tried it but It does not work.
I was able to update the FTM2_C0V value stopping the counter CLKS=00 and the restarting again. But this solution is not valid for me. FTM2 is the synchornization time in a CDMA system and it can not be stopped. This is the code:
{void setTimer(void)
FTM2_SC &=(uint32_t)~0x18UL;
FTM2_C0V=0x7FFF;
FTM2_SC |=(uint32_t)0x18UL;
FTM2_C0SC &= (uint32_t)~0x80UL; //Clear flag to clean previous channel matches
FTM2_C0SC |= (uint32_t)0x40UL; // Channel match interrupt enabled
}
Any other solution?
Thanks,
Jose
Hi Jose,
give me sometime i will look into that.if you will get the solution please post it.
Thanks n Regards,
Robin
Hi Robin,
I'll do that.
Thanks
Jose
Hi Jose,
so what was problem?
Thanks n Regards,
Robin
Sorry, I mean that I'll post the solution if I resolve the problem.
Thanks
Hi Jose,
can you mail me your complete code so that i can simulate on my pc.?
my email robinwithu@yahoo.co.in
Thanks n Regards,
Robin
Hi Jose,
can you initilize your FTM_MOD to 0xFFFF , register in first case and see the result.
Regards,
Robin