<?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>Restore date and time after reboot</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/124585/restore-date-and-time-after-reboot</link><description>Hello Nordic Support, 
 I have a question regarding the real-time clock (RTC) functionality on the nRF9160. 
 
 
 RTC availability 
 
 
 Does the nRF9160 have an internal real-time clock that can preserve time across reboots? 
 
 
 
 
 Behavior on reboot</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 13 Feb 2026 19:18:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/124585/restore-date-and-time-after-reboot" /><item><title>RE: Restore date and time after reboot</title><link>https://devzone.nordicsemi.com/thread/561154?ContentTypeID=1</link><pubDate>Fri, 13 Feb 2026 19:18:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b782b1c-dbbb-4554-89c4-014d56621ae1</guid><dc:creator>Paul012</dc:creator><description>&lt;p&gt;There is another way.&amp;nbsp; I have used a combination of the reset reason register and scratch space in RAM to store the current time at some frequency (say 30s) to be able to restore the time, with accuracy directly related to scratach space update frequency.&lt;/p&gt;
&lt;p&gt;It requires the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;define/reserve a scratch space in RAM&lt;/li&gt;
&lt;li&gt;modify cinit() to not erase the scratch space upon reset&lt;/li&gt;
&lt;li&gt;at some frequency, save the current RTC value to the scratch space and calculate a CRC on it (CRC-8 or 16 should do)&lt;/li&gt;
&lt;li&gt;at boot time, after cinit(), during system init, check the reset reason and calculate the CRC on the scratch space&lt;/li&gt;
&lt;li&gt;if the reset reason was not power related and the CRC is good, then set the RTC to the stored value&lt;/li&gt;
&lt;li&gt;continue system init....&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that reset reason is really optional.&amp;nbsp; If the power glitches so fast that the RAM isn&amp;#39;t corrupted then you&amp;#39;re probably OK.&amp;nbsp; But if the time values is very critical (safety related) then the reset reason is another check to ensure the value is good to go.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restore date and time after reboot</title><link>https://devzone.nordicsemi.com/thread/550114?ContentTypeID=1</link><pubDate>Tue, 30 Sep 2025 09:08:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b14fe36-b839-4017-9587-58e6d617688d</guid><dc:creator>Roman Veselskyi</dc:creator><description>&lt;p&gt;Hello&lt;a href="https://devzone.nordicsemi.com/members/hkn"&gt;Håkon Alseth&lt;/a&gt;,&lt;br /&gt;&lt;br /&gt;Thanks for the information.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restore date and time after reboot</title><link>https://devzone.nordicsemi.com/thread/549817?ContentTypeID=1</link><pubDate>Thu, 25 Sep 2025 13:35:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b36563d7-7493-4ffd-9e75-8c8bfa7efb19</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]Does the nRF9160 have an internal real-time clock that can preserve time across reboots?[/quote]
&lt;p&gt;nRF devices has a real time counter, not real time clock, unfortunately.&lt;/p&gt;
[quote user=""]I can understand losing time when the device is fully powered off or the battery is disconnected, but why is this happening during a reboot?[/quote]
&lt;p&gt;All peripherals are reset on reboot, except certain functions as listed here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf9160/page/pmureset.html#ariaid-title9"&gt;https://docs.nordicsemi.com/bundle/ps_nrf9160/page/pmureset.html#ariaid-title9&lt;/a&gt;&lt;/p&gt;
[quote user=""]After the reboot, we need to continue collecting events with valid timestamps, but without network access we cannot re-sync the time.[/quote]
&lt;p&gt;The nRF91-device needs to fetch time from somewhere. LTE network, NTP, and/or GNSS are all options in this case.&lt;/p&gt;
&lt;p&gt;You mention that you store entries with timestamps:&lt;/p&gt;
[quote user=""]Our firmware collects events and stores them in flash[/quote]
&lt;p&gt;You can restore the timestamp, based on the last stored entry, to get a approximation relative to the last stored timestamp. When you update the timestamp, you can compare and store the diff. This is a hack, but can give you an anchor.&lt;/p&gt;
&lt;p&gt;Example, use clock_settime() to restore after boot:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/119523/setting-and-updating-absolute-time-in-zephyr-application-using-time_t-epoch"&gt;Setting and Updating Absolute Time in Zephyr Application Using time_t Epoch&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>