<?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 Divide by 2 PWM using FTM in Kinetis K60 in Kinetis Software Development Kit</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Divide-by-2-PWM-using-FTM-in-Kinetis-K60/m-p/940831#M7953</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;In MK60DN256VLL10, I'm trying to generate 25MHz PWM with 50% duty cycle (using 50MHz external clock) in Edge aligned mode.&amp;nbsp;System clock and Core clock = 100MHz and Bus Clock = 50MHz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to the reference manual, FTM period in edge aligned mode = (MOD - CNTIN + 0x1) and duty cycle = (CnV - CNTIN). So, to generate 25MHz, MOD must be 1, CNTIN must be 0 and CnV must be 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I set these manually, I do see 25MHz PWM being generated on the scope.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the SDK/MCUXpresso cannot seem to set CnV correctly for this condition. I think issue seems to be in the code below in fsl_ftm.c (exists in more than 1 place).&lt;/P&gt;&lt;P&gt;........................&lt;BR /&gt; mod = base-&amp;gt;MOD;&lt;BR /&gt; if ((currentPwmMode == kFTM_EdgeAlignedPwm) || (currentPwmMode == kFTM_CenterAlignedPwm))&lt;BR /&gt; {&lt;BR /&gt; cnv = (mod * dutyCyclePercent) / 100;&lt;BR /&gt; /* For 100% duty cycle */&lt;BR /&gt; if (cnv &amp;gt;= mod)&lt;BR /&gt; {&lt;BR /&gt; cnv = mod + 1;&lt;BR /&gt; }&lt;BR /&gt; base-&amp;gt;CONTROLS[chnlNumber].CnV = cnv;&lt;BR /&gt; }&lt;BR /&gt;........................&lt;/P&gt;&lt;P&gt;In our case, mod = 1 and dutyCyclePercent = 50. So, cnv remains 0. We want cnv to be 1, I think.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know if I'm configuring FTM improperly. If you can generate 25MHz PWM using external 50MHz clock via MCUXpresso, please let me know the FTM configuration . I tried various settings via the Peripheral tool of MCUXpresso&amp;nbsp;but was unsuccessful. For now, I have hacked the fsl_ftm.c code and got it to work. If it is a bug in SDK, please plan to fix it in the next revision as soon as possible.&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;Satish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 04 Jul 2019 04:24:29 GMT</pubDate>
    <dc:creator>acharya_satishb</dc:creator>
    <dc:date>2019-07-04T04:24:29Z</dc:date>
    <item>
      <title>Divide by 2 PWM using FTM in Kinetis K60</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Divide-by-2-PWM-using-FTM-in-Kinetis-K60/m-p/940831#M7953</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;In MK60DN256VLL10, I'm trying to generate 25MHz PWM with 50% duty cycle (using 50MHz external clock) in Edge aligned mode.&amp;nbsp;System clock and Core clock = 100MHz and Bus Clock = 50MHz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to the reference manual, FTM period in edge aligned mode = (MOD - CNTIN + 0x1) and duty cycle = (CnV - CNTIN). So, to generate 25MHz, MOD must be 1, CNTIN must be 0 and CnV must be 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I set these manually, I do see 25MHz PWM being generated on the scope.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the SDK/MCUXpresso cannot seem to set CnV correctly for this condition. I think issue seems to be in the code below in fsl_ftm.c (exists in more than 1 place).&lt;/P&gt;&lt;P&gt;........................&lt;BR /&gt; mod = base-&amp;gt;MOD;&lt;BR /&gt; if ((currentPwmMode == kFTM_EdgeAlignedPwm) || (currentPwmMode == kFTM_CenterAlignedPwm))&lt;BR /&gt; {&lt;BR /&gt; cnv = (mod * dutyCyclePercent) / 100;&lt;BR /&gt; /* For 100% duty cycle */&lt;BR /&gt; if (cnv &amp;gt;= mod)&lt;BR /&gt; {&lt;BR /&gt; cnv = mod + 1;&lt;BR /&gt; }&lt;BR /&gt; base-&amp;gt;CONTROLS[chnlNumber].CnV = cnv;&lt;BR /&gt; }&lt;BR /&gt;........................&lt;/P&gt;&lt;P&gt;In our case, mod = 1 and dutyCyclePercent = 50. So, cnv remains 0. We want cnv to be 1, I think.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know if I'm configuring FTM improperly. If you can generate 25MHz PWM using external 50MHz clock via MCUXpresso, please let me know the FTM configuration . I tried various settings via the Peripheral tool of MCUXpresso&amp;nbsp;but was unsuccessful. For now, I have hacked the fsl_ftm.c code and got it to work. If it is a bug in SDK, please plan to fix it in the next revision as soon as possible.&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;Satish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Jul 2019 04:24:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Divide-by-2-PWM-using-FTM-in-Kinetis-K60/m-p/940831#M7953</guid>
      <dc:creator>acharya_satishb</dc:creator>
      <dc:date>2019-07-04T04:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Divide by 2 PWM using FTM in Kinetis K60</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Divide-by-2-PWM-using-FTM-in-Kinetis-K60/m-p/940832#M7954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the report, I'll inform the SDK team about this.&lt;BR /&gt;Sorry for the inconvenience we bring you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Robin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jul 2019 08:14:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Divide-by-2-PWM-using-FTM-in-Kinetis-K60/m-p/940832#M7954</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2019-07-05T08:14:16Z</dc:date>
    </item>
  </channel>
</rss>

