QTMR resets all counters upon capture

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

QTMR resets all counters upon capture

1,215 Views
madisonchou
Contributor III

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!! 

0 Kudos
7 Replies

1,067 Views
madisonchou
Contributor III

Hi Jeremy,

I would hope that you reflect my issue back to the team, first verify my finding, then when proving true, update RT family's Reference Manual.

Regards,

Jei

0 Kudos

1,067 Views
madisonchou
Contributor III

Hi Jeremy,

Thanks for prompt reply.   But the reset counters applies only to Compare event.   What I am looking for is the Capture event.   I haven't done exhausted testing yet.   But thus far, it doesn't work for Capture event.

Any other thoughts?

Jei

0 Kudos

1,067 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Jei Chou,

Thank you for your reply.
I'm afraid that QTMR doesn't support to initialize all four counter/timer upon the capture event happens.
Hope this is clear.

 

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,067 Views
madisonchou
Contributor III

Jeremy,

After experimenting some more, the counter reset by Master seems to work!

Attached is the changes to example project of iled_blinky.   I feed external 5KHz square waves to inputs of QTMR3.   Each input has different delay (leading or lagging) to Master.

  • TMR3_TIMER0 == GPIO_AD_B1_00 == RT1060 EVK J24-10 (Master)
  • TMR3_TIMER1 == GPIO_AD_B1_01 == RT1060 EVK J24-9, lag by 5uS
  • TMR3_TIMER2 == GPIO_AD_B1_02 == RT1060 EVK J22-7, lag by 10uS
  • TMR3_TIMER3 == GPIO_AD_B1_03 == RT1060 EVK J22-8, lead by 5uS

The debug output shows reasonable captures:

Enter any key => 1
15180, 14799, 14421, 378

0 Kudos

1,067 Views
madisonchou
Contributor III

Here is the attachment.

0 Kudos

1,067 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Jei Chou,

Thanks for the sharing:smileyhappy:.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,067 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Jei Chou,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Q1)  Is there a way to clear other 3 counters when the master (say counter0) is reset (i.e. reload) upon capture event?
-- It's able to clear other 3 counters when the master encounters a compare event if enabling the COINIT feature.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos