<?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 Pulse not counting properly using LPTMR in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Pulse-not-counting-properly-using-LPTMR/m-p/342868#M16618</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In using LPTMR to count the pulse.&lt;/P&gt;&lt;P&gt;here is the snip shot of the code &lt;/P&gt;&lt;P&gt;void lptmr_pulse_count(uint32 count_val, int pc_src, int psg_src)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Reset LPTMR module&lt;/P&gt;&lt;P&gt;&amp;nbsp; lptmr_clear_registers();&lt;/P&gt;&lt;P&gt;&amp;nbsp; // For interupt handler&lt;/P&gt;&lt;P&gt;&amp;nbsp; lptmr_mode = LPT_CNTR_MODE;&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Enable LPT Interrupt in NVIC&lt;/P&gt;&lt;P&gt;&amp;nbsp; enable_irq(LPTMR_IRQ_NUM); // LPTMR Vector is 101. IRQ# is 101-16=85&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Set up the interrupt vector for counter == compare val&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Set the compare value&lt;/P&gt;&lt;P&gt;&amp;nbsp; LPTMR0_CMR = count_val;&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Set up LPTMR to bypass prescaler clock&lt;/P&gt;&lt;P&gt;&amp;nbsp; LPTMR0_PSR = (LPTMR_PSR_PBYP_MASK | LPTMR_PSR_PCS(psg_src));&lt;/P&gt;&lt;P&gt;&amp;nbsp; // select pulse counter mode, pulse counter clk src, and interrupt enable.&lt;/P&gt;&lt;P&gt;&amp;nbsp; LPTMR0_CSR |= LPTMR_CSR_TMS_MASK | LPTMR_CSR_TPS(pc_src) | LPTMR_CSR_TIE_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; lptmr_intrpt = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; return;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;count_value = 0xFFFF&lt;/P&gt;&lt;P&gt;clock source is LPO.&lt;/P&gt;&lt;P&gt;in oscilloscope I counted the pulse it is 22 but in CNR register the value is 69.. please see the image for the pulse&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 15 Nov 2014 10:36:54 GMT</pubDate>
    <dc:creator>shabana</dc:creator>
    <dc:date>2014-11-15T10:36:54Z</dc:date>
    <item>
      <title>Pulse not counting properly using LPTMR</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Pulse-not-counting-properly-using-LPTMR/m-p/342868#M16618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In using LPTMR to count the pulse.&lt;/P&gt;&lt;P&gt;here is the snip shot of the code &lt;/P&gt;&lt;P&gt;void lptmr_pulse_count(uint32 count_val, int pc_src, int psg_src)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Reset LPTMR module&lt;/P&gt;&lt;P&gt;&amp;nbsp; lptmr_clear_registers();&lt;/P&gt;&lt;P&gt;&amp;nbsp; // For interupt handler&lt;/P&gt;&lt;P&gt;&amp;nbsp; lptmr_mode = LPT_CNTR_MODE;&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Enable LPT Interrupt in NVIC&lt;/P&gt;&lt;P&gt;&amp;nbsp; enable_irq(LPTMR_IRQ_NUM); // LPTMR Vector is 101. IRQ# is 101-16=85&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Set up the interrupt vector for counter == compare val&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Set the compare value&lt;/P&gt;&lt;P&gt;&amp;nbsp; LPTMR0_CMR = count_val;&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Set up LPTMR to bypass prescaler clock&lt;/P&gt;&lt;P&gt;&amp;nbsp; LPTMR0_PSR = (LPTMR_PSR_PBYP_MASK | LPTMR_PSR_PCS(psg_src));&lt;/P&gt;&lt;P&gt;&amp;nbsp; // select pulse counter mode, pulse counter clk src, and interrupt enable.&lt;/P&gt;&lt;P&gt;&amp;nbsp; LPTMR0_CSR |= LPTMR_CSR_TMS_MASK | LPTMR_CSR_TPS(pc_src) | LPTMR_CSR_TIE_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; lptmr_intrpt = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; return;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;count_value = 0xFFFF&lt;/P&gt;&lt;P&gt;clock source is LPO.&lt;/P&gt;&lt;P&gt;in oscilloscope I counted the pulse it is 22 but in CNR register the value is 69.. please see the image for the pulse&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Nov 2014 10:36:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Pulse-not-counting-properly-using-LPTMR/m-p/342868#M16618</guid>
      <dc:creator>shabana</dc:creator>
      <dc:date>2014-11-15T10:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Pulse not counting properly using LPTMR</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Pulse-not-counting-properly-using-LPTMR/m-p/342869#M16619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shabana m,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do you mean the glitch filter clock is LPO?&lt;BR /&gt;However you disabled (or bypassed) the glitch filer.&lt;BR /&gt;I think the error came from the input signal glitch.&lt;BR /&gt;Therefore you should better set the glitch filter as the following&lt;BR /&gt;because your input signal is 2.27MHz and LPO is 1kHz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[before]&lt;BR /&gt;LPTMR0_PSR = (LPTMR_PSR_PBYP_MASK | LPTMR_PSR_PCS(psg_src));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[after]&lt;BR /&gt;LPTMR0_PSR = (LPTMR_PSR_PRESCALE(0x6) | LPTMR_PSR_PCS(psg_src));&lt;BR /&gt;// PBYP=0 PCS=psg_src=0b01(?) PRESCALE=0b0110=128cycles(220cycles would be best but not available)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This means that the input low level should keep longer than 128ms and the high level should keep longer than 128ms.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this will help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;BR /&gt;Yasuhiko Koumoto.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Nov 2014 20:07:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Pulse-not-counting-properly-using-LPTMR/m-p/342869#M16619</guid>
      <dc:creator>yasuhikokoumoto</dc:creator>
      <dc:date>2014-11-15T20:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: Pulse not counting properly using LPTMR</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Pulse-not-counting-properly-using-LPTMR/m-p/342870#M16620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Yasuhiko koumoto,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank u sooooo much...Its working... :smileyhappy:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Shabana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Nov 2014 06:17:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Pulse-not-counting-properly-using-LPTMR/m-p/342870#M16620</guid>
      <dc:creator>shabana</dc:creator>
      <dc:date>2014-11-17T06:17:59Z</dc:date>
    </item>
  </channel>
</rss>

