Simple example of Quad Timer for the MIMXRT1052DV6JB

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Simple example of Quad Timer for the MIMXRT1052DV6JB

跳至解决方案
879 次查看
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?

标签 (1)
标记 (3)
0 项奖励
回复
1 解答
870 次查看
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 项奖励
回复
1 回复
871 次查看
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 项奖励
回复