<?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 PWM dither disables deadtime in MCX Microcontrollers</title>
    <link>https://community.nxp.com/t5/MCX-Microcontrollers/PWM-dither-disables-deadtime/m-p/2074539#M2846</link>
    <description>&lt;P&gt;Hello!&lt;BR /&gt;&lt;BR /&gt;I'm using the PWM on my FRDM-MCXN947 to create two complimentary 500kHz waveforms.&lt;BR /&gt;They're using submodule 1 (PWM1), have an input clock of 150MHz, and a deadtime of 6 ticks (40ns). Everything looks good so far!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcallon_0-1743809062129.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/331464iAC2943DFCDF509A1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcallon_0-1743809062129.png" alt="jcallon_0-1743809062129.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I also want to implement duty cycle dithering.&lt;BR /&gt;But, I've noticed when I turn on the registers to enable dithering, my deadtime reduces to 0.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcallon_1-1743809232799.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/331466i18CE38579707A021/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcallon_1-1743809232799.png" alt="jcallon_1-1743809232799.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;There are no functions to enable dithering, so I access the register directly:&lt;BR /&gt;&lt;A href="https://www.nxp.com/docs/en/application-note/AN14196.pdf" target="_blank"&gt;https://www.nxp.com/docs/en/application-note/AN14196.pdf&lt;/A&gt;&lt;BR /&gt;PWM1-&amp;gt;SM[0].FRCTRL |= PWM_FRCTRL_FRAC1_EN(1);&lt;BR /&gt;PWM1-&amp;gt;SM[0].FRCTRL |= PWM_FRCTRL_FRAC23_EN(1);&lt;BR /&gt;PWM1-&amp;gt;SM[0].FRCTRL |= PWM_FRCTRL_FRAC45_EN(1);&lt;BR /&gt;&lt;BR /&gt;Specifically, enabling FRAC1 and FRAC45 does not reduce the deadtime, but FRAC23 does.&lt;BR /&gt;&lt;BR /&gt;I'd like to be able to have both deadtime and dithering.&lt;BR /&gt;Can you tell me why this happens, and if this works on this or other submodules, boards, etc.?&lt;BR /&gt;&lt;BR /&gt;Thank you for your time,&lt;BR /&gt;JC&lt;/P&gt;</description>
    <pubDate>Fri, 04 Apr 2025 23:35:44 GMT</pubDate>
    <dc:creator>jcallon</dc:creator>
    <dc:date>2025-04-04T23:35:44Z</dc:date>
    <item>
      <title>PWM dither disables deadtime</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/PWM-dither-disables-deadtime/m-p/2074539#M2846</link>
      <description>&lt;P&gt;Hello!&lt;BR /&gt;&lt;BR /&gt;I'm using the PWM on my FRDM-MCXN947 to create two complimentary 500kHz waveforms.&lt;BR /&gt;They're using submodule 1 (PWM1), have an input clock of 150MHz, and a deadtime of 6 ticks (40ns). Everything looks good so far!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcallon_0-1743809062129.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/331464iAC2943DFCDF509A1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcallon_0-1743809062129.png" alt="jcallon_0-1743809062129.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I also want to implement duty cycle dithering.&lt;BR /&gt;But, I've noticed when I turn on the registers to enable dithering, my deadtime reduces to 0.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcallon_1-1743809232799.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/331466i18CE38579707A021/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcallon_1-1743809232799.png" alt="jcallon_1-1743809232799.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;There are no functions to enable dithering, so I access the register directly:&lt;BR /&gt;&lt;A href="https://www.nxp.com/docs/en/application-note/AN14196.pdf" target="_blank"&gt;https://www.nxp.com/docs/en/application-note/AN14196.pdf&lt;/A&gt;&lt;BR /&gt;PWM1-&amp;gt;SM[0].FRCTRL |= PWM_FRCTRL_FRAC1_EN(1);&lt;BR /&gt;PWM1-&amp;gt;SM[0].FRCTRL |= PWM_FRCTRL_FRAC23_EN(1);&lt;BR /&gt;PWM1-&amp;gt;SM[0].FRCTRL |= PWM_FRCTRL_FRAC45_EN(1);&lt;BR /&gt;&lt;BR /&gt;Specifically, enabling FRAC1 and FRAC45 does not reduce the deadtime, but FRAC23 does.&lt;BR /&gt;&lt;BR /&gt;I'd like to be able to have both deadtime and dithering.&lt;BR /&gt;Can you tell me why this happens, and if this works on this or other submodules, boards, etc.?&lt;BR /&gt;&lt;BR /&gt;Thank you for your time,&lt;BR /&gt;JC&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 23:35:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/PWM-dither-disables-deadtime/m-p/2074539#M2846</guid>
      <dc:creator>jcallon</dc:creator>
      <dc:date>2025-04-04T23:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: PWM dither disables deadtime</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/PWM-dither-disables-deadtime/m-p/2076400#M2856</link>
      <description>&lt;P&gt;If anyone else is running into this issue, I've worked around it for now by:&lt;BR /&gt;- Make 2 duplicate independent waveforms, instead of complimentary&lt;BR /&gt;- Make the one channel HIGH on active and the other LOW on active&lt;BR /&gt;- Simulate a deadtime by making the duty cycle of one channel (deadtime ticks * 2) longer (I'm not sure if this is enough to work for edge-aligned waveforms, I use center-aligned)&lt;BR /&gt;- After enabling FRCTRL somewhere, set FRACVAL3 (dither for channel A) and FRACVAL5 (dither for channel B) in PWM_UpdatePwmDutycycleHighAccuracy&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// During the integer division to calculate pwmHighPulse,
// any remainder was simply discarded and cut off during rounding down.
// lost_precision is the remainder that was cut off.
const double lost_precision = ((pulseCnt * dutyCycle) - (pwmHighPulse * 65535U)) / pulseCnt;

// Section 3.2.6 Fractional delay logic
// FRACVAL3 is, every pulseCnt pulses, how many pulses we want on for an extra clock tick
// NOTE: Yes, this also loses precision, but less than if we did nothing.
//       We can only dither the nearest 1/pulseCnt precision, unless we use adjust
//       FRACVAL3 every pulseCnt strategically.
// lost_precision / (((1 / pulseCnt) / pulseCnt)(65535)) =
// lost_precision * pulseCnt * pulseCnt / 65525
base-&amp;gt;SM[subModule].FRACVAL3 = PWM_FRACVAL3_FRACVAL3((pulseCnt * pulseCnt * lost_precision) / 65535U);
base-&amp;gt;SM[subModule].FRACVAL5 = PWM_FRACVAL5_FRACVAL5((pulseCnt * pulseCnt * lost_precision) / 65535U);&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Thought I'd share, although not using a workaround would be ideal, thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2025 17:37:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/PWM-dither-disables-deadtime/m-p/2076400#M2856</guid>
      <dc:creator>jcallon</dc:creator>
      <dc:date>2025-04-08T17:37:51Z</dc:date>
    </item>
  </channel>
</rss>

