Simple example of Quad Timer for the MIMXRT1052DV6JB

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Simple example of Quad Timer for the MIMXRT1052DV6JB

ソリューションへジャンプ
1,001件の閲覧回数
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 解決策
992件の閲覧回数
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 返信
993件の閲覧回数
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 件の賞賛
返信