<?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: how is pwm frequency setting parameters? in S32K</title>
    <link>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2096397#M48715</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;PWM frequency equation differs depending mode selected. For MCB up/down counting mode, the counter bus period is&amp;nbsp;&lt;SPAN&gt;global prescaler * internal prescaler * (2*period_in_ticks-2) / CORE_CLK. For the init setting from picture it gives PWM freq = 160e6/1/1/(2*16385-2) = 4.882KHz you calculated. You measure 3.9kHz, as MCB period is changed in code from default one. If you stop the code after init functions and have eMIOS FRZ bit cleared you will see&amp;nbsp;4.882KHz&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. for 30KHz PWM in OPWCMB mode you need to set MCB channel's period to period_in_tics = (CORE_CLK / global prescaler / internal prescaler / 30e3 + 2) / 2.&amp;nbsp; It gives 2667.66. Using 2667 value, it results in&amp;nbsp;&lt;/SPAN&gt;30.0075 kHz.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. third parameter in&amp;nbsp;Emios_Mcl_Ip_SetCounterBusPeriod determines value directly written to MCB channel A register. A register specifies the MCB period and for up/down mode it will be&amp;nbsp;160e6/1/1/(2*0x5000-2) =&lt;/SPAN&gt;3.906 kHz&lt;BR /&gt;For 0x1000 value used it is&amp;nbsp;&lt;SPAN&gt;160e6/1/1/(2*0x1000-2) =&amp;nbsp;&lt;/SPAN&gt;19.536&amp;nbsp;kHz&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;BR, Petr&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 13 May 2025 10:27:47 GMT</pubDate>
    <dc:creator>PetrS</dc:creator>
    <dc:date>2025-05-13T10:27:47Z</dc:date>
    <item>
      <title>how is pwm frequency setting parameters?</title>
      <link>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2096116#M48690</link>
      <description>&lt;P&gt;i know pwm frequency is&amp;nbsp;PWM frequency = CORE_CLK / global prescaler / internal prescaler / (B1+1).&lt;/P&gt;&lt;P&gt;but don't understand how is set that parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this pics are my current pwm frequncy setting.&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am using CH4(emios0).&amp;nbsp;&lt;/P&gt;&lt;P&gt;and i got pwm frequency is 3.906kHz.&lt;/P&gt;&lt;P&gt;i wanna set pwm frequency is 30kHz.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 487px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/337433i1D17D62E74AE57FF/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/337434i654FC528088EAF00/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.png" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/337435i6A560279CC099749/image-size/large?v=v2&amp;amp;px=999" role="button" title="3.png" alt="3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="4.png" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/337436iE487FF62BDD870A1/image-size/large?v=v2&amp;amp;px=999" role="button" title="4.png" alt="4.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i think CORE_CLK is 160Mhz,&amp;nbsp;global prescaler is 1.&amp;nbsp;internal prescaler is 1??? b1 is 32768.&lt;/P&gt;&lt;P&gt;so i expect pwm frequency is 160000000/1/1/(32768+1) = 4.882Khz.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. how i set parameter for getting 30Khz pwm parameter???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. what is mean 0x5000 in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Emios_Mcl_Ip_SetCounterBusPeriod&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;function parameter?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="5.png" style="width: 568px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/337437iE4B66CDA46E10853/image-size/large?v=v2&amp;amp;px=999" role="button" title="5.png" alt="5.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;i changed smaller than 0x5000 value like 0x1000.&lt;/P&gt;&lt;P&gt;then pwm frequency is changed more higher(3.906kHz-&amp;gt;19.53Khz).&amp;nbsp;&lt;/P&gt;&lt;P&gt;what is mean that value and what influence that value for pwm frequency formula?&lt;/P&gt;</description>
      <pubDate>Tue, 13 May 2025 05:49:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2096116#M48690</guid>
      <dc:creator>rlaxortn</dc:creator>
      <dc:date>2025-05-13T05:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: how is pwm frequency setting parameters?</title>
      <link>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2096397#M48715</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;PWM frequency equation differs depending mode selected. For MCB up/down counting mode, the counter bus period is&amp;nbsp;&lt;SPAN&gt;global prescaler * internal prescaler * (2*period_in_ticks-2) / CORE_CLK. For the init setting from picture it gives PWM freq = 160e6/1/1/(2*16385-2) = 4.882KHz you calculated. You measure 3.9kHz, as MCB period is changed in code from default one. If you stop the code after init functions and have eMIOS FRZ bit cleared you will see&amp;nbsp;4.882KHz&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. for 30KHz PWM in OPWCMB mode you need to set MCB channel's period to period_in_tics = (CORE_CLK / global prescaler / internal prescaler / 30e3 + 2) / 2.&amp;nbsp; It gives 2667.66. Using 2667 value, it results in&amp;nbsp;&lt;/SPAN&gt;30.0075 kHz.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. third parameter in&amp;nbsp;Emios_Mcl_Ip_SetCounterBusPeriod determines value directly written to MCB channel A register. A register specifies the MCB period and for up/down mode it will be&amp;nbsp;160e6/1/1/(2*0x5000-2) =&lt;/SPAN&gt;3.906 kHz&lt;BR /&gt;For 0x1000 value used it is&amp;nbsp;&lt;SPAN&gt;160e6/1/1/(2*0x1000-2) =&amp;nbsp;&lt;/SPAN&gt;19.536&amp;nbsp;kHz&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;BR, Petr&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 May 2025 10:27:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2096397#M48715</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2025-05-13T10:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: how is pwm frequency setting parameters?</title>
      <link>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2096823#M48735</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/52961"&gt;@PetrS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;after i watched your post, i tried.&amp;nbsp;&lt;/P&gt;&lt;P&gt;but result is different.&amp;nbsp;&lt;/P&gt;&lt;P&gt;when i apply&amp;nbsp;&lt;SPAN&gt;Emios_Mcl_Ip_SetCounterBusPeriod(pwmInstance0, pwmCH23, 0x14d5).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;i got pwm frequency is 30kHz.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;so i think formula is core_clk /&amp;nbsp;Period.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;bacause i changed code&amp;nbsp;Emios_Mcl_Ip_SetCounterBusPeriod(pwmInstance0, pwmCH23, 0x29aa). so i got pwm frequency is 15kHz.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i don't understand. because it is different with formula you teached.&lt;/P&gt;&lt;P&gt;and current pwm setting is same with post pics.&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 May 2025 01:14:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2096823#M48735</guid>
      <dc:creator>rlaxortn</dc:creator>
      <dc:date>2025-05-14T01:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: how is pwm frequency setting parameters?</title>
      <link>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2097135#M48755</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;this my measurement using RTD500&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PetrS_0-1747211486917.png" style="width: 685px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/337736i07FB445A38E9EC9D/image-dimensions/685x322?v=v2" width="685" height="322" role="button" title="PetrS_0-1747211486917.png" alt="PetrS_0-1747211486917.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;BR, Petr&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 May 2025 08:32:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2097135#M48755</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2025-05-14T08:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: how is pwm frequency setting parameters?</title>
      <link>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2097174#M48760</link>
      <description>1. for 30KHz PWM in OPWCMB mode you need to set MCB channel's period to period_in_tics = (CORE_CLK / global prescaler / internal prescaler / 30e3 + 2) / 2. It gives 2667.66. Using 2667 value, it results in 30.0075 kHz.&lt;BR /&gt;&lt;BR /&gt;i think is this formula is wrong.&lt;BR /&gt;</description>
      <pubDate>Wed, 14 May 2025 09:12:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2097174#M48760</guid>
      <dc:creator>rlaxortn</dc:creator>
      <dc:date>2025-05-14T09:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: how is pwm frequency setting parameters?</title>
      <link>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2097318#M48772</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I see calculation and measurement aligned&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PetrS_2-1747223529389.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/337776i45ACDE65FAD8BBF4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PetrS_2-1747223529389.png" alt="PetrS_2-1747223529389.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PetrS_3-1747223553194.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/337777iADF6C579334E3F85/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PetrS_3-1747223553194.png" alt="PetrS_3-1747223553194.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PetrS_0-1747223298834.png" style="width: 579px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/337774i3F09AA5FA1F6269C/image-dimensions/579x209?v=v2" width="579" height="209" role="button" title="PetrS_0-1747223298834.png" alt="PetrS_0-1747223298834.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;BR, Petr&lt;/P&gt;</description>
      <pubDate>Wed, 14 May 2025 11:53:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2097318#M48772</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2025-05-14T11:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: how is pwm frequency setting parameters?</title>
      <link>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2097770#M48806</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/52961"&gt;@PetrS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when i set Emios_Mcl_Ip_SetCounterBusPeriod(pwmInstance0, pwmCH23, 2667);.&lt;/P&gt;&lt;P&gt;i got pwm frequency 60Khz.&lt;/P&gt;</description>
      <pubDate>Thu, 15 May 2025 05:41:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2097770#M48806</guid>
      <dc:creator>rlaxortn</dc:creator>
      <dc:date>2025-05-15T05:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: how is pwm frequency setting parameters?</title>
      <link>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2098091#M48842</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;it could be if channel is using counter bus in MCB up counting mode. But for channel in OPWMCB mode using counter bus in MCB up/down counting you should not get that. Unless different value is written to counter bus A register, you can check it within debugger.&lt;/P&gt;
&lt;P&gt;BR, Petr&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 May 2025 10:40:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/how-is-pwm-frequency-setting-parameters/m-p/2098091#M48842</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2025-05-15T10:40:51Z</dc:date>
    </item>
  </channel>
</rss>

