<?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: tPM PWM Fluctuation&amp; Resolution (FRMD-K66F) in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/tPM-PWM-Fluctuation-Resolution-FRMD-K66F/m-p/882833#M52358</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;Hello,&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;Yes you can change it but you'll need to change some settings in the TPM driver,&amp;nbsp; go to the definition of the function TPM_UpdatePwmDutycycle, then you'll see the operation where the duty cycle is set cnv = (mod * dutyCyclePercent) / 100, change the 100 to a 1000, that way you'll have more resolution, for example you can achieve your 50.5%.&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;Also, make sure that you use an 16 bit int for the updatedDutycycle and for the pass parameter of the TPM_UpdatePwmDutycycle, since you'll use values from 1 to 999 (0.1% to 99.9%)&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;Hope this helps,&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;Regards,&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;Aldo.&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt; Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Apr 2019 15:56:16 GMT</pubDate>
    <dc:creator>AldoG</dc:creator>
    <dc:date>2019-04-11T15:56:16Z</dc:date>
    <item>
      <title>tPM PWM Fluctuation&amp; Resolution (FRMD-K66F)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/tPM-PWM-Fluctuation-Resolution-FRMD-K66F/m-p/882830#M52355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to send a PWM signal to a motor controller for torque control.&lt;/P&gt;&lt;P&gt;I have a couple of questions regarding tPM_PWM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly, the PWM signal is fluctuating within 0.5% around the target duty cycle when received at the motor controller.&lt;/P&gt;&lt;P&gt;My colleague has tried with Arduino to the motor controller and the duty cycle did not fluctuate.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I modified an example code(tpm_simple_pwm) to make it run with FreeRTOS.&lt;/P&gt;&lt;P&gt;But it still has the same structure for PWM.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The scheme is that when the SW button is pressed, it starts sending PWM to the motor controller.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (Motor_Switch==1)&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;/* Disable channel output before updating the dutycycle */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TPM_UpdateChnlEdgeLevelSelect(TPM_BASEADDR, (tpm_chnl_t)TPM_CHANNEL, 0U);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;/* Update PWM duty cycle */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TPM_UpdatePwmDutycycle(TPM_BASEADDR, (tpm_chnl_t)TPM_CHANNEL, kTPM_CenterAlignedPwm,&lt;BR /&gt;updatedDutycycle);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;/* Start channel output with updated dutycycle */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TPM_UpdateChnlEdgeLevelSelect(TPM_BASEADDR, (tpm_chnl_t)TPM_CHANNEL, TPM_LED_ON_LEVEL);&lt;BR /&gt;}&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; /* Disable channel output before updating the dutycycle */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;TPM_UpdateChnlEdgeLevelSelect(TPM_BASEADDR, (tpm_chnl_t)TPM_CHANNEL, 0U);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PWM frequency of the motor controller is 5kHz and TPM_SetupPwm was set to 24kHz.&lt;/P&gt;&lt;P&gt;I tried to match those two values (TPM PWM was set to 5kHz).&lt;/P&gt;&lt;P&gt;(TPM_SetupPwm(TPM_BASEADDR, &amp;amp;tpmParam, 1U, &lt;SPAN&gt;kTPM_CenterAlignedPwm&lt;/SPAN&gt;, 5000U, TPM_SOURCE_CLOCK);)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Secondly, according to the example code, I can only send duty cycle from 0% to 99% with 1% increment.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had a look at the underlying codes as well but I could not figure out how I can increase the resolution of the dutycycle.&lt;/P&gt;&lt;P&gt;Is there anywhere that I can change to increase the resolution of duty cycle?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your advice will be very much appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Apr 2019 12:13:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/tPM-PWM-Fluctuation-Resolution-FRMD-K66F/m-p/882830#M52355</guid>
      <dc:creator>songja</dc:creator>
      <dc:date>2019-04-05T12:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: tPM PWM Fluctuation&amp; Resolution (FRMD-K66F)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/tPM-PWM-Fluctuation-Resolution-FRMD-K66F/m-p/882831#M52356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 11.0pt; margin: 0in;"&gt;Hello,&lt;/P&gt;&lt;P style="font-size: 11.0pt; margin: 0in;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="font-size: 11.0pt; margin: 0in;"&gt;You can indeed change the PWM frequency using the function you mentioned:&lt;/P&gt;&lt;P style="font-size: 11.0pt; margin: 0in;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="font-size: 11.0pt; margin: 0in;"&gt;TPM_SetupPwm(TPM_BASEADDR, &amp;amp;tpmParam, 1U,&amp;nbsp;kTPM_CenterAlignedPwm, &lt;SPAN style="font-weight: bold;"&gt;24000U&lt;/SPAN&gt;, TPM_SOURCE_CLOCK)&lt;/P&gt;&lt;P style="font-size: 11.0pt; margin: 0in;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="font-size: 11.0pt; margin: 0in;"&gt;You'll just need to change the 24000 to another value, for example in your case would be 5000.&lt;/P&gt;&lt;P style="font-size: 11.0pt; margin: 0in;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="font-size: 11.0pt; margin: 0in;"&gt;Hope this helps,&lt;/P&gt;&lt;P style="font-size: 11.0pt; margin: 0in;"&gt;Regards,&lt;BR /&gt; Aldo.&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt; Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Apr 2019 21:05:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/tPM-PWM-Fluctuation-Resolution-FRMD-K66F/m-p/882831#M52356</guid>
      <dc:creator>AldoG</dc:creator>
      <dc:date>2019-04-10T21:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: tPM PWM Fluctuation&amp; Resolution (FRMD-K66F)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/tPM-PWM-Fluctuation-Resolution-FRMD-K66F/m-p/882832#M52357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I already changed it already to 5000U and the PWM signal at the receiving end still fluctuated +- 0.2%.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, do you know how I can change the resolution of PWM?&lt;/P&gt;&lt;P&gt;The example only seemed to work with every 1% of dutycycle. For example, it could not send 50.5% dutycycle.&lt;/P&gt;&lt;P&gt;I have looked into the underlying code but still had no clue to change the resolution for PWM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Jaeyong Song&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Apr 2019 07:19:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/tPM-PWM-Fluctuation-Resolution-FRMD-K66F/m-p/882832#M52357</guid>
      <dc:creator>songja</dc:creator>
      <dc:date>2019-04-11T07:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: tPM PWM Fluctuation&amp; Resolution (FRMD-K66F)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/tPM-PWM-Fluctuation-Resolution-FRMD-K66F/m-p/882833#M52358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;Hello,&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;Yes you can change it but you'll need to change some settings in the TPM driver,&amp;nbsp; go to the definition of the function TPM_UpdatePwmDutycycle, then you'll see the operation where the duty cycle is set cnv = (mod * dutyCyclePercent) / 100, change the 100 to a 1000, that way you'll have more resolution, for example you can achieve your 50.5%.&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;Also, make sure that you use an 16 bit int for the updatedDutycycle and for the pass parameter of the TPM_UpdatePwmDutycycle, since you'll use values from 1 to 999 (0.1% to 99.9%)&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;Hope this helps,&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;Regards,&lt;/P&gt;&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;Aldo.&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt; Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Apr 2019 15:56:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/tPM-PWM-Fluctuation-Resolution-FRMD-K66F/m-p/882833#M52358</guid>
      <dc:creator>AldoG</dc:creator>
      <dc:date>2019-04-11T15:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: tPM PWM Fluctuation&amp; Resolution (FRMD-K66F)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/tPM-PWM-Fluctuation-Resolution-FRMD-K66F/m-p/882834#M52359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It worked after changing the value from 100 to 1000 and also the pass parameter to uint16_t both in c and header files.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;J&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Apr 2019 13:40:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/tPM-PWM-Fluctuation-Resolution-FRMD-K66F/m-p/882834#M52359</guid>
      <dc:creator>songja</dc:creator>
      <dc:date>2019-04-12T13:40:49Z</dc:date>
    </item>
  </channel>
</rss>

