<?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 Free-running Timer on KL25 in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Free-running-Timer-on-KL25/m-p/224904#M4302</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm requiring the services of a high-speed timer and as I see it on the KL25 I have the following options:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;TPM&lt;/LI&gt;&lt;LI&gt;LPTMR&lt;/LI&gt;&lt;LI&gt;PIR&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm concerned that later on in my project, the 4MHz max clock of the LPTMR will be too slow for my needs, likewise, I feel as though I'm somehow misappropriating the PIR if I use it as a simple free-running timer. It's my hope to use the TPM, all I require is for it to free run and for my software to sample the current timer value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I currently have the following code, however the timer doesn't appear to begin counting:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13677039661068306" jivemacro_uid="_13677039661068306"&gt;
&lt;P&gt;SIM-&amp;gt;SOPT2 &amp;amp;= ~(1UL &amp;lt;&amp;lt; 16); // Use FLL clock&lt;/P&gt;
&lt;P&gt;SIM-&amp;gt;SOPT2 |= (1UL &amp;lt;&amp;lt; 24);&amp;nbsp; // Timer will run off FLL clock&lt;/P&gt;
&lt;P&gt;SIM-&amp;gt;SCGC6 |= (1UL &amp;lt;&amp;lt; 24);&amp;nbsp; // Activate clock to Timer 0&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;TPM0-&amp;gt;CNT&amp;nbsp;&amp;nbsp; = 0;&lt;/P&gt;
&lt;P&gt;TPM0-&amp;gt;SC&amp;nbsp;&amp;nbsp;&amp;nbsp; = (1UL &amp;lt;&amp;lt; 3);&amp;nbsp; // Enable the counter to increment on each counter clock&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm now expecting CNT to increment, however this doesn't appear to be the case. Do I need to do something to trigger the timer? Will this allow it to function as a true free-running counter?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 04 May 2013 21:44:25 GMT</pubDate>
    <dc:creator>gmscribe</dc:creator>
    <dc:date>2013-05-04T21:44:25Z</dc:date>
    <item>
      <title>Free-running Timer on KL25</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Free-running-Timer-on-KL25/m-p/224904#M4302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm requiring the services of a high-speed timer and as I see it on the KL25 I have the following options:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;TPM&lt;/LI&gt;&lt;LI&gt;LPTMR&lt;/LI&gt;&lt;LI&gt;PIR&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm concerned that later on in my project, the 4MHz max clock of the LPTMR will be too slow for my needs, likewise, I feel as though I'm somehow misappropriating the PIR if I use it as a simple free-running timer. It's my hope to use the TPM, all I require is for it to free run and for my software to sample the current timer value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I currently have the following code, however the timer doesn't appear to begin counting:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13677039661068306" jivemacro_uid="_13677039661068306"&gt;
&lt;P&gt;SIM-&amp;gt;SOPT2 &amp;amp;= ~(1UL &amp;lt;&amp;lt; 16); // Use FLL clock&lt;/P&gt;
&lt;P&gt;SIM-&amp;gt;SOPT2 |= (1UL &amp;lt;&amp;lt; 24);&amp;nbsp; // Timer will run off FLL clock&lt;/P&gt;
&lt;P&gt;SIM-&amp;gt;SCGC6 |= (1UL &amp;lt;&amp;lt; 24);&amp;nbsp; // Activate clock to Timer 0&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;TPM0-&amp;gt;CNT&amp;nbsp;&amp;nbsp; = 0;&lt;/P&gt;
&lt;P&gt;TPM0-&amp;gt;SC&amp;nbsp;&amp;nbsp;&amp;nbsp; = (1UL &amp;lt;&amp;lt; 3);&amp;nbsp; // Enable the counter to increment on each counter clock&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm now expecting CNT to increment, however this doesn't appear to be the case. Do I need to do something to trigger the timer? Will this allow it to function as a true free-running counter?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 May 2013 21:44:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Free-running-Timer-on-KL25/m-p/224904#M4302</guid>
      <dc:creator>gmscribe</dc:creator>
      <dc:date>2013-05-04T21:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Free-running Timer on KL25</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Free-running-Timer-on-KL25/m-p/224905#M4303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Gmscribe&lt;/P&gt;&lt;P&gt;It seems that your TPM initial code is not complete. For example, you did not set register TPM0_MOD value. You can download sample code from our website. The link is &lt;A href="http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KL2&amp;amp;nodeId=01624698C9E3EC&amp;amp;fpsp=1&amp;amp;tab=Design_Tools_Tab"&gt;http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KL2&amp;amp;nodeId=01624698C9E3EC&amp;amp;fpsp=1&amp;amp;tab=Design_Tools_Tab&lt;/A&gt;. Sample code name is KL25_SC. In this file, there are many sample project for modules in KL25. After you install it, you can find TPM module sample code from folder: ...\Kinetis L Sample Code\kl25_sc_rev6\klxx-sc-baremetal\src\projects\LQRUG_tpm_ex2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope my reply can help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 May 2013 01:15:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Free-running-Timer-on-KL25/m-p/224905#M4303</guid>
      <dc:creator>Paul_Tian</dc:creator>
      <dc:date>2013-05-06T01:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Free-running Timer on KL25</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Free-running-Timer-on-KL25/m-p/224906#M4304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Paul,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not setting TPM0_MOD because it defaults to the maximum value of 0xFFFF, which is what I want for a free-running timer. Never-the-less I have tried setting this with no change. I have also tried out some configurations of the various channels, however this does not promote the timer to count. I have set the debug flag to ensure the timer does not freeze during debug and attempted to adjust it manually from my peripheral view (using Keil for the record) however this does not help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm at a complete loss, were it the clock source, I would hard fault when attempting to access the module so it can't be this...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 May 2013 09:30:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Free-running-Timer-on-KL25/m-p/224906#M4304</guid>
      <dc:creator>gmscribe</dc:creator>
      <dc:date>2013-05-06T09:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Free-running Timer on KL25</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Free-running-Timer-on-KL25/m-p/224907#M4305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Gmscribe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would you please help to reference the code I mentioned in my last reply? You can also find this code as attached. You can use a variable to get value when you need or add a breakpoint. I tested to use a variable to read TPM0_CNT and value is changed not zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope my reply can help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 May 2013 03:20:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Free-running-Timer-on-KL25/m-p/224907#M4305</guid>
      <dc:creator>Paul_Tian</dc:creator>
      <dc:date>2013-05-07T03:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: Free-running Timer on KL25</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Free-running-Timer-on-KL25/m-p/224908#M4306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello gmscribe:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know this is *years* after the fact, but maybe this will help someone else.&amp;nbsp; If I understand your question, you don't need to&amp;nbsp;generate any interrupts, you just want a free-running counter that you can read.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you looked at the PIT module?&amp;nbsp; It's a (fast) free running counter tied to the bus clock.&amp;nbsp; You can gang two counters together to get a 64 bit counter with sub-microsecond resolution.&amp;nbsp; You can find coding examples in the&amp;nbsp;KL25 Sub-Family Reference Manual.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- rdp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 Sep 2017 09:46:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Free-running-Timer-on-KL25/m-p/224908#M4306</guid>
      <dc:creator>robertpoor</dc:creator>
      <dc:date>2017-09-30T09:46:37Z</dc:date>
    </item>
  </channel>
</rss>

