<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>i.MX Processors中的主题 Re: QTMR PWM Example</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/QTMR-PWM-Example/m-p/1421003#M187630</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/196067"&gt;@DFaulkner&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Not all the pins can be used as the &lt;SPAN&gt;QTIMER2_TIMER0&amp;nbsp;PWM pin, please check the IO chapter:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kerryzhou_0-1646118321600.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/172074iCA5F8B68953D1ABD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kerryzhou_0-1646118321600.png" alt="kerryzhou_0-1646118321600.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;When you select the related pin, you also need to configure it in the pin_mux.c, please check the current SDK code for QTIMER.&lt;/P&gt;
&lt;P&gt;SDK_2_11_0_MIMXRT1160-EVK\boards\evkmimxrt1160\driver_examples\qtmr&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wish it helps you!&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Kerry&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Mar 2022 07:07:23 GMT</pubDate>
    <dc:creator>kerryzhou</dc:creator>
    <dc:date>2022-03-01T07:07:23Z</dc:date>
    <item>
      <title>QTMR PWM Example</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/QTMR-PWM-Example/m-p/1415570#M187156</link>
      <description>&lt;P&gt;MCUXpresso IDE v11.4.1 [Build 6260] [2021-09-15]&lt;/P&gt;&lt;P&gt;SDK_2.x_MIMXRT1160-EVK: Version 2.1.0&lt;/P&gt;&lt;P&gt;EVK1160 PCB&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to get my PWM started using&amp;nbsp;QTIMER2_TIMER0 for&amp;nbsp;GPIO_DISP_B1_01 (D13). Here is my code setup from the driver example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;uint8_t i = 0;&lt;BR /&gt;qtmr_config_t qtmrConfig;&lt;/P&gt;&lt;P&gt;/* Board pin, clock, debug console init */&lt;BR /&gt;BOARD_ConfigMPU();&lt;BR /&gt;BOARD_InitPins();&lt;BR /&gt;BOARD_BootClockRUN();&lt;BR /&gt;BOARD_InitDebugConsole();&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*!&lt;BR /&gt;* brief Sets up Quad timer module for PWM signal output.&lt;BR /&gt;*&lt;BR /&gt;* The function initializes the timer module according to the parameters passed in by the user. The&lt;BR /&gt;* function also sets up the value compare registers to match the PWM signal requirements.&lt;BR /&gt;*&lt;BR /&gt;* param base Quad Timer peripheral base address&lt;BR /&gt;* param channel Quad Timer channel number&lt;BR /&gt;* param pwmFreqHz PWM signal frequency in Hz&lt;BR /&gt;* param dutyCyclePercent PWM pulse width, value should be between 0 to 100&lt;BR /&gt;* 0=inactive signal(0% duty cycle)...&lt;BR /&gt;* 100=active signal (100% duty cycle)&lt;BR /&gt;* param outputPolarity true: invert polarity of the output signal, false: no inversion&lt;BR /&gt;* param srcClock_Hz Main counter clock in Hz.&lt;BR /&gt;*&lt;BR /&gt;* return Returns an error if there was error setting up the signal.&lt;BR /&gt;*/&lt;BR /&gt;status_t QTMR_SetupPwm(TMR_Type *base,&lt;BR /&gt;qtmr_channel_selection_t channel,&lt;BR /&gt;uint32_t pwmFreqHz,&lt;BR /&gt;uint8_t dutyCyclePercent,&lt;BR /&gt;bool outputPolarity,&lt;BR /&gt;uint32_t srcClock_Hz)&lt;BR /&gt;{&lt;BR /&gt;uint32_t periodCount, highCount, lowCount;&lt;BR /&gt;uint16_t reg;&lt;BR /&gt;status_t status;&lt;/P&gt;&lt;P&gt;if (dutyCyclePercent &amp;lt;= 100U)&lt;BR /&gt;{&lt;BR /&gt;/* Set OFLAG pin for output mode and force out a low on the pin */&lt;BR /&gt;base-&amp;gt;CHANNEL[channel].SCTRL |= (TMR_SCTRL_FORCE_MASK | TMR_SCTRL_OEN_MASK);&lt;/P&gt;&lt;P&gt;/* Counter values to generate a PWM signal */&lt;BR /&gt;periodCount = srcClock_Hz / pwmFreqHz;&lt;BR /&gt;highCount = periodCount * dutyCyclePercent / 100U;&lt;BR /&gt;lowCount = periodCount - highCount;&lt;/P&gt;&lt;P&gt;if (highCount &amp;gt; 0U)&lt;BR /&gt;{&lt;BR /&gt;highCount -= 1U;&lt;BR /&gt;}&lt;BR /&gt;if (lowCount &amp;gt; 0U)&lt;BR /&gt;{&lt;BR /&gt;lowCount -= 1U;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* This should not be a 16-bit overflow value. If it is, change to a larger divider for clock source. */&lt;BR /&gt;assert(highCount &amp;lt;= 0xFFFFU);&lt;BR /&gt;assert(lowCount &amp;lt;= 0xFFFFU);&lt;/P&gt;&lt;P&gt;/* Setup the compare registers for PWM output */&lt;BR /&gt;base-&amp;gt;CHANNEL[channel].COMP1 = (uint16_t)lowCount;&lt;BR /&gt;base-&amp;gt;CHANNEL[channel].COMP2 = (uint16_t)highCount;&lt;/P&gt;&lt;P&gt;/* Setup the pre-load registers for PWM output */&lt;BR /&gt;base-&amp;gt;CHANNEL[channel].CMPLD1 = (uint16_t)lowCount;&lt;BR /&gt;base-&amp;gt;CHANNEL[channel].CMPLD2 = (uint16_t)highCount;&lt;/P&gt;&lt;P&gt;reg = base-&amp;gt;CHANNEL[channel].CSCTRL;&lt;BR /&gt;/* Setup the compare load control for COMP1 and COMP2.&lt;BR /&gt;* Load COMP1 when CSCTRL[TCF2] is asserted, load COMP2 when CSCTRL[TCF1] is asserted&lt;BR /&gt;*/&lt;BR /&gt;reg &amp;amp;= (uint16_t)(~(TMR_CSCTRL_CL1_MASK | TMR_CSCTRL_CL2_MASK));&lt;BR /&gt;reg |= (TMR_CSCTRL_CL1(kQTMR_LoadOnComp2) | TMR_CSCTRL_CL2(kQTMR_LoadOnComp1));&lt;BR /&gt;base-&amp;gt;CHANNEL[channel].CSCTRL = reg;&lt;/P&gt;&lt;P&gt;if (outputPolarity)&lt;BR /&gt;{&lt;BR /&gt;/* Invert the polarity */&lt;BR /&gt;base-&amp;gt;CHANNEL[channel].SCTRL |= TMR_SCTRL_OPS_MASK;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;/* True polarity, no inversion */&lt;BR /&gt;base-&amp;gt;CHANNEL[channel].SCTRL &amp;amp;= ~(uint16_t)TMR_SCTRL_OPS_MASK;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;reg = base-&amp;gt;CHANNEL[channel].CTRL;&lt;BR /&gt;reg &amp;amp;= ~(uint16_t)TMR_CTRL_OUTMODE_MASK;&lt;BR /&gt;/* Count until compare value is reached and re-initialize the counter, toggle OFLAG output&lt;BR /&gt;* using alternating compare register&lt;BR /&gt;*/&lt;BR /&gt;reg |= (TMR_CTRL_LENGTH_MASK | TMR_CTRL_OUTMODE(kQTMR_ToggleOnAltCompareReg));&lt;BR /&gt;base-&amp;gt;CHANNEL[channel].CTRL = reg;&lt;/P&gt;&lt;P&gt;status = kStatus_Success;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;/* Invalid dutycycle */&lt;BR /&gt;status = kStatus_Fail;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return status;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is for this enum:&lt;/P&gt;&lt;P&gt;status_t QTMR_SetupPwm(TMR_Type *base,&lt;BR /&gt;qtmr_channel_selection_t channel,&lt;BR /&gt;uint32_t pwmFreqHz,&lt;BR /&gt;uint8_t dutyCyclePercent,&lt;BR /&gt;bool outputPolarity,&lt;BR /&gt;uint32_t srcClock_Hz)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where should these parameters be defined? Are they only initialized or do they have a default value somewhere that I am missing?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 21:15:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/QTMR-PWM-Example/m-p/1415570#M187156</guid>
      <dc:creator>DFaulkner</dc:creator>
      <dc:date>2022-02-17T21:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: QTMR PWM Example</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/QTMR-PWM-Example/m-p/1421003#M187630</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/196067"&gt;@DFaulkner&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Not all the pins can be used as the &lt;SPAN&gt;QTIMER2_TIMER0&amp;nbsp;PWM pin, please check the IO chapter:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kerryzhou_0-1646118321600.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/172074iCA5F8B68953D1ABD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kerryzhou_0-1646118321600.png" alt="kerryzhou_0-1646118321600.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;When you select the related pin, you also need to configure it in the pin_mux.c, please check the current SDK code for QTIMER.&lt;/P&gt;
&lt;P&gt;SDK_2_11_0_MIMXRT1160-EVK\boards\evkmimxrt1160\driver_examples\qtmr&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wish it helps you!&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Kerry&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 07:07:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/QTMR-PWM-Example/m-p/1421003#M187630</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2022-03-01T07:07:23Z</dc:date>
    </item>
  </channel>
</rss>

