<?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>S12 / MagniV MicrocontrollersのトピックRe: MM912J637 Lifetime Counter error</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MM912J637-Lifetime-Counter-error/m-p/604400#M13103</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Further info.&amp;nbsp; If I read back the TRIM_ALF register I am getting values of about 0x81EB. If I cool the chip a little I see it fall to 0x81E8 then slowly climb back again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So this looks reasonable and the PRDF bit is set suggesting sync is OK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So why the error in LTC timeout?&lt;/P&gt;&lt;P&gt;Have I calculated the reload value wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Feb 2017 01:30:19 GMT</pubDate>
    <dc:creator>ianwilson</dc:creator>
    <dc:date>2017-02-28T01:30:19Z</dc:date>
    <item>
      <title>MM912J637 Lifetime Counter error</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MM912J637-Lifetime-Counter-error/m-p/604399#M13102</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;We are using the MM912J637.&amp;nbsp; Have been for a few years now but I think we are uncovering an old issue now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am finding the lifetime counter is giving a wake-up about 5% too early. I want 5 seconds but am seeing about 4.75 seconds.&amp;nbsp; The error should be better than this as the system has been running and so the ALFCLK should have a recent sync against D2DSCLK. D2DSCLK should have an accuracy better than ~1%.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am thinking that the ALFCLK may not be synchronised against the D2DSCLK correctly.&amp;nbsp; The datasheet (V5.0 Jan 2015) is slightly confusing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It states "&lt;EM&gt;the low power oscillator (LPCLK) is synchronized to the more precise D2DCLK, via the D2DSCLK signal.&lt;/EM&gt;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But later it also states "The “Calibrated Low Power Clock” (ALFCLK) &lt;STRONG&gt;could&lt;/STRONG&gt; be trimmed to the D2DCLK accuracy plus a maximum error adder of 1 LPCLK period, by internally counting the number of periods of the LPCLK (512 kHz) during a D2DSCLK period.".&amp;nbsp; (My emphasis.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The "could" here implies to me that I may need to code something to make this happen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, further on again, the datasheet states that this adjustment is continuously performed during Normal mode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code to reload the LTC counter when it rolls over and generates an interrupt (or wakeup) is:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="property macro token"&gt;#define SLEEP_SECONDS (5)&lt;/SPAN&gt;
&lt;SPAN class="property macro token"&gt;#define ALFCLK_HZ (1000UL)&lt;/SPAN&gt;
&lt;SPAN class="property macro token"&gt;#define LTC_RELOAD (1UL + (0xFFFFFFFFUL - (ALFCLK_HZ * SLEEP_SECONDS)))&lt;/SPAN&gt;
&lt;SPAN class="property macro token"&gt;#define LTC_RELOAD_HI ((uint16_t)(LTC_RELOAD &amp;gt;&amp;gt; 16))&lt;/SPAN&gt;
&lt;SPAN class="property macro token"&gt;#define LTC_RELOAD_LO ((uint16_t)(LTC_RELOAD &amp;amp; 0xFFFF))&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;static&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;ltc_timer_reload&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LTC_CTL &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0x8100&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;// b 10000001 00000000 - disable LTC&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LTC_CNT1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; LTC_RELOAD_HI&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LTC_CNT0 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; LTC_RELOAD_LO&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LTC_CTL &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0x8181&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;// b 10000001 10000001 - enable LTC and its interrupt&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So the LTC counter should be loaded with 0xFFFFEC78 and should then count for 0x1388 x ALFCLK before rolling over; that is 5000 (decimal) ms.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My questions are:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Q1: Is the datasheet a little confusing here?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Q2: Any thoughts on why I would see a 5% error in the LTC timeout?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks for any assistance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2017 00:04:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MM912J637-Lifetime-Counter-error/m-p/604399#M13102</guid>
      <dc:creator>ianwilson</dc:creator>
      <dc:date>2017-02-28T00:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: MM912J637 Lifetime Counter error</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MM912J637-Lifetime-Counter-error/m-p/604400#M13103</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Further info.&amp;nbsp; If I read back the TRIM_ALF register I am getting values of about 0x81EB. If I cool the chip a little I see it fall to 0x81E8 then slowly climb back again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So this looks reasonable and the PRDF bit is set suggesting sync is OK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So why the error in LTC timeout?&lt;/P&gt;&lt;P&gt;Have I calculated the reload value wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2017 01:30:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MM912J637-Lifetime-Counter-error/m-p/604400#M13103</guid>
      <dc:creator>ianwilson</dc:creator>
      <dc:date>2017-02-28T01:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: MM912J637 Lifetime Counter error</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MM912J637-Lifetime-Counter-error/m-p/604401#M13104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for disturbing you - the problem is fixed now.&lt;/P&gt;&lt;P&gt;We had a PRESC value of 0x2A00 which gives a correct D2DFCLK but an incorrect D2DSCLK.&lt;/P&gt;&lt;P&gt;Changing PRESC to 0x2C00 gives correct frequencies for both.&lt;/P&gt;&lt;P&gt;R,&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Mar 2017 01:39:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MM912J637-Lifetime-Counter-error/m-p/604401#M13104</guid>
      <dc:creator>ianwilson</dc:creator>
      <dc:date>2017-03-01T01:39:01Z</dc:date>
    </item>
  </channel>
</rss>

