Hi Frank,
According to your statement, my scenario is illustrated below.
1. Configure the FTM2 channel 0 and channel 1 work in Input Capture mode, and channel 0 capture on Rising Edge only, channel 1 capture on falling edge only.
2. FTM2_CNTIN is not 0, however the value of the FTM2_CNTIN is equal to 0xFFFF minus the the specified fix value, and the FTM2_MOD=0xFFFF;
3. When the channel 0 detect the rising edge of the input PWM, then trigger interrupt as the CHnF bit is set. And in the interrupt function, it should update the CNT register with its initial value, CNTIN. However when FTM2_CNT=0xFFFF, in another word, the width of pulse is greater than the the specified fix value. The interrupt function will be triggered again as TOF bit is set. In this time, it need to make the digital output to be set to on.
4. FTM2 channel1 is used to detect the falling edge of the input PWM, then trigger the interrupt when falling edge occurs and the digital output will be set to off in interrupt function.
Hope it helps.
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------