<?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: fast PWM clock source with imx8mp in MCX Microcontrollers</title>
    <link>https://community.nxp.com/t5/MCX-Microcontrollers/fast-PWM-clock-source-with-imx8mp/m-p/1917097#M1347</link>
    <description>&lt;P&gt;attached&amp;nbsp;is the output, where yellow is the expected PWM output, and the purple is toggled every time the interrupt is triggered (it does not happen again after the 2 toggles that are shown in the picture, and the PWM continues indefinitely without any changes)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="WhatsApp Image 2024-07-25 at 13.38.07.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/290311i2B348B95FEDBF4E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="WhatsApp Image 2024-07-25 at 13.38.07.jpeg" alt="WhatsApp Image 2024-07-25 at 13.38.07.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jul 2024 10:46:31 GMT</pubDate>
    <dc:creator>OrenP</dc:creator>
    <dc:date>2024-07-25T10:46:31Z</dc:date>
    <item>
      <title>fast PWM clock source with imx8mp</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/fast-PWM-clock-source-with-imx8mp/m-p/1913287#M1260</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to use the imx8mp's cortex M to create a PWM output for working with the&amp;nbsp;ws2812b LEDs.&lt;/P&gt;&lt;P&gt;The LEDs require a faster clock source than the default, and after checking the clock source possibilities I've found that setting:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;pwmConfig.clockSource = kPWM_HighFrequencyClock;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;works for the required rates.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I encountered an issue with this clock source that the interrupt no longer triggers when the reload triggers (this is taken from the driver_examples/pwm project).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To be more precise, the interrupt triggers twice at the beginning, then never again, and at the two times that it does, it's not at the expected points where the counter period is complete.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;to reproduce this, just take the example and set&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;pwmConfig.clockSource = kPWM_HighFrequencyClock;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;right after getting the default configuration in the main function.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jul 2024 12:58:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/fast-PWM-clock-source-with-imx8mp/m-p/1913287#M1260</guid>
      <dc:creator>OrenP</dc:creator>
      <dc:date>2024-07-21T12:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: fast PWM clock source with imx8mp</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/fast-PWM-clock-source-with-imx8mp/m-p/1914535#M1280</link>
      <description>&lt;P&gt;Hi &lt;BR /&gt;The interrupt process is not suitable for the &lt;SPAN&gt;HighFrequencyClock&lt;/SPAN&gt; scenario, you can try&amp;nbsp;kPWM_PeripheralClock using&amp;nbsp;24MHz as clock source.&lt;BR /&gt;&lt;BR /&gt;Best Regards&lt;BR /&gt;Zhiming&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2024 02:17:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/fast-PWM-clock-source-with-imx8mp/m-p/1914535#M1280</guid>
      <dc:creator>Zhiming_Liu</dc:creator>
      <dc:date>2024-07-23T02:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: fast PWM clock source with imx8mp</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/fast-PWM-clock-source-with-imx8mp/m-p/1917091#M1346</link>
      <description>&lt;P&gt;The attempt results in the exact same scenario.&amp;nbsp;&lt;BR /&gt;Is there another modification I need to do in order to make this work? or is it just not possible?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 10:37:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/fast-PWM-clock-source-with-imx8mp/m-p/1917091#M1346</guid>
      <dc:creator>OrenP</dc:creator>
      <dc:date>2024-07-25T10:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: fast PWM clock source with imx8mp</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/fast-PWM-clock-source-with-imx8mp/m-p/1917097#M1347</link>
      <description>&lt;P&gt;attached&amp;nbsp;is the output, where yellow is the expected PWM output, and the purple is toggled every time the interrupt is triggered (it does not happen again after the 2 toggles that are shown in the picture, and the PWM continues indefinitely without any changes)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="WhatsApp Image 2024-07-25 at 13.38.07.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/290311i2B348B95FEDBF4E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="WhatsApp Image 2024-07-25 at 13.38.07.jpeg" alt="WhatsApp Image 2024-07-25 at 13.38.07.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 10:46:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/fast-PWM-clock-source-with-imx8mp/m-p/1917097#M1347</guid>
      <dc:creator>OrenP</dc:creator>
      <dc:date>2024-07-25T10:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: fast PWM clock source with imx8mp</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/fast-PWM-clock-source-with-imx8mp/m-p/1917698#M1365</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;
&lt;P&gt;Here are snippets which has been tested by internal team on M4. You can use it as a reference.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Init and configure PWM4.&lt;BR /&gt;
&lt;PRE&gt;PWM_GetDefaultConfig(&amp;amp;pwmConfig);&lt;BR /&gt;pwmConfig.clockSource = kPWM_PeripheralClock; // Using 24MHz as clock source&lt;BR /&gt;&lt;BR /&gt;/* Initialize PWM module */&lt;BR /&gt;PWM_Init(DEMO_PWM_BASEADDR, &amp;amp;pwmConfig);&lt;BR /&gt;&lt;BR /&gt;/* Enable FIFO empty interrupt */&lt;BR /&gt;PWM_EnableInterrupts(DEMO_PWM_BASEADDR, kPWM_FIFOEmptyInterruptEnable);&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Init filling samples
&lt;PRE&gt;PWM_SetSampleValue(DEMO_PWM_BASEADDR, LED_0_SAMPLE); // LED_0_SAMPLE = 9&lt;BR /&gt;PWM_SetSampleValue(DEMO_PWM_BASEADDR, LED_1_SAMPLE); // LED_1_SAMPLE = 18&lt;BR /&gt;PWM_SetSampleValue(DEMO_PWM_BASEADDR, LED_0_SAMPLE);&lt;BR /&gt;pwm_pr_cnt += 3;&lt;BR /&gt;/* Write the period to the PWM Period Register */&lt;BR /&gt;PWM_SetPeriodValue(DEMO_PWM_BASEADDR, PWM_PERIOD_VALUE); // PWM_PERIOD_VALUE = 28&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Filling samples in irq&lt;BR /&gt;
&lt;PRE&gt;/* Gets interrupt kPWM_FIFOEmptyFlag */&lt;BR /&gt;if (PWM_GetStatusFlags(DEMO_PWM_BASEADDR) &amp;amp; kPWM_FIFOEmptyFlag)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (pwm_pr_cnt &amp;gt; PWM_PERIOD + RESET_PERIOD) // PWM_PERIOD = 12 *24, RESET_PERIOD = 64&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pwm_pr_cnt = 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PWM_SetSampleValue(DEMO_PWM_BASEADDR, LED_0_SAMPLE);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if (pwm_pr_cnt &amp;gt; PWM_PERIOD)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Reset period */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PWM_SetSampleValue(DEMO_PWM_BASEADDR, 0);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* PWM period */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t sample_val = (pwm_pr_cnt &amp;amp; 1) ? LED_1_SAMPLE : LED_0_SAMPLE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PWM_SetSampleValue(DEMO_PWM_BASEADDR, sample_val);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pwm_pr_cnt++;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Clear kPWM_FIFOEmptyFlag */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PWM_clearStatusFlags(DEMO_PWM_BASEADDR, kPWM_FIFOEmptyFlag);&lt;BR /&gt;}&lt;BR /&gt;/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping&lt;BR /&gt;exception return operation might vector to incorrect interrupt */&lt;BR /&gt;#if defined __CORTEX_M &amp;amp;&amp;amp; (__CORTEX_M == 4U)&lt;BR /&gt;__DSB();&lt;BR /&gt;#endif&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Best Regards&lt;BR /&gt;Zhiming&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 02:38:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/fast-PWM-clock-source-with-imx8mp/m-p/1917698#M1365</guid>
      <dc:creator>Zhiming_Liu</dc:creator>
      <dc:date>2024-07-26T02:38:26Z</dc:date>
    </item>
  </channel>
</rss>

