void FTM1_init(void)
{
PCC->PCCn[PCC_FTM1_INDEX] &= ~PCC_PCCn_CGC_MASK;
PCC->PCCn[PCC_FTM1_INDEX] |= PCC_PCCn_PCS(0b010)
| PCC_PCCn_CGC_MASK;
FTM1->MODE |= FTM_MODE_WPDIS_MASK;
FTM1->SC |= FTM_SC_PS(7); //Prescale Factor Selection
FTM1->SC |= FTM_SC_FLTPS(0b1111); //FLTPS[3:0] ≠ 0
FTM1->FILTER |= FTM_FILTER_CH1FVAL(0b1111);//CHnFVAL[3:0] ≠ 0
FTM1->COMBINE = 0x00000000;
FTM1->POL = 0x00000000;
}
according to Table 47-7. FTM Channel Input Filter Delay,register set as below FTM_SC_FLTPS(0b1111);FTM_FILTER_CH1FVAL(0b1111);
it means the delay time can calculate as -> 4 rising edges of FTM input clock + (1 + 4 × CHnFVAL[3:0]) rising edges of FTM filter clock.
FTM input clock:8HMhz(fixed freq)/128 divide=62.5Khz;
FTM filter clock:sys clk(80Mhz)/16 divide = 5Mhz;
delay time = 4/62.5KHz+61/5Mhz=64us+12.2us=76.2us;
In fact,the input capture can detect 16us period PWM.