I have a FDM-KE02Z20M board, using IAR Kickstart for ARM development tools.
I am using FTM2, CH0 to capture a rising edge event. I also want to reset the counter to a small value after processing the capture, so that the counter effectively restarts from zero. If, for example, the capture processing takes 5us, I want to set the counter to the count equivalent of 5us so that the time between capture events is correct.
According to the reference manual, writing ANY value to the CNT register sets the counter to the CNTIN register value. However, I do not see this occurring. I set the initial value like this:
FTM_SetCounterInitValue(FTM2, 20); and I can see, that, in fact, that value is in the CNTIN register if my breakpoint is reached in the capture function. However, FTM2->CNT is always zero after reaching this line in the code:
FTM2->CNT = 20;
Theoretically, it shouldn't make any difference what value I use, according to manual, "Writing any value to COUNT updates the counter with its initial value, CNTIN."
What might I be doing wrong here? CNTIN is set to 20.