<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Retain 32 bits across a watchdog reset ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29789/retain-32-bits-across-a-watchdog-reset</link><description>I&amp;#39;m sure the same question has been asked in a few different forms, but hoping for some ideas. . .
Is there a way to retain 32 bits of information across a watchdog reset ? 
 I currently use PPI to clock a 32 bit counter at 1Hz from the RTC, this is</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 22 Jun 2017 01:07:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29789/retain-32-bits-across-a-watchdog-reset" /><item><title>RE: Retain 32 bits across a watchdog reset ?</title><link>https://devzone.nordicsemi.com/thread/118171?ContentTypeID=1</link><pubDate>Thu, 22 Jun 2017 01:07:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:909d3617-950d-4765-9611-5d2c63ba77bb</guid><dc:creator>AmbystomaLabs</dc:creator><description>&lt;p&gt;Excellent!  Glad to hear it&amp;#39;s a good solution.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Retain 32 bits across a watchdog reset ?</title><link>https://devzone.nordicsemi.com/thread/118174?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 21:55:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:acf15da0-f981-4ba1-8692-76dce39ffa63</guid><dc:creator>Hein</dc:creator><description>&lt;p&gt;Update . . . storing to ram before a watchdog reset seems to work well. I&amp;#39;ve got some guard uint32_t variables around the value I care about, so at least in theory I should be able to detect ram corruption, but it seems the chances of ram corruption with a normal watchdog reset are pretty low. For a brownout or power on reset I clear the variables anyway, so not too concerned about that.&lt;/p&gt;
&lt;p&gt;Our devices update their real time every time they make a BLE connection (usually daily) anyway, so not too worried about keeping great time, in practice 20ppm over a year would be a fantastic result.&lt;/p&gt;
&lt;p&gt;Thanks for your input and advice AmbystomaLabs and Daniel Wang.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Retain 32 bits across a watchdog reset ?</title><link>https://devzone.nordicsemi.com/thread/118169?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 19:16:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b365ee23-3f97-4395-b55a-5f8c51033242</guid><dc:creator>Daniel Wang</dc:creator><description>&lt;p&gt;For &amp;quot;real time clock&amp;quot;/calender, check out the nrf5-calendar-example:
&lt;a href="https://github.com/NordicSemiconductor/nrf5-calendar-example"&gt;github.com/.../nrf5-calendar-example&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Retain 32 bits across a watchdog reset ?</title><link>https://devzone.nordicsemi.com/thread/118170?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 17:47:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:817ee791-771c-44d2-9a73-193ad6c9df72</guid><dc:creator>AmbystomaLabs</dc:creator><description>&lt;p&gt;The RTC on most microcontrollers is really just a tick, app_timer kind of thing. And, for bluetooth it runs sleep/wake to keep the framing correct.  At 20ppm it&amp;#39;s not going to keep great time anyway. It might be for that reason that they refer to it as a real time counter and not real time clock.&lt;/p&gt;
&lt;p&gt;There are a lot of good real time clock solutions out there in tiny packages and only draw nanoamps. Plus they have internal registers that will keep time for roughly forever.  Interfaces are simple i2c, 1 wire or 2 wire serial. Most are around 1 to 2ppm. Or under 1 minute error annually. This might be a better solution if you have high performance time keeping requirements.  Plus at nanoamps these can normally be run from soldered in rechargeable button cells so they even run with power off.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Retain 32 bits across a watchdog reset ?</title><link>https://devzone.nordicsemi.com/thread/118173?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 01:27:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1cc3fb3a-4714-47b3-a8b9-c359db0fb4d0</guid><dc:creator>Hein</dc:creator><description>&lt;p&gt;Also, because the RTC is 24bit with a 12bit prescaler, you cannot really use it to keep real time for years. At maximum values, it would overflow every 24 days or so if my quick math is correct.  This means to do a low power timebase that runs for years, I had to use the PPI to clock a 32 bit counter every second, which then also turns on the HF clock briefly at every event, which causes a extra 100nA or so on average of extra power consumption in sleep mode. This problem could have been avoided by either being able to use the 32k clock for a 32bit timer or by making the RTC 32 bit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Retain 32 bits across a watchdog reset ?</title><link>https://devzone.nordicsemi.com/thread/118172?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 01:21:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b95c01a-6086-4c79-a9d8-38a4b647b243</guid><dc:creator>Hein</dc:creator><description>&lt;p&gt;Yeah, I should have added that we are ultra low power, our devices usually sleep @ less than 2uA to get the lifetime we require from a CR2032. No chance of writing to flash and even having to wake up the high frequency clock every second just to store the timer value make a real difference to our sleep current.&lt;/p&gt;
&lt;p&gt;I have experimented with writing the timer to a .noinit global variable and it looks to be working well in practice. I would have liked to store the timer value to this variable in the watchdog event handler, but it seems I cannot initialize the 32 bit counter to the stored value at startup ? Still trying to think about a simple way around all these catches.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Retain 32 bits across a watchdog reset ?</title><link>https://devzone.nordicsemi.com/thread/118167?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 00:31:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b299bd2-2b60-40bf-966f-237a1416c8cc</guid><dc:creator>AmbystomaLabs</dc:creator><description>&lt;p&gt;Well you could push your 32 bit register to flash between watchdog refresh cycles. Unless your watchdog time is unusually short this shouldn&amp;#39;t use much power. Then on reboot you can look for the data and load if available. At worst you will be off by one watchdog cycle.  The reality is you would always be off a little on a watchdog reset since the RTC won&amp;#39;t be configured on reset.&lt;/p&gt;
&lt;p&gt;As for the RTC timer, a second of 32768 fits nicely in 16 bits so even 24 bits is overkill let alone 32 bits.  Don&amp;#39;t know if they had a reason for it though.&lt;/p&gt;
&lt;p&gt;According to the spec, ram does not reset under any circumstance.  They warn that it could be corrupted depending on the reset reason (eg, brownout).  So, you could just write the 32bit word to ram once a second and just make sure to not initialize the variable in C. Sounds silly, but it should work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Retain 32 bits across a watchdog reset ?</title><link>https://devzone.nordicsemi.com/thread/118168?ContentTypeID=1</link><pubDate>Tue, 20 Jun 2017 23:20:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:415afd23-88a9-4f05-8440-bb5538b4f25d</guid><dc:creator>Hein</dc:creator><description>&lt;p&gt;Also, why on earth would the GPREGRET registers not be 32 bit ?!?!?!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>