Two input clock sources to Quad timer channels primary count source

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

Two input clock sources to Quad timer channels primary count source

325 Views
Sena0987
Contributor I

I am using MKM34z256VLL7 controller,

I want compare two clock frequencies using quad timer.

 I want to give internal clock (MCGIRCLK) to the quad time chanel 1 primary count source and external clock source input to the quad timer channel 2 primary count source to get the channel 1 counter value and channel 2  counter value . Is it possible, can you give me an example code for it. 

0 Kudos
Reply
1 Reply

275 Views
Celeste_Liu
NXP Employee
NXP Employee

Hello @Sena0987 ,

Thanks for your post. 

According to the RM, it's possible to achieve your requirements when using MKM34z256VLL7.

The Quad Timer module has four 16-bit counters/timers with the ability to configure different clock sources for each channel. This allows for comparing two different clock frequencies.

To set the MCGIRCLK as the primary count source for QTMR channel 1, you need to configure the TMR1PCSSEL field in the SIM_MISC_CTL register. Set it to "00" and configure TMR1_CTRL[PCS] = 1xxxb to route MCGIRCLK to channel 1.

For the external clock source on QTMR channel 2, first, identify the connected pin. Then, configure the TMR2PCSSEL field in the SIM_MISC_CTL register to select the external clock source input and set TMR2_CTRL[PCS] = 1xxxb.

Celeste_Liu_1-1745561770267.png

 

After configuring the clock sources, the QTMR starts counting. You can obtain the counter values of channel 1 and channel 2 by reading their respective counter registers (TMRx_CNTR, where x is the channel number). In your program, read these registers at appropriate times for frequency comparison calculations. For example, read the values at a specific time interval and calculate the frequencies based on the count changes and the time interval.

Celeste_Liu_2-1745562086989.png

 

I'm sorry we don't have such example code. You'll need to develop it on your own. However, you can start with the QTimer demo in our SDK to speed up your development.

Celeste_Liu_0-1745561643370.png

 

The SDK can be downloaded at Select Board | MCUXpresso SDK Builder.

Hope it can help you.

BRs,

Celeste

 

-------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the "ACCEPT AS SOLUTION" button. Thank you!
-------------------------------------------------------------------------------------------------------------------

 

0 Kudos
Reply