<?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 Update PWM period on runtime in Kinetis Design Studio</title>
    <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Update-PWM-period-on-runtime/m-p/556576#M7151</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd like to generate sine waves of different frequencies using PWM that means that I need to vary also the period of PWM to achieve that. &lt;/P&gt;&lt;P&gt;I've used a PWM_LDD component where I can set the period and a TimerUnit_LDD component for the hardware PWM but don't&amp;nbsp; provide any method to change the period.&lt;/P&gt;&lt;P&gt;what I'm doing wrong ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Jun 2016 09:33:57 GMT</pubDate>
    <dc:creator>nadiajarray</dc:creator>
    <dc:date>2016-06-22T09:33:57Z</dc:date>
    <item>
      <title>Update PWM period on runtime</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Update-PWM-period-on-runtime/m-p/556576#M7151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd like to generate sine waves of different frequencies using PWM that means that I need to vary also the period of PWM to achieve that. &lt;/P&gt;&lt;P&gt;I've used a PWM_LDD component where I can set the period and a TimerUnit_LDD component for the hardware PWM but don't&amp;nbsp; provide any method to change the period.&lt;/P&gt;&lt;P&gt;what I'm doing wrong ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2016 09:33:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/Update-PWM-period-on-runtime/m-p/556576#M7151</guid>
      <dc:creator>nadiajarray</dc:creator>
      <dc:date>2016-06-22T09:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Update PWM period on runtime</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Update-PWM-period-on-runtime/m-p/556577#M7152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nadia,&lt;/P&gt;&lt;P&gt;If you look at the PWM_LDD help, it states the following:&lt;/P&gt;&lt;P class="titlebox"&gt;&lt;/P&gt;&lt;DIV class="beanname"&gt;Component PWM_LDD &lt;P&gt;&lt;/P&gt;&lt;P class="descrtext"&gt;Pulse width modulation&lt;/P&gt;&lt;P class="info_name"&gt;Component Level: &lt;SPAN class="info_text"&gt;&lt;A href="http://127.0.0.1:55406/help/ntopic/com.freescale.doc.processorexpert.components/DOCs/BeanCategoriesInfo.html#LevelAbstraction"&gt;Logical Device Driver&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="info_name"&gt;Category: &lt;SPAN class="info_text"&gt;Logical Device Drivers-Timer&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P class="user_text"&gt;&lt;STRONG&gt;This component implements a pulse-width modulation generator that generates a signal with variable duty and fixed frequency (period).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The PWM_LDD Component has the frequency fixed.&lt;/P&gt;&lt;P&gt;But since it is "just software" you could play around with Events.c PWM1_OnEnd() ISR as shown below to allow changing frequency. The frequency range depends on the clock configuration so this is just an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void PWM1_OnEnd(LDD_TUserData *UserDataPtr)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;/* Write your code here ... */&lt;/P&gt;&lt;P&gt;#if 0 //DES 0=change frequency, 1=change duty&lt;/P&gt;&lt;P&gt;PWM1_SetRatio16(MyPWM1Ptr,++ratio); //change duty&lt;/P&gt;&lt;P&gt;#else&lt;/P&gt;&lt;P&gt;static unsigned increment=0;&lt;/P&gt;&lt;P&gt;increment++;&lt;/P&gt;&lt;P&gt;if(!(increment%10)) //DES slow down frequency change to enable watching on oscope&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;FTM_PDD_WriteModuloReg(FTM0_BASE_PTR, ++ratio);&lt;/P&gt;&lt;P&gt;FTM_PDD_WriteChannelValueReg(FTM0_BASE_PTR, 0, (uint16_t)ratio/2);&lt;/P&gt;&lt;P&gt;increment=0;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tested the above using KDS+PE for the TWR-K70.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2016 17:27:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/Update-PWM-period-on-runtime/m-p/556577#M7152</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2016-06-22T17:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Update PWM period on runtime</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Update-PWM-period-on-runtime/m-p/556578#M7153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you !&lt;/P&gt;&lt;P&gt;So to update the PWM period, I only need to update the modulo register with &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;FTM_PDD_WriteModuloReg and set the number of timer ticks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;I only don't get the difference between &lt;/SPAN&gt;FTM_PDD_WriteChannelValueReg and and SetRatio16 ..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jun 2016 08:24:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/Update-PWM-period-on-runtime/m-p/556578#M7153</guid>
      <dc:creator>nadiajarray</dc:creator>
      <dc:date>2016-06-23T08:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Update PWM period on runtime</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Update-PWM-period-on-runtime/m-p/556579#M7154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nadia,&lt;/P&gt;&lt;P&gt;Glad to help.&lt;/P&gt;&lt;P&gt;Again, the LDD is limited to only change duty cycle of a constant frequency (period).&amp;nbsp; When PWM1_SetRatio16() called, it reads what the period (aka FTM-&amp;gt;MOD register which is constant), uses the ratio value (0-65535&amp;nbsp; where 0=0% duty cycle, 32767=50% duty cycle, 65535=100% duty cycle) you passed in to calculate the new FTM-&amp;gt;FTMx_CnV register VAL to have PWM generate the correct duty cycle.&lt;/P&gt;&lt;P&gt;The code I provided is accessing the FTM/PWM registers directly and by changing the MOD and having VAL=1/2MOD the frequency is changing and the duty cycle is set to 50%.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jun 2016 20:36:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/Update-PWM-period-on-runtime/m-p/556579#M7154</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2016-06-23T20:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Update PWM period on runtime</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Update-PWM-period-on-runtime/m-p/556580#M7155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I undersand, the PWM value register can only be change du ring the ISR?&amp;nbsp; Insted of using the PWM_LDD component, I want to use the Init_FTM component to be able to combine pair of PWM channels. I didn't find the Processor Expert settings to generate the ISR yet. Do you have an example for the Init_FTM component?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bruno&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Aug 2016 16:56:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/Update-PWM-period-on-runtime/m-p/556580#M7155</guid>
      <dc:creator>brunotremblay</dc:creator>
      <dc:date>2016-08-12T16:56:37Z</dc:date>
    </item>
  </channel>
</rss>

