<?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 k60 rtc with external battery backup reinit in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/k60-rtc-with-external-battery-backup-reinit/m-p/747465#M17738</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am struggling with the RTC on a custom board that uses the k60.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have the 3 volt battery connected to the VBAT pin (pin 42). A 32.8 KHz crystal connected across XTAL32 &amp;amp; EXTAL32.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that the hardware is fine, this design has been in place for a few years. We have recently upgraded to MQX 4.2 using the KDS IDE without processor expert.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am struggling with the bsp settings for the RTC. The RTC is re-initializing every time upon bootup. I would assume there is a way to have it check to see if the RTC is already running. which under the _RTC_INIT() function, it appears to do....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int32_t _rtc_init&lt;BR /&gt;(&lt;BR /&gt; /* [IN] param identifying init operations */&lt;BR /&gt; void* param&lt;BR /&gt;)&lt;BR /&gt;{ /* Body */&lt;BR /&gt; int32_t result = MQX_OK;&lt;BR /&gt; RTC_MemMapPtr rtc = RTC_BASE_PTR;&lt;/P&gt;&lt;P&gt;_int_disable();&lt;BR /&gt; /* Check if the time is invalid */&lt;BR /&gt; if (rtc-&amp;gt;SR &amp;amp; RTC_SR_TIF_MASK)&lt;BR /&gt; {&lt;BR /&gt; rtc-&amp;gt;SR &amp;amp;= ~RTC_SR_TCE_MASK; /* disable rtc timer - enable write access */&lt;BR /&gt; rtc-&amp;gt;TAR = 0xFFFFFFFF; /* e2574: RTC: Writing RTC_TAR[TAR] = 0 does not disable RTC alarm */&lt;/P&gt;&lt;P&gt;/* if TIF reading TSR return zero and we must set TSR to one */&lt;BR /&gt; rtc-&amp;gt;TSR = 1; /* this clear SR flags TIF, TOF */&lt;BR /&gt; rtc-&amp;gt;SR |= RTC_SR_TCE_MASK;&lt;BR /&gt; /* Update alarm time &amp;amp; alarm period */&lt;/P&gt;&lt;P&gt;alarm_time = 0;&lt;BR /&gt; alarm_period = 0;&lt;BR /&gt; } /* End if*/&lt;BR /&gt; _int_enable();&lt;/P&gt;&lt;P&gt;/* Check if RTC counter or OSC for RTC is not started */&lt;BR /&gt; if( !(rtc-&amp;gt;SR &amp;amp; RTC_SR_TCE_MASK) || !(rtc-&amp;gt;CR &amp;amp; RTC_CR_OSCE_MASK) )&lt;BR /&gt; {&lt;BR /&gt; rtc-&amp;gt;CR |= RTC_CR_OSCE_MASK;&lt;BR /&gt; /* recommended 125 ms delay for oscillator start */&lt;BR /&gt; _time_delay(125);&lt;BR /&gt; rtc-&amp;gt;SR |= RTC_SR_TCE_MASK;&lt;BR /&gt; } /* End if */&lt;/P&gt;&lt;P&gt;return result;&lt;BR /&gt;} /* Endbody */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From my understanding the RTC should continue to run off of the battery power when the main power is shut off. The only setting that is 100% clear is to set&amp;nbsp;&lt;SPAN&gt;BSPCFG_ENABLE_RTCDEV&amp;nbsp;to 1.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does anyone have an idea on where i should direct my attention to?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for you time,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;J&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Nov 2017 17:18:53 GMT</pubDate>
    <dc:creator>jasonscott</dc:creator>
    <dc:date>2017-11-29T17:18:53Z</dc:date>
    <item>
      <title>k60 rtc with external battery backup reinit</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/k60-rtc-with-external-battery-backup-reinit/m-p/747465#M17738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am struggling with the RTC on a custom board that uses the k60.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have the 3 volt battery connected to the VBAT pin (pin 42). A 32.8 KHz crystal connected across XTAL32 &amp;amp; EXTAL32.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that the hardware is fine, this design has been in place for a few years. We have recently upgraded to MQX 4.2 using the KDS IDE without processor expert.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am struggling with the bsp settings for the RTC. The RTC is re-initializing every time upon bootup. I would assume there is a way to have it check to see if the RTC is already running. which under the _RTC_INIT() function, it appears to do....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int32_t _rtc_init&lt;BR /&gt;(&lt;BR /&gt; /* [IN] param identifying init operations */&lt;BR /&gt; void* param&lt;BR /&gt;)&lt;BR /&gt;{ /* Body */&lt;BR /&gt; int32_t result = MQX_OK;&lt;BR /&gt; RTC_MemMapPtr rtc = RTC_BASE_PTR;&lt;/P&gt;&lt;P&gt;_int_disable();&lt;BR /&gt; /* Check if the time is invalid */&lt;BR /&gt; if (rtc-&amp;gt;SR &amp;amp; RTC_SR_TIF_MASK)&lt;BR /&gt; {&lt;BR /&gt; rtc-&amp;gt;SR &amp;amp;= ~RTC_SR_TCE_MASK; /* disable rtc timer - enable write access */&lt;BR /&gt; rtc-&amp;gt;TAR = 0xFFFFFFFF; /* e2574: RTC: Writing RTC_TAR[TAR] = 0 does not disable RTC alarm */&lt;/P&gt;&lt;P&gt;/* if TIF reading TSR return zero and we must set TSR to one */&lt;BR /&gt; rtc-&amp;gt;TSR = 1; /* this clear SR flags TIF, TOF */&lt;BR /&gt; rtc-&amp;gt;SR |= RTC_SR_TCE_MASK;&lt;BR /&gt; /* Update alarm time &amp;amp; alarm period */&lt;/P&gt;&lt;P&gt;alarm_time = 0;&lt;BR /&gt; alarm_period = 0;&lt;BR /&gt; } /* End if*/&lt;BR /&gt; _int_enable();&lt;/P&gt;&lt;P&gt;/* Check if RTC counter or OSC for RTC is not started */&lt;BR /&gt; if( !(rtc-&amp;gt;SR &amp;amp; RTC_SR_TCE_MASK) || !(rtc-&amp;gt;CR &amp;amp; RTC_CR_OSCE_MASK) )&lt;BR /&gt; {&lt;BR /&gt; rtc-&amp;gt;CR |= RTC_CR_OSCE_MASK;&lt;BR /&gt; /* recommended 125 ms delay for oscillator start */&lt;BR /&gt; _time_delay(125);&lt;BR /&gt; rtc-&amp;gt;SR |= RTC_SR_TCE_MASK;&lt;BR /&gt; } /* End if */&lt;/P&gt;&lt;P&gt;return result;&lt;BR /&gt;} /* Endbody */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From my understanding the RTC should continue to run off of the battery power when the main power is shut off. The only setting that is 100% clear is to set&amp;nbsp;&lt;SPAN&gt;BSPCFG_ENABLE_RTCDEV&amp;nbsp;to 1.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does anyone have an idea on where i should direct my attention to?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for you time,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;J&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Nov 2017 17:18:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/k60-rtc-with-external-battery-backup-reinit/m-p/747465#M17738</guid>
      <dc:creator>jasonscott</dc:creator>
      <dc:date>2017-11-29T17:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: k60 rtc with external battery backup reinit</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/k60-rtc-with-external-battery-backup-reinit/m-p/747466#M17739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Correction.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in my post above, i stated that i was entering this if statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;/* Check if RTC counter or OSC for RTC is not started */&lt;/SPAN&gt;&lt;BR style="color: #51626f; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;if( !(rtc-&amp;gt;SR &amp;amp; RTC_SR_TCE_MASK) || !(rtc-&amp;gt;CR &amp;amp; RTC_CR_OSCE_MASK) )&lt;/SPAN&gt;&lt;BR style="color: #51626f; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;{&lt;/SPAN&gt;&lt;BR style="color: #51626f; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;rtc-&amp;gt;CR |= RTC_CR_OSCE_MASK;&lt;/SPAN&gt;&lt;BR style="color: #51626f; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;/* recommended 125 ms delay for oscillator start */&lt;/SPAN&gt;&lt;BR style="color: #51626f; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;_time_delay(125);&lt;/SPAN&gt;&lt;BR style="color: #51626f; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;rtc-&amp;gt;SR |= RTC_SR_TCE_MASK;&lt;/SPAN&gt;&lt;BR style="color: #51626f; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;} /* End if */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;That is not the case.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;So if the RTC counter has already been started prior to this point (which it should be with the battery backup).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Why is the RTC counter still resetting itself to the 1970 default??&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Nov 2017 19:41:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/k60-rtc-with-external-battery-backup-reinit/m-p/747466#M17739</guid>
      <dc:creator>jasonscott</dc:creator>
      <dc:date>2017-11-30T19:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: k60 rtc with external battery backup reinit</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/k60-rtc-with-external-battery-backup-reinit/m-p/747467#M17740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;More information...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The previous version of mqx was 4.01 and we are now using mqx 4.2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The RTC initialization under 4.01 appears to be structured differently and syncs the mqx time with the rtc time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone confirm that there are differences in operation using the RTC on version 4.01 and 4.2?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Under the release notes for version 4.02, the rtc driver states that it will be renewed during bsp startup.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So does that mean we can no longer use the external battery power option?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/52372i76B44B81D6AACE4F/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As always, thanks for your time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-J&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Dec 2017 17:39:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/k60-rtc-with-external-battery-backup-reinit/m-p/747467#M17740</guid>
      <dc:creator>jasonscott</dc:creator>
      <dc:date>2017-12-01T17:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: k60 rtc with external battery backup reinit</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/k60-rtc-with-external-battery-backup-reinit/m-p/747468#M17741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Too bad i wasn't able to get any insight from anyone on this forum....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For whomever is reading/has a similar situation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Interesting find...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Under MQX 4.02, when the rtc driver is initialized, the rtc time is synced with the mqx time.&lt;/P&gt;&lt;P&gt;I was able to do something similar under 4.2, by calling the following lines of code from the user application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;uint32_t rtc_seconds;&lt;BR /&gt; DATE_STRUCT mqx_date;&lt;BR /&gt; TIME_STRUCT mqx_time;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;_rtc_get_time(&amp;amp;rtc_seconds);&lt;BR /&gt; mqx_time.SECONDS = rtc_seconds;&lt;BR /&gt; _time_set(&amp;amp;mqx_time);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The clock now is not resetting to 1970, but is off 7~ minutes when i preform a power cycle. (only on the first power cycle)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BUT, from what i can tell the rtc is running off VBAT when the system is powered down. which resolved my initial issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Dec 2017 19:38:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/k60-rtc-with-external-battery-backup-reinit/m-p/747468#M17741</guid>
      <dc:creator>jasonscott</dc:creator>
      <dc:date>2017-12-01T19:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: k60 rtc with external battery backup reinit</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/k60-rtc-with-external-battery-backup-reinit/m-p/747469#M17742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think that for MQX related questions you will find help in the MQX Software Solutions forum rather than the Kinetis (processor) forum: &lt;A href="https://community.nxp.com/community/mqx"&gt;https://community.nxp.com/community/mqx&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From what I understand NXP no longer supports MQX but it seems there are MQX people at that forum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Dec 2017 20:01:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/k60-rtc-with-external-battery-backup-reinit/m-p/747469#M17742</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2017-12-01T20:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: k60 rtc with external battery backup reinit</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/k60-rtc-with-external-battery-backup-reinit/m-p/747470#M17743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your input.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wasn't aware I was posting in the wrong location.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll give that a look.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Jason&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Dec 2017 20:43:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/k60-rtc-with-external-battery-backup-reinit/m-p/747470#M17743</guid>
      <dc:creator>jasonscott</dc:creator>
      <dc:date>2017-12-01T20:43:12Z</dc:date>
    </item>
  </channel>
</rss>

