<?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: RTC time lost after power failure on LPC4357 in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-time-lost-after-power-failure-on-LPC4357/m-p/567357#M17508</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by amey_pandit on Sun Nov 02 08:57:23 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Hangdog&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By the phrase "remove the power totally" means I am not removing the RTC battery I am just removing the power supply to the board. So the RTC is powered from the battery all the time. I know this looks like a silly question but it has become a show stopper.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Before this I have worked on LPC1768 RTC and it has worked well for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Mike&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will test your steps soon and will update.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers (Mine also is a pint ;) )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Amey&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 18:54:39 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T18:54:39Z</dc:date>
    <item>
      <title>RTC time lost after power failure on LPC4357</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-time-lost-after-power-failure-on-LPC4357/m-p/567354#M17505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by amey_pandit on Fri Oct 31 02:05:18 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Guys&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am, using a LPC4357 module on a EA base board (EA = Embedded Artist). Along with the NXP library (lpc43xx_rtc.c &amp;amp; lpc43xx_rtc.h) in a Keil IDE and compiler.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am able to initialize the RTC with a predefined time and also the clock ticks so time on the RTC increments. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have also connected a external 3.3V battery to the VBAT pin. Voltage of this battery at the terminal is 3.02V.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But when I power down the board (i.e. remove the power totally) and start again, the RTC time resets to zero (0). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But a normal reset (i.e. by pressing the reset button without removing power) doesn't cause any problem to the RTC time (i.e time is not lost) and clocks ticks correctly after reset.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Following is the code I am using. i took this code from a topic on this forum itself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Also the original code from NXP has same issue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/** CCR register mask */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#define RTC_CCR_BITMASK((0x00000013))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/** Clock enable */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#define RTC_CCR_CLKEN((1&amp;lt;&amp;lt;0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/** Clock reset */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#define RTC_CCR_CTCRST((0&amp;lt;&amp;lt;1)) // I made it zero as i thought i might be resetting the clock.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/** Calibration counter enable */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#define RTC_CCR_CCALEN((1&amp;lt;&amp;lt;4))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;void RTC_Init (LPC_RTC_Type* RTCx)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHECK_PARAM(PARAM_RTCx(RTCx));&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Configure clock to RTC&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_CREG-&amp;gt;CREG0 &amp;amp;= ~((1 &amp;lt;&amp;lt; 3) | (1 &amp;lt;&amp;lt; 2));&amp;nbsp; // Reset 32Khz oscillator&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_CREG-&amp;gt;CREG0 |= (1 &amp;lt;&amp;lt; 1) | (1 &amp;lt;&amp;lt; 0);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Enable 32 kHz &amp;amp; 1 kHz on osc32k and release reset&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;RTCx-&amp;gt;CCR = RTC_CCR_CTCRST | RTC_CCR_CCALEN;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;void RTC_Cmd (LPC_RTC_Type* RTCx, FunctionalState NewState)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHECK_PARAM(PARAM_RTCx(RTCx));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHECK_PARAM(PARAM_FUNCTIONALSTATE(NewState));&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (NewState == ENABLE)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RTCx-&amp;gt;CCR |= RTC_CCR_CLKEN;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while ((RTCx-&amp;gt;CCR &amp;amp; RTC_CCR_CLKEN) == 0);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RTCx-&amp;gt;CCR &amp;amp;= (~RTC_CCR_CLKEN) &amp;amp; RTC_CCR_BITMASK;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the main function after intilization of other required peripherals, I am calling RTC_Init() first and then RTC_Cmd(LPC_RTC, ENABLE).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kindly help me what is the problem because of which the RTC is losing time after power down.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Amey&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:54:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-time-lost-after-power-failure-on-LPC4357/m-p/567354#M17505</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: RTC time lost after power failure on LPC4357</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-time-lost-after-power-failure-on-LPC4357/m-p/567355#M17506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by hangdog on Fri Oct 31 07:10:22 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: amey_pandit&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;I have also connected a external 3.3V battery to the VBAT pin. Voltage of this battery at the terminal is 3.02V.&lt;BR /&gt;&lt;BR /&gt;But when I power down the board (i.e. remove the power totally) and start again, the RTC time resets to zero (0). &lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This may sound like a very silly question, but when you say "connected an external battery", then the phrase "remove the power totally" sounds a lot like you're taking the battery away too. You're not, are you? Because that would reset the RTC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:54:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-time-lost-after-power-failure-on-LPC4357/m-p/567355#M17506</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: RTC time lost after power failure on LPC4357</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-time-lost-after-power-failure-on-LPC4357/m-p/567356#M17507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Fri Oct 31 10:35:53 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using the LPC1778 (but I guess the the RTC block is similar).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Also I do not use NXP CMSIS or LPCOpen libraries so I find it difficult to see exactly&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;which RTC hardware registers you are changing and what the changes are.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I suspect however that you are re-initialising the RTC at each reset rather than checking&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;to see it it is already setup (maintained by the battery)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The RTC init should first check the RTC_AUX register (offset 5C hex) an look at bit 4 (RTC_OSCF) to see if&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the RTC oscillator has stopped (or has never been started).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[After reading/saving this bit, you must write a one back to the same register to clear the flag regardless.]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the bit was set (one) the RTC is not running and needs to be setup:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Set CCR (Clock Control Register) to 0x12 (disable calibration, reset divisor, disable counting)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; write date/time values [Default to some standard eg midnight 1/1/2000?]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Set RTC CCR to 0x11 (disable calibration, release divisor, enable counting)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Otherwise, DO NOTHING -- The RTC is running.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You will have to translate these register accesses to conform with the CMSIS/LPC Open headers etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But that is how to maintain the time and date across power cycles/resets [Given a permanent battery supply].&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers (mine's a pint) Mike,&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:54:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-time-lost-after-power-failure-on-LPC4357/m-p/567356#M17507</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: RTC time lost after power failure on LPC4357</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-time-lost-after-power-failure-on-LPC4357/m-p/567357#M17508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by amey_pandit on Sun Nov 02 08:57:23 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Hangdog&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By the phrase "remove the power totally" means I am not removing the RTC battery I am just removing the power supply to the board. So the RTC is powered from the battery all the time. I know this looks like a silly question but it has become a show stopper.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Before this I have worked on LPC1768 RTC and it has worked well for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Mike&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will test your steps soon and will update.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers (Mine also is a pint ;) )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Amey&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:54:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-time-lost-after-power-failure-on-LPC4357/m-p/567357#M17508</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: RTC time lost after power failure on LPC4357</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-time-lost-after-power-failure-on-LPC4357/m-p/567358#M17509</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by michele sponchiado on Thu Jul 16 00:47:24 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Well sorry guys, posted in the wrong thread!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[s]Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have just found that the RTCX1/2 wasn't moving because one of the two capacitors was at the wrong value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We put 10pF measured values on both RTC capacitors, the RTC input started oscillating and the chip worked fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So... the strange thing is that if you enable the RTC without an external running clock, the whole chip hangs, and this was unexpected for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe was this your issue too?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks[/s]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:54:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-time-lost-after-power-failure-on-LPC4357/m-p/567358#M17509</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:54:39Z</dc:date>
    </item>
  </channel>
</rss>

