<?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: FTM Counter setting in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Counter-setting/m-p/202881#M3012</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Mark. Sensible suggestion however that does not seem to work either. The condition for the while loop never becomes true so I guess it is still not writing the value to the counter.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Feb 2012 18:09:50 GMT</pubDate>
    <dc:creator>seprol</dc:creator>
    <dc:date>2012-02-06T18:09:50Z</dc:date>
    <item>
      <title>FTM Counter setting</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Counter-setting/m-p/202879#M3010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;Hi,&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using one of the K60 Flex Timer (FTM) modules to act as&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;a simple pulse counter of the external clock FTM_CLKIN1&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;input. I want it to roll over at 0xffff back to 0x0000. However&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;occasionally I wish to write a specific value to the CNT register&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and I dont seem to be able to make this work. The only setup&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for the FTM I do is:&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;FTM1-&amp;gt;SC = FTM_SC_CLKS(3) | FTM_SC_PS(0) |&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FTM_SC_TOIE_MASK;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This sets external clock, Divide 1 and enable overflow&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;interrupt.&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To write a value to the clock I use:&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;FTM1-&amp;gt;SC &amp;amp;= ~FTM_SC_CLKS_MASK; // Stop&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FTM1-&amp;gt;CNTIN = lo_word; // value to write&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FTM1-&amp;gt;CNT = lo_word; // Trigger write CNTIN to CNT&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FTM1-&amp;gt;CNTIN = 0; // Reset for roll over&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FTM1-&amp;gt;SC = FTM_SC_CLKS(3) | FTM_SC_PS(0) |&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FTM_SC_TOIE_MASK; // restart&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However all this does is clear the counter to 0 and not the&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;value I set. What am I doing wrong?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 18:36:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Counter-setting/m-p/202879#M3010</guid>
      <dc:creator>seprol</dc:creator>
      <dc:date>2012-02-03T18:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: FTM Counter setting</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Counter-setting/m-p/202880#M3011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suspect that your problem is to do with clock-domain timing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The technique looks to be essentially correct since it is possible to set the CNT value by writing the CNTIN register and transferring it to the CNT value with a 'dummy' write (also with the timer clock stopped ).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the timer module is being clocked from a different clock than the CPU it may be that the sequence&lt;/P&gt;&lt;P&gt;CNTIN = lo_word;&lt;/P&gt;&lt;P&gt;CNT = lo_word;&lt;/P&gt;&lt;P&gt;has not completed when the CPU sets CNTIN to 0 again. This would mean that the load trigger would start but the CNTIN has been changed again before it propogates to the latch cycle in the timer block.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try doing something like&lt;/P&gt;&lt;P&gt;CNTIN = lo_word;&lt;/P&gt;&lt;P&gt;do {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CNT = lo_word;&lt;/P&gt;&lt;P&gt;} while (CNT != low_word);&lt;/P&gt;&lt;P&gt;CNTIN = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Feb 2012 02:38:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Counter-setting/m-p/202880#M3011</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2012-02-04T02:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: FTM Counter setting</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Counter-setting/m-p/202881#M3012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Mark. Sensible suggestion however that does not seem to work either. The condition for the while loop never becomes true so I guess it is still not writing the value to the counter.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2012 18:09:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Counter-setting/m-p/202881#M3012</guid>
      <dc:creator>seprol</dc:creator>
      <dc:date>2012-02-06T18:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: FTM Counter setting</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Counter-setting/m-p/202882#M3013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK I think I have found the problem. It would appear that you cannot write a value greater than the MOD register. As I left this at 0 then that is what was being written. The answer is to write the value to MOD before the update and then reset it afterwards. The only problem with this is that it appears you cannot write a value of 0xffff !!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 23:55:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Counter-setting/m-p/202882#M3013</guid>
      <dc:creator>seprol</dc:creator>
      <dc:date>2012-02-10T23:55:14Z</dc:date>
    </item>
  </channel>
</rss>

