<?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: Dynamically change pwm frequency on FTM in MCUXpresso SDK</title>
    <link>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1557956#M4015</link>
    <description>&lt;P&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/176743"&gt;@Marc852&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Could you please check if you are entering this condition?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RaulRomero_0-1669139740756.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/201292i6E1F83C5D34421FF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RaulRomero_0-1669139740756.png" alt="RaulRomero_0-1669139740756.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;[Driver fsl_ftm.c -&amp;gt; function FTM_SetupPWM()]&lt;/P&gt;
&lt;P&gt;Due the range of frequency you are wanting to work, the function will not work it out. This is because the number of ticks the counter needs will overflow the mod register every time. FTM_SetupPWM() then, will only work with a lower range.&lt;/P&gt;
&lt;P&gt;As you can read in the comment, the best solution for your range would be: Changing clock source to get the desired frequency. As you were doing in the first place.&lt;/P&gt;
&lt;P&gt;Regards, Raul&lt;/P&gt;</description>
    <pubDate>Tue, 22 Nov 2022 18:08:56 GMT</pubDate>
    <dc:creator>RaRo</dc:creator>
    <dc:date>2022-11-22T18:08:56Z</dc:date>
    <item>
      <title>Dynamically change pwm frequency on FTM</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1547722#M3974</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use an FTM function to generate PWM output. I based my code on the SDK example "driver_examples =&amp;gt; simple_PWM".&lt;/P&gt;&lt;P&gt;Actually to change PWM frequency I use "&lt;SPAN&gt;FTM_Deinit&lt;/SPAN&gt;", then "&lt;SPAN&gt;FTM_CalculateCounterClkDiv&lt;/SPAN&gt;" to modify frequency and "&lt;SPAN&gt;FTM_Init&lt;/SPAN&gt;&lt;SPAN&gt;". But it's a really slow solution and it's not working properly if I modify my frequency many time too fast.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Is there a way to change dynamically the frequency (like duty cycle on the example) ? Have you got any example ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help.&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;---------------------------&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;MCUXpresso 11.5.0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;K22FN256M1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;SDK_2_11_0_MK22FN256xxx12&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;---------------------------&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 11:31:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1547722#M3974</guid>
      <dc:creator>Marc852</dc:creator>
      <dc:date>2022-11-02T11:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically change pwm frequency on FTM</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1555035#M3996</link>
      <description>&lt;P class="lia-align-justify"&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/176743"&gt;@Marc852&lt;/a&gt;,&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;In the example you have function: FTM_SetupPwm(). This function has a parameter named pwmFreq_Hz, that is for PWM signal frequency in Hz.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RaulRomero_2-1668614342907.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/200647i5E33342E9C301E50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RaulRomero_2-1668614342907.png" alt="RaulRomero_2-1668614342907.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;[Function FTM_SetupPwm in main]&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RaulRomero_1-1668614250634.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/200646i91300E6DA75AA552/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RaulRomero_1-1668614250634.png" alt="RaulRomero_1-1668614250634.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;[Declaration of function in fsl_ftm.c]&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;You could experiment with that function and modify the frequency of the PWM, without the use of FTM_DeInit() and FTM_CalculateCounterClkDiv.&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;Regards, Raul.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 15:59:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1555035#M3996</guid>
      <dc:creator>RaRo</dc:creator>
      <dc:date>2022-11-16T15:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically change pwm frequency on FTM</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1555881#M4004</link>
      <description>&lt;P&gt;Hello Raul,&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;I had already seen this function but it did not work dynamically.&lt;/P&gt;&lt;P&gt;I tried again with FRDM-K22 demo board. I started PWM with 1 KHz and I modified it to 10 KHz with "&lt;SPAN&gt;FTM_SetupPwm()"&lt;/SPAN&gt;. Nothing happened on output, I kept a 1KHz frequency.&lt;/P&gt;&lt;P&gt;Did I made a mistake ?&lt;/P&gt;&lt;P&gt;I attach my test source files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cordially,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Marc&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 15:19:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1555881#M4004</guid>
      <dc:creator>Marc852</dc:creator>
      <dc:date>2022-11-17T15:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically change pwm frequency on FTM</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1557956#M4015</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/176743"&gt;@Marc852&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Could you please check if you are entering this condition?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RaulRomero_0-1669139740756.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/201292i6E1F83C5D34421FF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RaulRomero_0-1669139740756.png" alt="RaulRomero_0-1669139740756.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;[Driver fsl_ftm.c -&amp;gt; function FTM_SetupPWM()]&lt;/P&gt;
&lt;P&gt;Due the range of frequency you are wanting to work, the function will not work it out. This is because the number of ticks the counter needs will overflow the mod register every time. FTM_SetupPWM() then, will only work with a lower range.&lt;/P&gt;
&lt;P&gt;As you can read in the comment, the best solution for your range would be: Changing clock source to get the desired frequency. As you were doing in the first place.&lt;/P&gt;
&lt;P&gt;Regards, Raul&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 18:08:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1557956#M4015</guid>
      <dc:creator>RaRo</dc:creator>
      <dc:date>2022-11-22T18:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically change pwm frequency on FTM</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1558357#M4019</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/206649"&gt;@RaRo&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;That doesn’t seem to be the problem, the function return "kStatus_Success" each time.&lt;/P&gt;&lt;P&gt;I still tried to change frequency in lower range 1KHz =&amp;gt; 1.1KHz but same result, the frequency keep 1KHz output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: In comparaison to your screen the mod test return "kStatus_OutOfRange" instead of "kStatus_Fail".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cordially,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Marc&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 08:46:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1558357#M4019</guid>
      <dc:creator>Marc852</dc:creator>
      <dc:date>2022-11-23T08:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically change pwm frequency on FTM</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1566075#M4051</link>
      <description>&lt;P class="lia-align-justify"&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/176743"&gt;@Marc852&lt;/a&gt;,&lt;/P&gt;
&lt;UL class="lia-align-justify" type="disc"&gt;
&lt;LI&gt;Just to double check, could you please check the configuration of the port for the FTM0_CH3 in pin_mux.c file of your project? Here is the configuration from the driver example "ftm_simple_pwm" using CH6:&lt;/LI&gt;
&lt;/UL&gt;
&lt;P class="lia-align-justify"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RaulRomero_0-1670433187047.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/203397iBC2C795153415E97/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RaulRomero_0-1670433187047.png" alt="RaulRomero_0-1670433187047.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL class="lia-align-justify" type="disc"&gt;
&lt;LI&gt;In order to change frequencies, you may need the following line FTM_SetSoftwareTrigger(BOARD_FTM_BASEADDR, true); without it as you point out the frequency will not change. Could you please try to add the line every time you want to change the frequency after FTM_SetupPwm? Here is a sample of how the testing was made.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P class="lia-align-justify"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RaulRomero_1-1670433187052.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/203398iD25AA56382E29708/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RaulRomero_1-1670433187052.png" alt="RaulRomero_1-1670433187052.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;Best regards, Raul.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 17:16:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1566075#M4051</guid>
      <dc:creator>RaRo</dc:creator>
      <dc:date>2022-12-07T17:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically change pwm frequency on FTM</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1566941#M4054</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/206649"&gt;@RaRo&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;This works perfectly by adding the function &lt;STRONG&gt;FTM_SetSoftwareTrigger(BOARD_FTM_BASEADDR, true) &lt;/STRONG&gt;!&lt;/P&gt;&lt;P&gt;Looks like I missed it..&amp;nbsp;&lt;LI-EMOJI id="lia_smirking-face" title=":smirking_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your time and help.&lt;/P&gt;&lt;P&gt;Cordialy,&lt;/P&gt;&lt;P&gt;Marc&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 15:30:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Dynamically-change-pwm-frequency-on-FTM/m-p/1566941#M4054</guid>
      <dc:creator>Marc852</dc:creator>
      <dc:date>2022-12-08T15:30:27Z</dc:date>
    </item>
  </channel>
</rss>

