<?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: S32K116 PWM generation using FLEXIO - Cannot set duty cycle to 0 in S32 SDK</title>
    <link>https://community.nxp.com/t5/S32-SDK/S32K116-PWM-generation-using-FLEXIO-Cannot-set-duty-cycle-to-0/m-p/1433589#M2460</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/141175"&gt;@junxi_cai&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I have been testing it today.&lt;/P&gt;
&lt;P&gt;It works with this configuration:&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;FLEXIO-&amp;gt;SHIFTCTL[0] |= (1 &amp;lt;&amp;lt; 7); // PINPOL = 1, Pin is active low&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you test it on your side?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR, Daniel&lt;/P&gt;</description>
    <pubDate>Thu, 24 Mar 2022 17:07:02 GMT</pubDate>
    <dc:creator>danielmartynek</dc:creator>
    <dc:date>2022-03-24T17:07:02Z</dc:date>
    <item>
      <title>S32K116 PWM generation using FLEXIO - Cannot set duty cycle to 0</title>
      <link>https://community.nxp.com/t5/S32-SDK/S32K116-PWM-generation-using-FLEXIO-Cannot-set-duty-cycle-to-0/m-p/1431509#M2453</link>
      <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;I am currently working on a project using FLEXIO to emulate the PWM generation.&lt;/P&gt;&lt;P&gt;Here is the problem I am facing:&lt;/P&gt;&lt;P&gt;When I am trying to stop PWM generation for the duty cycle 0 case, I cannot do that. It outputs the clock fed to the FLEXIO instead of the voltage low.&lt;/P&gt;&lt;P&gt;As the application note AN12174 suggests 'flexio_pwm_stop() function disables the timer0 by setting TIMOD and disable generating the PWM.' I set TIMOD to 0 when the duty cycle is equal to 0.&lt;/P&gt;&lt;P&gt;Here is my code for reference:&lt;/P&gt;&lt;P&gt;if(duty &amp;gt; 0)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;/*!&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* FlexIO Timer Control:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* ============================&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;FLEXIO-&amp;gt;TIMCTL[0] |=&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FLEXIO_TIMCTL_TIMOD(2) /* Dual 8-bit counters PWM high mode */&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|FLEXIO_TIMCTL_PINSEL(0) /* Select FXIO_D0 */&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|FLEXIO_TIMCTL_PINCFG(3); /* Timer pin output */&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;low = ( ( ( (4000000/20000) * (100-duty)) / 100) - 1) &amp;lt;&amp;lt; 8;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;high= ( ( (4000000/20000) * duty) / 100) - 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;FLEXIO-&amp;gt;TIMCMP[0] = high | low;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;FLEXIO-&amp;gt;TIMCTL[0] |=&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FLEXIO_TIMCTL_TIMOD(0) /* Timer Disabled. */&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|FLEXIO_TIMCTL_PINSEL(0 /* Select FXIO_D0 */&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|FLEXIO_TIMCTL_PINCFG(3); /* Timer pin output */&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Very appreciated for the help.&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Junxi&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 23:24:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-SDK/S32K116-PWM-generation-using-FLEXIO-Cannot-set-duty-cycle-to-0/m-p/1431509#M2453</guid>
      <dc:creator>junxi_cai</dc:creator>
      <dc:date>2022-03-21T23:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: S32K116 PWM generation using FLEXIO - Cannot set duty cycle to 0</title>
      <link>https://community.nxp.com/t5/S32-SDK/S32K116-PWM-generation-using-FLEXIO-Cannot-set-duty-cycle-to-0/m-p/1431996#M2454</link>
      <description>&lt;P&gt;Hello Junxi,&lt;/P&gt;
&lt;P&gt;I'm not sure if I understand the question, but if you need an explanation why the duty cycle cannot be set to 0%, this is given by the operation of the 8bit PWM mode (54.3.1.21 Timer Compare N Register (TIMCMP0 - TIMCMP3)):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="danielmartynek_0-1647953188902.png" style="width: 849px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/174421i347C9359842396C5/image-dimensions/849x56?v=v2" width="849" height="56" role="button" title="danielmartynek_0-1647953188902.png" alt="danielmartynek_0-1647953188902.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Regarding the AN12174 recommendation, do you have any problems with this approach?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;BR, Daniel&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 12:49:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-SDK/S32K116-PWM-generation-using-FLEXIO-Cannot-set-duty-cycle-to-0/m-p/1431996#M2454</guid>
      <dc:creator>danielmartynek</dc:creator>
      <dc:date>2022-03-22T12:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: S32K116 PWM generation using FLEXIO - Cannot set duty cycle to 0</title>
      <link>https://community.nxp.com/t5/S32-SDK/S32K116-PWM-generation-using-FLEXIO-Cannot-set-duty-cycle-to-0/m-p/1432025#M2455</link>
      <description>&lt;P&gt;Hello Daniel,&lt;/P&gt;&lt;P&gt;Thank you for the response. Sorry for the confusion. Let me clarify it.&lt;/P&gt;&lt;P&gt;What I want to achieve is when the duty cycle is 0, the PWM output should be at voltage level low always.&lt;/P&gt;&lt;P&gt;My PWM is using FLEXIO which fed by SIRCDIV2_CLK (4MHz), the frequency is 20kHz.&lt;/P&gt;&lt;P&gt;My first approach is as what you said, set&amp;nbsp;FLEXIO-&amp;gt;TIMCMP[0] = 0x0000 to configure the comparison counter to be 0.&lt;/P&gt;&lt;P&gt;So I set the duty cycle of the PWM to be 50% first to get a 20kHz, 50% duty cycle PWM. Then I set the duty cycle to be 0 by setting&amp;nbsp;FLEXIO-&amp;gt;TIMCMP[0] = 0x0000&lt;/P&gt;&lt;P&gt;However, when the TIMCMP[0] = 0, I measured a PWM with 2MHz and 50% duty cycle on my oscilloscope instead of a straight line at 0v.&lt;/P&gt;&lt;P&gt;Then my second approach is to disable the timer0 by setting TIMOD to 0.&lt;/P&gt;&lt;P&gt;So I repeat the sample step as above, after I set the duty cycle to 50%, I can see the TIMOD bit of TIMCTL0 set to be 2, and PWM generated correctly.&lt;/P&gt;&lt;P&gt;Then I tried set duty cycle to 0 by set&amp;nbsp;TIMOD bit of TIMCTL0 to be 0 to stop the PWM.&lt;/P&gt;&lt;P&gt;However, it doesn't all me to configure the TIMOD again. It stays at 2.&lt;/P&gt;&lt;P&gt;And the PWM is still at 50% duty cycle instead of getting off.&lt;/P&gt;&lt;P&gt;Could you please let me know if I did something wrong?&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Junxi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 13:47:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-SDK/S32K116-PWM-generation-using-FLEXIO-Cannot-set-duty-cycle-to-0/m-p/1432025#M2455</guid>
      <dc:creator>junxi_cai</dc:creator>
      <dc:date>2022-03-22T13:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: S32K116 PWM generation using FLEXIO - Cannot set duty cycle to 0</title>
      <link>https://community.nxp.com/t5/S32-SDK/S32K116-PWM-generation-using-FLEXIO-Cannot-set-duty-cycle-to-0/m-p/1433589#M2460</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/141175"&gt;@junxi_cai&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I have been testing it today.&lt;/P&gt;
&lt;P&gt;It works with this configuration:&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;FLEXIO-&amp;gt;SHIFTCTL[0] |= (1 &amp;lt;&amp;lt; 7); // PINPOL = 1, Pin is active low&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you test it on your side?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR, Daniel&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 17:07:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-SDK/S32K116-PWM-generation-using-FLEXIO-Cannot-set-duty-cycle-to-0/m-p/1433589#M2460</guid>
      <dc:creator>danielmartynek</dc:creator>
      <dc:date>2022-03-24T17:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: S32K116 PWM generation using FLEXIO - Cannot set duty cycle to 0</title>
      <link>https://community.nxp.com/t5/S32-SDK/S32K116-PWM-generation-using-FLEXIO-Cannot-set-duty-cycle-to-0/m-p/1438458#M2477</link>
      <description>&lt;P&gt;Hello Daniel,&lt;/P&gt;&lt;P&gt;Sorry for the late response. I also tried that, it is not get set to Low.&lt;/P&gt;&lt;P&gt;Instead, I use the clear register API to clear the TIMCTL register as below to solve the problem.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;REG_BIT_CLEAR32(&amp;amp;FLEXIO-&amp;gt;TIMCTL[ChannelNumber],0xFFFFFFFFu);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 15:51:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-SDK/S32K116-PWM-generation-using-FLEXIO-Cannot-set-duty-cycle-to-0/m-p/1438458#M2477</guid>
      <dc:creator>junxi_cai</dc:creator>
      <dc:date>2022-04-04T15:51:57Z</dc:date>
    </item>
  </channel>
</rss>

