AnsweredAssumed Answered

FTM Counter setting

Question asked by Victor Krawciw on Feb 3, 2012
Latest reply on Feb 10, 2012 by Victor Krawciw


I am using one of the K60 Flex Timer (FTM) modules to act as 
a simple pulse counter of the external clock FTM_CLKIN1 
input. I want it to roll over at 0xffff back to 0x0000. However 
occasionally I wish to write a specific value to the CNT register 
and I dont seem to be able to make this work. The only setup 
for the FTM I do is: 

FTM1->SC = FTM_SC_CLKS(3) | FTM_SC_PS(0) | 

This sets external clock, Divide 1 and enable overflow 

To write a value to the clock I use: 

FTM1->SC &= ~FTM_SC_CLKS_MASK; // Stop 
FTM1->CNTIN = lo_word; // value to write 
FTM1->CNT = lo_word; // Trigger write CNTIN to CNT 
FTM1->CNTIN = 0; // Reset for roll over 
FTM1->SC = FTM_SC_CLKS(3) | FTM_SC_PS(0) | 
FTM_SC_TOIE_MASK; // restart 

However all this does is clear the counter to 0 and not the 
value I set. What am I doing wrong?