S32K 144 FTM Timer.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

S32K 144 FTM Timer.

跳至解决方案
1,876 次查看
kwakd_y
Contributor III

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);

1 解答
1,400 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Writing any value to CNT[COUNT] updates the counter with its initial value, CNTIN.

Section 45.4.3.3m RM r.7.

Regards,

Daniel

在原帖中查看解决方案

1 回复
1,401 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Writing any value to CNT[COUNT] updates the counter with its initial value, CNTIN.

Section 45.4.3.3m RM r.7.

Regards,

Daniel