<?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: K64 reading RTC-&amp;gt;TPR register in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-reading-RTC-gt-TPR-register/m-p/1230515#M59606</link>
    <description>&lt;P&gt;The general solution for reading multiple bytes across different clock domains is:&lt;/P&gt;&lt;P&gt;uint16_t t1,t2;&lt;/P&gt;&lt;P&gt;do{&lt;/P&gt;&lt;P&gt;&amp;nbsp;t1 = RTC-&amp;gt;TPR&lt;/P&gt;&lt;P&gt;&amp;nbsp;t2 = RTC-&amp;gt;TPR&lt;/P&gt;&lt;P&gt;}while( t1 != t2 );&lt;BR /&gt;&lt;BR /&gt;t1 is now valid at this point.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Feb 2021 18:20:44 GMT</pubDate>
    <dc:creator>bobpaddock</dc:creator>
    <dc:date>2021-02-12T18:20:44Z</dc:date>
    <item>
      <title>K64 reading RTC-&gt;TPR register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-reading-RTC-gt-TPR-register/m-p/1230501#M59605</link>
      <description>&lt;P&gt;Using a K64FN1M0M12, we tried to log some events with a millisecond resolution. To do so, we use the TPR register from RTC peripheral.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;millisec = base-&amp;gt;TPR;
millisec = (millisec * 1000) / 32768;&lt;/LI-CODE&gt;&lt;P&gt;We have a problem with some consecutive reads: the value read from the register can have a lower value than the previous read. To highlight the problem, we implemented a single task which only reads the TPR register every millisecond and prints the value on a console. After about 30 minutes, we have 3 occurrences of the issue. Each read gives the TPR value incremented by 32 or 33. Here are 2 occurrences of the problem with the values of RTC-&amp;gt;TPR :&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;STRONG&gt;Millisecond&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;STRONG&gt;TPR read value&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;STRONG&gt;Is value correct?&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;STRONG&gt;TPR expected value&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;479&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;15711&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;YES&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;FONT color="#FF0000"&gt;476&lt;/FONT&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;FONT color="#FF0000"&gt;15616 (0x3D00)&lt;/FONT&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;FONT color="#FF0000"&gt;NO&lt;/FONT&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;FONT color="#FF0000"&gt;15755 (0x3D80)&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;481&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;15776&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;YES&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;STRONG&gt;Millisecond&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;STRONG&gt;TPR read value&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;STRONG&gt;Is value correct&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;STRONG&gt;TPR expected value&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;577&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;18911&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;YES&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;FONT color="#FF0000"&gt;562&lt;/FONT&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;FONT color="#FF0000"&gt;18432 (0x4800)&lt;/FONT&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;FONT color="#FF0000"&gt;NO&lt;/FONT&gt;&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;&lt;FONT color="#FF0000"&gt;18944 (0x4A00)&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;579&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;18976&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;YES&lt;/TD&gt;&lt;TD width="25%" height="24px" class="lia-align-center"&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can notice, there is a one bit difference between the read value and the expected value. Is there something we do wrong? Is this a known issue? Is there a way to prevent this from happening other than reading the register multiple times?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 17:52:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-reading-RTC-gt-TPR-register/m-p/1230501#M59605</guid>
      <dc:creator>nicolasguigo</dc:creator>
      <dc:date>2021-02-12T17:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: K64 reading RTC-&gt;TPR register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-reading-RTC-gt-TPR-register/m-p/1230515#M59606</link>
      <description>&lt;P&gt;The general solution for reading multiple bytes across different clock domains is:&lt;/P&gt;&lt;P&gt;uint16_t t1,t2;&lt;/P&gt;&lt;P&gt;do{&lt;/P&gt;&lt;P&gt;&amp;nbsp;t1 = RTC-&amp;gt;TPR&lt;/P&gt;&lt;P&gt;&amp;nbsp;t2 = RTC-&amp;gt;TPR&lt;/P&gt;&lt;P&gt;}while( t1 != t2 );&lt;BR /&gt;&lt;BR /&gt;t1 is now valid at this point.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 18:20:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-reading-RTC-gt-TPR-register/m-p/1230515#M59606</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2021-02-12T18:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: K64 reading RTC-&gt;TPR register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-reading-RTC-gt-TPR-register/m-p/1232006#M59649</link>
      <description>&lt;P&gt;Thank you for your reply. It solved the problem we had.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 10:29:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-reading-RTC-gt-TPR-register/m-p/1232006#M59649</guid>
      <dc:creator>nicolasguigo</dc:creator>
      <dc:date>2021-02-17T10:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: K64 reading RTC-&gt;TPR register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-reading-RTC-gt-TPR-register/m-p/1232118#M59650</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/139793"&gt;@nicolasguigo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've run in the same problem and rather than use the RTC, I ended up using a PIT requesting an interrupt every 1ms (actually every 100us in my application) which avoids the issue.&lt;/P&gt;&lt;P&gt;myke&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 15:08:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-reading-RTC-gt-TPR-register/m-p/1232118#M59650</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-02-17T15:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: K64 reading RTC-&gt;TPR register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-reading-RTC-gt-TPR-register/m-p/1232185#M59652</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.ganssle.com/tem/tem355.html#article6" target="_blank" rel="noopener"&gt;http://www.ganssle.com/tem/tem355.html#article6&lt;/A&gt;&amp;nbsp;explains the general problem with multiple byte reads involving interrupts.&amp;nbsp; Then throw in that RTC is in a different clock domain...&lt;BR /&gt;&lt;BR /&gt;It is important to note the distinction between simultaneous (the hardware ticking) and concurrent (the software reading the hardware with interrupts).&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 16:55:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-reading-RTC-gt-TPR-register/m-p/1232185#M59652</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2021-02-17T16:55:18Z</dc:date>
    </item>
  </channel>
</rss>

