<?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>topic Re: PWM not returning LOW when timer stopped in i.MX RT Crossover MCUs</title>
    <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/PWM-not-returning-LOW-when-timer-stopped/m-p/1535590#M21980</link>
    <description>&lt;P&gt;Thanks for taking the time to reply.&lt;/P&gt;&lt;P&gt;Yes that does work. I am surprised the fsl_pwm PWM driver doesn't have a function to set/clear the OUTEN bits if this is something that is obviously important.&lt;/P&gt;&lt;P&gt;I am also confused as to why I needed to add an external pull-down resistor because all the PWM pins have a 100K pull-down enabled in the pin configuration. I am assuming that this pull-down is still used when the pin is configured for PWM and not a general purpose GPIO?&lt;/P&gt;</description>
    <pubDate>Tue, 11 Oct 2022 11:07:57 GMT</pubDate>
    <dc:creator>gary_metalle</dc:creator>
    <dc:date>2022-10-11T11:07:57Z</dc:date>
    <item>
      <title>PWM not returning LOW when timer stopped</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/PWM-not-returning-LOW-when-timer-stopped/m-p/1533337#M21901</link>
      <description>&lt;P&gt;I am using PWM2 on iMX.RT to control an RGB LED which is working ok except that when I turn the LED off using the following call, the outputs are randomly HIGH or LOW depending on the PWM value when it was turned off.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;PWM_StopTimer(PWM2, kPWM_Control_Module_0 | kPWM_Control_Module_1);&lt;/LI-CODE&gt;&lt;P&gt;I have had a look on the forum and the closest related question is &lt;A href="https://community.nxp.com/t5/i-MX-RT/PWM-on-i-MX-RT-1050-EVKB/td-p/858849" target="_blank" rel="noopener"&gt;this one&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;I have a feeling it's something to do with the XBAR but I am not sure and am confused why the XBAR should be involved when using the PWM anyway. The PWM SDK example for the iMX.RT1052 is quite lengthy for something I would expect to be quite simple.&lt;/P&gt;&lt;P&gt;Here's the code I use to set up the three channels of the PWM. I have a separate timer that I use for blinking/flashing of the RGB LED and it is there that I call PWM_StartTimer or PWM_StopTimer accordingly.&lt;/P&gt;&lt;P&gt;I basically want to ensure that when the PWM is stopped all outputs are LOW.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    pwm_signal_param_t pwmSignal[3];
    pwm_config_t pwmConfig;
    pwm_fault_param_t faultConfig;
    uint32_t pwmSourceClockInHz;
    uint32_t pwmFrequencyInHz = LED_PWM_FREQUENCY_IN_HZ;

    // set the PWM Fault inputs to a low value
#if 1
    XBARA_Init(XBARA1);
    XBARA_SetSignalsConnection(XBARA1, kXBARA1_InputLogicHigh, kXBARA1_OutputFlexpwm2Fault0);
    XBARA_SetSignalsConnection(XBARA1, kXBARA1_InputLogicHigh, kXBARA1_OutputFlexpwm2Fault1);
    XBARA_SetSignalsConnection(XBARA1, kXBARA1_InputLogicHigh, kXBARA1_OutputFlexpwm1234Fault2);
    XBARA_SetSignalsConnection(XBARA1, kXBARA1_InputLogicHigh, kXBARA1_OutputFlexpwm1234Fault3);
#endif

    PWM_GetDefaultConfig(&amp;amp;pwmConfig);

    pwmConfig.reloadLogic = kPWM_ReloadPwmFullCycle;		// use full cycle reload
    pwmConfig.enableDebugMode = true;						// turn on debug mode
    pwmConfig.pairOperation = kPWM_Independent;				// we don't want complementary pair
    pwmConfig.prescale = kPWM_Prescale_Divide_8;			// divide input clock by 8

    /* initialise both of the sub modules that we are going to be using */
    if (PWM_Init(PWM2, kPWM_Module_0, &amp;amp;pwmConfig) == kStatus_Fail)
    {
        LOG_WARN("PWM initialization failed for submodule 0.");
    }

    if (PWM_Init(PWM2, kPWM_Module_1, &amp;amp;pwmConfig) == kStatus_Fail)
    {
        LOG_WARN("PWM initialization failed for submodule 1.");
    }

#if 0
    PWM2-&amp;gt;SM[kPWM_Module_0].DISMAP[0] = 0;
    PWM2-&amp;gt;SM[kPWM_Module_0].DISMAP[1] = 0;
    PWM2-&amp;gt;SM[kPWM_Module_1].DISMAP[0] = 0;
    PWM2-&amp;gt;SM[kPWM_Module_1].DISMAP[1] = 0;
#endif

    PWM_FaultDefaultConfig(&amp;amp;faultConfig);

#if 0
    faultConfig.faultLevel = true;
    faultConfig.enableCombinationalPath = false;
#endif

    /* Sets up the PWM fault protection */
    PWM_SetupFaults(PWM2, kPWM_Fault_0, &amp;amp;faultConfig);
    PWM_SetupFaults(PWM2, kPWM_Fault_1, &amp;amp;faultConfig);
    PWM_SetupFaults(PWM2, kPWM_Fault_2, &amp;amp;faultConfig);
    PWM_SetupFaults(PWM2, kPWM_Fault_3, &amp;amp;faultConfig);

#if 1
    /* Set PWM fault disable mapping for channels and submodules we're using */
    PWM_SetupFaultDisableMap(PWM2, kPWM_Module_0, kPWM_PwmA, kPWM_faultchannel_0,
                             kPWM_FaultDisable_0 | kPWM_FaultDisable_1 | kPWM_FaultDisable_2 | kPWM_FaultDisable_3);
    PWM_SetupFaultDisableMap(PWM2, kPWM_Module_0, kPWM_PwmB, kPWM_faultchannel_0,
                             kPWM_FaultDisable_0 | kPWM_FaultDisable_1 | kPWM_FaultDisable_2 | kPWM_FaultDisable_3);
    PWM_SetupFaultDisableMap(PWM2, kPWM_Module_1, kPWM_PwmA, kPWM_faultchannel_0,
                             kPWM_FaultDisable_0 | kPWM_FaultDisable_1 | kPWM_FaultDisable_2 | kPWM_FaultDisable_3);
#endif

    pwmSourceClockInHz = PWM_SRC_CLK_FREQ;

    // configuration for RED component
    pwmSignal[0].level            = kPWM_HighTrue;
    pwmSignal[0].deadtimeValue    = 0;
    pwmSignal[0].faultState       = kPWM_PwmFaultState0;
    pwmSignal[0].pwmChannel = kPWM_PwmA;
    pwmSignal[0].dutyCyclePercent = 0;

    // configuration for GREEN component
    pwmSignal[1].level            = kPWM_HighTrue;
    pwmSignal[1].deadtimeValue    = 0;
    pwmSignal[1].faultState       = kPWM_PwmFaultState0;
    pwmSignal[1].pwmChannel = kPWM_PwmB;
    pwmSignal[1].dutyCyclePercent = 0;

    if (PWM_SetupPwm(PWM2, kPWM_Module_0, pwmSignal, 2, kPWM_CenterAligned, pwmFrequencyInHz, pwmSourceClockInHz) == kStatus_Fail)
    {
        LOG_WARN("PWM setup failed.");
    }

    // configuration for BLUE component
    pwmSignal[2].level            = kPWM_HighTrue;
    pwmSignal[2].deadtimeValue    = 0;
    pwmSignal[2].faultState       = kPWM_PwmFaultState0;
    pwmSignal[2].pwmChannel = kPWM_PwmA;
    pwmSignal[2].dutyCyclePercent = 0;

    if (PWM_SetupPwm(PWM2, kPWM_Module_1, &amp;amp;pwmSignal[2], 1, kPWM_CenterAligned, pwmFrequencyInHz, pwmSourceClockInHz) == kStatus_Fail)
    {
        LOG_WARN("PWM setup failed.");
    }

    /* Set the load okay bit for both submodules to load registers from their buffer */
    PWM_SetPwmLdok(PWM2, kPWM_Control_Module_0 | kPWM_Control_Module_1, true);

    /* Start the PWM generation from Submodules 0 and 1 */
    PWM_StartTimer(PWM2, kPWM_Control_Module_0 | kPWM_Control_Module_1);&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 06 Oct 2022 11:03:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/PWM-not-returning-LOW-when-timer-stopped/m-p/1533337#M21901</guid>
      <dc:creator>gary_metalle</dc:creator>
      <dc:date>2022-10-06T11:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: PWM not returning LOW when timer stopped</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/PWM-not-returning-LOW-when-timer-stopped/m-p/1534450#M21943</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I suggest you clear the corresponding bits in PWM OUTEN register, which will disable the PWM signal output, but the PWM module continues to work.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xiangjun_rong_0-1665304693934.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/196178i53ACDE312332255B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xiangjun_rong_0-1665304693934.png" alt="xiangjun_rong_0-1665304693934.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the code to write the register.&lt;/P&gt;
&lt;P&gt;PWM2-&amp;gt;OUTEN=0x00;&lt;/P&gt;
&lt;P&gt;If you connect a external pull-down resistor or set the PWM signal pin as pull-down mode, the pin will be low logic.&lt;/P&gt;
&lt;P&gt;Hope it can help you&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2022 08:42:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/PWM-not-returning-LOW-when-timer-stopped/m-p/1534450#M21943</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2022-10-09T08:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: PWM not returning LOW when timer stopped</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/PWM-not-returning-LOW-when-timer-stopped/m-p/1535590#M21980</link>
      <description>&lt;P&gt;Thanks for taking the time to reply.&lt;/P&gt;&lt;P&gt;Yes that does work. I am surprised the fsl_pwm PWM driver doesn't have a function to set/clear the OUTEN bits if this is something that is obviously important.&lt;/P&gt;&lt;P&gt;I am also confused as to why I needed to add an external pull-down resistor because all the PWM pins have a 100K pull-down enabled in the pin configuration. I am assuming that this pull-down is still used when the pin is configured for PWM and not a general purpose GPIO?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 11:07:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/PWM-not-returning-LOW-when-timer-stopped/m-p/1535590#M21980</guid>
      <dc:creator>gary_metalle</dc:creator>
      <dc:date>2022-10-11T11:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: PWM not returning LOW when timer stopped</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/PWM-not-returning-LOW-when-timer-stopped/m-p/1535633#M21981</link>
      <description>&lt;P&gt;I think one of the problems I had was that the PWM pin was configured by default for KEEPER when it needed to be PULL. This meant the 100k pull-down wasn't being used. It does pay to be careful when configuring pins because it's not safe to assume that the configuration will be correct if you set a pin to use a peripheral such as PWM, you still have to make sure the other settings are correct. So for I2C etc you will want to make sure you have open drain etc.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 12:13:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/PWM-not-returning-LOW-when-timer-stopped/m-p/1535633#M21981</guid>
      <dc:creator>gary_metalle</dc:creator>
      <dc:date>2022-10-11T12:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: PWM not returning LOW when timer stopped</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/PWM-not-returning-LOW-when-timer-stopped/m-p/1535940#M21997</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I suppose that you can set SW_PAD_CTL_PAD_xxx register to enable on-chip pull-down resistor to get low logic of the PWM pin when the PWM outputting function is disabled. But it is a common design to connect pull-down resistor for each PWM pins.&lt;/P&gt;
&lt;P&gt;Hope it can help you&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 02:58:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/PWM-not-returning-LOW-when-timer-stopped/m-p/1535940#M21997</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2022-10-12T02:58:57Z</dc:date>
    </item>
  </channel>
</rss>

