AnsweredAssumed Answered

S32K 144 FTM Timer.

Question asked by KWAK D.Y on Jun 24, 2018
Latest reply on Jun 26, 2018 by Daniel Martynek

I am running a timer interrupt using FTM Timer.

I set the interrupt in 1ms cycle.

But I want to clear the FTM timer count before the 1ms interrupt is called, so that the interrupt is not called.

I set the interrupt to be called when FTM2.cnt is 8000.

How does FTM2.Cnt clear before it reaches 8000?

 

 

void FTM2_init(void)
{
 PCC->PCCn[PCC_FTM2_INDEX] &= ~PCC_PCCn_CGC_MASK;  /* Ensure clk disabled for config */
 PCC->PCCn[PCC_FTM2_INDEX] |= PCC_PCCn_PCS(0b001) /* Clock Src=1, 8 MHz SOSCDIV1_CLK */
        |  PCC_PCCn_CGC_MASK;   /* Enable clock for FTM regs */
 FTM2->MODE |= FTM_MODE_WPDIS_MASK;      /* Write protect to registers disabled (default) */
 FTM2->SC = 0x00000100;            /* TOIE (Timer Overflow Interrupt Ena) = 1 (default) */
                                                                    /* PS (Prescaler factor) = 3. Prescaler = 1 */
 FTM2->COMBINE = 0x00000000;       /* FTM mode settings used: DECAPENx, MCOMBINEx, COMBINEx=0  */
 FTM2->MOD = 8000-1;                        // 1ms
}

 

INT_SYS_InstallHandler(FTM2_Ovf_Reload_IRQn, &ClearFtm2Int, (isr_t *)0);

Outcomes