AnsweredAssumed Answered

QTMR resets all counters upon capture

Question asked by Jei Chou on May 3, 2019
Latest reply on May 8, 2019 by Jei Chou

In Kinetis FTM module, it has only one counter that serves multiple timer input or output.   In RT, the 4 counters in a QTMR are independent.   Is there a way to clear other 3 counters when the master (say counter0) is reset (i.e. reload) upon capture event?

 

The equivalent code for Kinetis FTM is here:

FTM0->CONTROLS[ 0 ].CnSC = FTM_CnSC_ELSA_MASK + FTM_CnSC_ICRST_MASK; // MSB:MSA=00=input capture; ELSB:ELSA=01=rising edge; CNT reset on edge
FTM0->CONTROLS[ 1 ].CnSC = FTM_CnSC_ELSA_MASK; // MSB:MSA=00=input capture; ELSB:ELSA=01=rising edge
FTM0->CONTROLS[ 2 ].CnSC = FTM_CnSC_ELSA_MASK; // MSB:MSA=00=input capture; ELSB:ELSA=01=rising edge

FTM0->SC = FTM_SC_CLKS( 1 ); // Enable FTM @ 40MHz BUS_CLK; PS=div1

 

The behavior of above code is...

  • FTM0_CH0 rising edge is detected and counter value is latched into C0V.   The counter is reset to 0.
    • If the FTM0_CH0 input is a square wave, C0V measures its period.
  • Subsequently when FTM0_CH1 rising edge comes up, counter value is latched into C1V.
    • C1V in effect is the period between the two rising edges.   In other words, C1V measures the delay from CH0 to CH1.
  • FTM0_CH2 is the same as CH1.   Its capture, C2V, represents the delay from CH0 to CH2.

 

Thanks!! 

Outcomes