About the S32K146 FTM input capture filter function

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

About the S32K146 FTM input capture filter function

Jump to solution
2,078 Views
ByteWord
Contributor II

Problems with FTM input capture filtering

1.FTM1 is in input capture mode

2.FTIM1 input clk = 80MHz/128 = 625KHz

3.FTM1.SC.FLTPS = 15 (Divide by 16, filter clk = 625KHz/16 ≈ 40KHz)

4.FTM1.FILTER.CH0FVAL = 15

So,

Filtering time = 4 rising edges of FTM input clock+(1 + 4 × CHnFVAL[3:0]) rising edges of FTM filter clock

                     = 4/625KHz + (1 + 4*15)/40KHz = 6.4us + 1525us ≈ 1530us

If the input PWM signal frequency is 10kHz and the duty cycle is 50%, then the high level time is 50us;

If the filtering time is 1.53ms, the pulse should not be detected;But I can still detect the pulse;I don't know where I went wrong;

1 Solution
2,066 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

I took some tests and it works, the calculation seems to be correct, but the FTM filter clock is derived from the FTM System clock not from the FTM function clock (RM rev12.1, Table 27-9. Peripheral module clocking).

 

Regards,

Daniel

View solution in original post

0 Kudos
Reply
5 Replies
1,137 Views
xxw1
Contributor I

i have a same confusion like him,the input capture filter do not work.

0 Kudos
Reply
1,135 Views
xxw1
Contributor I
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.
0 Kudos
Reply
2,067 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

I took some tests and it works, the calculation seems to be correct, but the FTM filter clock is derived from the FTM System clock not from the FTM function clock (RM rev12.1, Table 27-9. Peripheral module clocking).

 

Regards,

Daniel

0 Kudos
Reply
2,058 Views
ByteWord
Contributor II

hi,thanks for your reply.Your reply has solved my problem.

"the FTM filter clock is derived from the FTM System clock not from the FTM function clock " help me a lot.

For me, the correct formula for filtering time would look something like this :

filtering clk= FTM sys clk/16 = 80MHz/16 = 5MHz

FTM input clk = 80MHz/128 = 625KHz

filtering time = 4 rising edges of FTM input clock+(1 + 4 × CHnFVAL[3:0]) rising edges of FTM filter clock

                    = 4/625KHz + (1 + 4*15)/5MHz = 18.6us

Therefore, it can detect pulses with a pulse width of 50us;

Thank you again!

1,134 Views
xxw1
Contributor I

hello,i'm struggle in the same problem and can i consult it with you

0 Kudos
Reply