<?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: K22: LPTMR TCF overhead of 2 ms with LPO? in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-LPTMR-TCF-overhead-of-2-ms-with-LPO/m-p/791428#M48159</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;According to my understanding: When 1kHz LPO is used, LPTMR0-&amp;gt;CMR=0x09 will lead 10ms timeout.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="40.4.4 LPTMR compare.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/77997iACD45F622E4A9D98/image-size/large?v=v2&amp;amp;px=999" role="button" title="40.4.4 LPTMR compare.png" alt="40.4.4 LPTMR compare.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Additionally: When the LPTMR is enabled, the first increment will take an additional one or two prescaler clock cycles due to synchronization logic.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="40.4.3.2 Prescaler bypassed.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/77830iA0E7FE06CC98A5BA/image-size/large?v=v2&amp;amp;px=999" role="button" title="40.4.3.2 Prescaler bypassed.png" alt="40.4.3.2 Prescaler bypassed.png" /&gt;&lt;/span&gt;&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;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Nov 2018 06:23:23 GMT</pubDate>
    <dc:creator>Robin_Shen</dc:creator>
    <dc:date>2018-11-26T06:23:23Z</dc:date>
    <item>
      <title>K22: LPTMR TCF overhead of 2 ms with LPO?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-LPTMR-TCF-overhead-of-2-ms-with-LPO/m-p/791426#M48157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Device is MK22FN256VLL12, the LPTMR is currently using the LPO (1 kHz) with prescaler bypassed, running in time counter mode. What I am experiencing is about 2 ms overhead regardless of CMR value, e.g. until TCF is set. I check the LPO on PTE0 using the following setup:&lt;BR /&gt;SIM-&amp;gt;SOPT1 |= SIM_SOPT1_OSC32KSEL(3) | SIM_SOPT1_OSC32KOUT(1);&lt;BR /&gt;The waveform looks as follows:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="SCR05.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/77985i709AC354C30F271B/image-size/large?v=v2&amp;amp;px=999" role="button" title="SCR05.PNG" alt="SCR05.PNG" /&gt;&lt;/span&gt;&lt;BR /&gt;So about 1% slower, which is well within acceptable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the following, the clock output on PTE0 is disabled, it just works as a normal GPIO, configured as output&lt;BR /&gt;My LPTMR setups is as follows:&lt;BR /&gt;&lt;BR /&gt;void LPTMR_init(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;SIM-&amp;gt;SCGC5 |= SIM_SCGC5_LPTMR_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;LPTMR0-&amp;gt;CSR = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;LPTMR0-&amp;gt;PSR = LPTMR_PSR_PCS(1) | LPTMR_PSR_PBYP_MASK;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The LPTMR delay function looks like this:&lt;BR /&gt;&lt;BR /&gt;void LPTMR_delay(uint16_t uValue)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;LPTMR0-&amp;gt;CMR = LPTMR_CMR_COMPARE(uValue);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;LPTMR0-&amp;gt;CSR |= LPTMR_CSR_TEN_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; while(!(LPTMR0-&amp;gt;CSR &amp;amp; LPTMR_CSR_TCF_MASK));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; LPTMR0-&amp;gt;CSR &amp;amp;= ~LPTMR_CSR_TEN_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;GPIOE-&amp;gt;PTOR = GPIO_PIN(0);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function calling the LPTMR_delay is as follows:&lt;BR /&gt;do&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;LPTMR_delay(10);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;while(1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is just called from main. The ONLY other ISR running at 20 ms intervals is the SysTick ISR, which just increases a counter and nothing else. The results when monitoring PTE0 using a scope, is as follows:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="SCR07.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/78248i95E0C8FF469D12FF/image-size/large?v=v2&amp;amp;px=999" role="button" title="SCR07.PNG" alt="SCR07.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So what ought to be 10 ms toggle intervals is now approximately 12 ms intervals.&lt;BR /&gt;&lt;BR /&gt;Any suggestions why I have an overhead of 2 ms and what I've misunderstood about the LPTMR?&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2018 10:23:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-LPTMR-TCF-overhead-of-2-ms-with-LPO/m-p/791426#M48157</guid>
      <dc:creator>troelsoesteraa</dc:creator>
      <dc:date>2018-11-22T10:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: K22: LPTMR TCF overhead of 2 ms with LPO?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-LPTMR-TCF-overhead-of-2-ms-with-LPO/m-p/791427#M48158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In addition to this I tested with the 4 MHz fast IRC as clock for the LPTMR, downscaled to 1 MHz by the MCG, doing the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Disable fast IRC (4 MHz) when FRDRIV is changed&lt;BR /&gt;MCG-&amp;gt;C2 &amp;amp;= ~MCG_C2_IRCS_MASK;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;// Divide by 4 to bring clock speed to 1 MHz.&lt;BR /&gt;// Make sure to clear any previous setting (reset default is 2!).&lt;BR /&gt;MCG-&amp;gt;SC &amp;amp;= ~MCG_SC_FCRDIV_MASK;&lt;BR /&gt;MCG-&amp;gt;SC |= MCG_SC_FCRDIV(2);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Enable fast IRC again.&lt;BR /&gt;MCG-&amp;gt;C2 |= MCG_C2_IRCS_MASK;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;// Enable active IRC as MCGIRCLK for use with LPTMR.&lt;BR /&gt;MCG-&amp;gt;C1 |= MCG_C1_IRCLKEN_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I configured PSR as follows:&lt;BR /&gt;LPTMR0-&amp;gt;PSR = LPTMR_PSR_PCS(0) | LPTMR_PSR_PBYP_MASK;&lt;BR /&gt;&lt;BR /&gt;Otherwise, the code is unchanged. The overhead with this configuration is about 2 us, not 2 ms, so quite acceptable!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2018 14:59:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-LPTMR-TCF-overhead-of-2-ms-with-LPO/m-p/791427#M48158</guid>
      <dc:creator>troelsoesteraa</dc:creator>
      <dc:date>2018-11-22T14:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: K22: LPTMR TCF overhead of 2 ms with LPO?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-LPTMR-TCF-overhead-of-2-ms-with-LPO/m-p/791428#M48159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;According to my understanding: When 1kHz LPO is used, LPTMR0-&amp;gt;CMR=0x09 will lead 10ms timeout.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="40.4.4 LPTMR compare.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/77997iACD45F622E4A9D98/image-size/large?v=v2&amp;amp;px=999" role="button" title="40.4.4 LPTMR compare.png" alt="40.4.4 LPTMR compare.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Additionally: When the LPTMR is enabled, the first increment will take an additional one or two prescaler clock cycles due to synchronization logic.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="40.4.3.2 Prescaler bypassed.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/77830iA0E7FE06CC98A5BA/image-size/large?v=v2&amp;amp;px=999" role="button" title="40.4.3.2 Prescaler bypassed.png" alt="40.4.3.2 Prescaler bypassed.png" /&gt;&lt;/span&gt;&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;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Nov 2018 06:23:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-LPTMR-TCF-overhead-of-2-ms-with-LPO/m-p/791428#M48159</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2018-11-26T06:23:23Z</dc:date>
    </item>
  </channel>
</rss>

