AnsweredAssumed Answered

Use FTM0 / 1 with a one-shot timer.

Question asked by jun yamada on Sep 14, 2019
Latest reply on Sep 17, 2019 by jun yamada

Hi.


I want to use the one-shot timer, but the CNT register does not seem to be reset even if the timer overflows.
So, remodeling to make CNT = 0 at FTM_StartTimer (), is there a problem?

Used for MODBUS silent interval timer.

 

Modify fsl_ftm.c (SDK_2.6.0_MKE04Z128xxx4)
static inline void FTM_StartTimer (FTM_Type * base, ftm_clock_source_t clockSource)
{
       uint32_t reg = base-> SC;

       if (base  ! = FTM2) {
              base-> CNT = 0u;       // 2019/09/14 add jun. 
       }
       reg & = ~ (FTM_SC_CLKS_MASK);
       reg | = FTM_SC_CLKS (clockSource);
       base-> SC = reg;
}

 

my application source is

// ================================================ =======
//        T3.5 character timer-timer start
// ================================================ =======
static inline void modbusT15Start (void)
{
       FTM_StopTimer (MODBUS_TMR_T15);
       FTM_StartTimer (MODBUS_TMR_T15, kFTM_SystemClock); // reset timer & start
}
// ================================================ =======
//        3.5 character timer-interrupt handler
// ================================================ =======
void MODBUS_TMR_T35_IRQ_HANDLER (void)
{
       / * Clear interrupt flag. * /
       FTM_ClearStatusFlags (MODBUS_TMR_T35, kFTM_TimeOverflowFlag);
       FTM_StopTimer (MODBUS_TMR_T35);
       modbusMatrix (E_MB_EV_T35_EXPIRED, 0);
}

 

 

 

jun.

Outcomes