<?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: LPTMR0 as Pulse Counter in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/LPTMR0-as-Pulse-Counter/m-p/281809#M10458</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well I figure it out!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The correct value for MUX is 4 and the CMR register must have some value non-zero. So it counts till that value, and sets TCF flag when that value is reached. Also start over counting from zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe someone could find it usefull.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SebaS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Jun 2013 18:12:09 GMT</pubDate>
    <dc:creator>sebasira</dc:creator>
    <dc:date>2013-06-07T18:12:09Z</dc:date>
    <item>
      <title>LPTMR0 as Pulse Counter</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/LPTMR0-as-Pulse-Counter/m-p/281807#M10456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everybody!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm working with K60N512, I'm trying to develop an odometer. I guess the best way to accomplish that is with the pulse counter, to measure wheel pulses, and then get the speed and distance with a simple conversion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I can not make the counter to increment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is how I configure the LPTMR0:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;SIM_SCGC5 |= SIM_SCGC5_LPTIMER_MASK;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;EM&gt;// Enable LPT Module&lt;/EM&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;// Reset LPTMR module&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;LPTMR0_CSR = 0x00;&lt;/P&gt;&lt;P&gt;LPTMR0_PSR = 0x00;&lt;/P&gt;&lt;P&gt;LPTMR0_CMR = 0x00;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;// I choose PRESCALER = 1, because it says 0 is not supported on pusle counter mode&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;LPTMR0_PSR = LPTMR_PSR_PRESCALE(1) | LPTMR_PSR_PBYP_MASK;&amp;nbsp; // bypass glicth filter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;LPTMR0_CSR |= LPTMR_CSR_TPS(2);&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;EM&gt;// Input pin select&lt;/EM&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;LPTMR0_CSR &amp;amp;= ~LPTMR_CSR_TPP_MASK;&amp;nbsp; &lt;EM&gt;// Rising Edge&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;LPTMR0_CSR |= LPTMR_CSR_TMS_MASK;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;EM&gt;// Timer as Pulse Counter&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Turn on LPTMR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I've got a function generator (square wave) connected to PTC5 (LPTMR0_ALT2), but the counter valur remains zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I missing something?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;SebaS&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 15:58:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/LPTMR0-as-Pulse-Counter/m-p/281807#M10456</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2013-06-07T15:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: LPTMR0 as Pulse Counter</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/LPTMR0-as-Pulse-Counter/m-p/281808#M10457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've notice I've forgot to enable the PIN, but it is still not working&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SIM_SCGC5 |= SIM_SCGC5_PORTC_MASK; //Turn on PORTC clock&lt;/P&gt;&lt;P&gt;PORTC_PCR5=PORT_PCR_MUX(0x3); //Use ALT3 on PTC5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;About MUX value, the demo from IAR sets it to be 4... but on K60N512 Reference Manual I can see that it should be 3. What's the rigth value?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 16:29:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/LPTMR0-as-Pulse-Counter/m-p/281808#M10457</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2013-06-07T16:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: LPTMR0 as Pulse Counter</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/LPTMR0-as-Pulse-Counter/m-p/281809#M10458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well I figure it out!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The correct value for MUX is 4 and the CMR register must have some value non-zero. So it counts till that value, and sets TCF flag when that value is reached. Also start over counting from zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe someone could find it usefull.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SebaS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 18:12:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/LPTMR0-as-Pulse-Counter/m-p/281809#M10458</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2013-06-07T18:12:09Z</dc:date>
    </item>
  </channel>
</rss>

