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