FTM PWM input filter

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

FTM PWM input filter

847 Views
Lauch_Spargel
Contributor II

Hello,

is there a example for a FTMinput filter configuration?

I would like to debounce a pwm signal. Is the FTM filter useful for this application or should I implement the debouncing with software? Or is there a fitler by default? And are there pullup or pulldown resistors at the input pins?

This is the FTM configuration I am using.

 

/* - Dual-Edge Capture Mode */
void FTM0_Dual_Edge_Capture_Mode()
{
    /* Enable clock for PORTD */
    PCC->PCCn[PCC_PORTD_INDEX] = PCC_PCCn_CGC_MASK;
    /* Select and enable clock for FTM0 */
    PCC->PCCn[PCC_FTM0_INDEX] =  PCC_PCCn_PCS(6) | PCC_PCCn_CGC_MASK;

    PORTD->PCR[15] = PORT_PCR_MUX(2);		// Set PTD15 for FTM0 - Channel0

	S32_NVIC->ISER[FTM0_Ch0_Ch1_IRQn / 32] |= (1 << (FTM0_Ch0_Ch1_IRQn % 32));		// Enable interrupt

	/* Enable dual-edge capture mode */
	FTM0->COMBINE= FTM_COMBINE_DECAPEN0_MASK | FTM_COMBINE_DECAP0_MASK
			     | FTM_COMBINE_DECAPEN1_MASK | FTM_COMBINE_DECAP1_MASK;

	/* Set CNTIN */
	FTM0->CNTIN = FTM_CNTIN_INIT(0);

	/* Select positive polarity pulse width measurement and enable continuous mode for FTM0_CH0 */
	FTM0->CONTROLS[0].CnSC =  FTM_CnSC_MSA_MASK | FTM_CnSC_ELSA_MASK;
    FTM0->CONTROLS[1].CnSC =  FTM_CnSC_ELSB_MASK | FTM_CnSC_CHIE_MASK;

    /* Reset counter */
    FTM0->CNT = 0;
    /* Select clock */
    FTM0->SC = FTM_SC_CLKS(1)
    		   |FTM_SC_PS(7);
    FTM0->MOD = 62500 -1 ;     	/* FTM1 counter final value (used for PWM mode) 			*/
    								/* FTM1 Period = MOD-CNTIN+0x0001 ~= 62500 ctr clks  		*/
    								/* 8MHz /128 = 62.5kHz ->  ticks -> 1Hz 					*/
}

 

 

 

 

0 Kudos
Reply
1 Reply

829 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

yes, the FTM input filter can be used , see more in chapter 47.5.5.1 Filter for Input Capture Mode of teh RM. It is enough to set FILTER[CH0FVAL] and SC[FLTPS] values.
For example https://community.nxp.com/t5/S32K/About-the-S32K146-FTM-input-capture-filter-function/m-p/1245500 discusses filtering time calculation

BR, Petr