Simple example of Quad Timer for the MIMXRT1052DV6JB

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

Simple example of Quad Timer for the MIMXRT1052DV6JB

Jump to solution
908 Views
ed_graham
Contributor II

I am new to firmware programming and would like some help setting up a quad timer for PWM.  I am using the QTMR_SetupPwm() function in file fsl_qtmr.c from the SDK.  I don't know what value to supply for the source clock frequency (parameter srcClock_Hz); presumably this relates to the particular processor I am using.  Is it the frequency written in the data sheet for the i.MX RT1050, namely 600 MHz?

I'm trying to create pulses of varying frequencies ranging from 1 Hz to 25 KHz.  For each frequency, I need to set the duty cycles so that the signal stays low for a specified number of microseconds.  I'm a bit confused as to how to specify the parameters to QTMR_SetupPwm() in order to achieve this.  In particular, I often fall foul of the assertions on these lines:

 /* This should not be a 16-bit overflow value. If it is, change to a larger divider for clock source. */
assert(highCount <= 0xFFFFU);
assert(lowCount <= 0xFFFFU);

How do I "change to a larger divider for clock source"?  What does that actually mean?

Labels (1)
Tags (3)
0 Kudos
Reply
1 Solution
899 Views
ed_graham
Contributor II

In the end I got it working, although I still don't really understand why.  The quad timer for PWM uses the IP Bus global clock (kCLOCK_IpgClk), which ticks at 150 MHz.  For some reason I need to divide this by three and use that value, 50 MHz, as the clock frequency (srcClock_Hz).  Then to achieve smaller divisions (lower frequencies) I can specify the primarySource property of the qtmr_config_t object to be anything from kQTMR_ClockDivide_1 to kQTMR_ClockDivide_128.  (kQTMR_ClockDivide_128 was the "larger divider" I was seeking in my original post.)

View solution in original post

0 Kudos
Reply
1 Reply
900 Views
ed_graham
Contributor II

In the end I got it working, although I still don't really understand why.  The quad timer for PWM uses the IP Bus global clock (kCLOCK_IpgClk), which ticks at 150 MHz.  For some reason I need to divide this by three and use that value, 50 MHz, as the clock frequency (srcClock_Hz).  Then to achieve smaller divisions (lower frequencies) I can specify the primarySource property of the qtmr_config_t object to be anything from kQTMR_ClockDivide_1 to kQTMR_ClockDivide_128.  (kQTMR_ClockDivide_128 was the "larger divider" I was seeking in my original post.)

0 Kudos
Reply