<?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>timestamp problem</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/98582/timestamp-problem</link><description>Hardware: The chip is 52832, the low-frequency crystal frequency is 32.768kHz, and the crystal precision is &amp;#177;20ppm 
 Our application is to make a second level timestamp (Unix timestamp)function, it can synchronize the time through the phone. I start a</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 13 Apr 2023 01:41:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/98582/timestamp-problem" /><item><title>RE: timestamp problem</title><link>https://devzone.nordicsemi.com/thread/420064?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 01:41:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7921707d-32b8-41f4-90f5-02d55a3989e8</guid><dc:creator>alan11</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/emil-lenngren"&gt;Emil Lenngren&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I have the same problem, and it sounds like a great tip.&lt;/p&gt;
&lt;p&gt;1.Can you provide simple sample code? For RTC overflow calibration problem&lt;/p&gt;
&lt;p&gt;2.How to detect the accuracy of external &lt;span&gt;LFXO&lt;/span&gt; crystal oscillator?&lt;/p&gt;
&lt;p&gt;Best wishes&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: timestamp problem</title><link>https://devzone.nordicsemi.com/thread/419521?ContentTypeID=1</link><pubDate>Tue, 11 Apr 2023 06:38:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be7f0fb7-49ae-4fa1-becf-29355b87c823</guid><dc:creator>Victor A</dc:creator><description>&lt;p&gt;&lt;span&gt;If, for example, diff_tick contains ~1.001007 seconds, 1001 ms will be added on the last time,1007 microseconds will be saved and added the next time.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This is the result of RTC COUNTER.&lt;/span&gt;That means&amp;nbsp;it actually ran 1.001007s,If discard it, that will lose 1007us&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: timestamp problem</title><link>https://devzone.nordicsemi.com/thread/419476?ContentTypeID=1</link><pubDate>Mon, 10 Apr 2023 06:44:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbc8046a-bf69-4a87-9677-e79dfc88f214</guid><dc:creator>Emil Lenngren</dc:creator><description>&lt;p&gt;Because your calculations are wrong. On the last line you add an integer number of milliseconds that have passed since last time. To compensate for rounding errors, the remain_tick variable contains a remainder that is added the next time. But it&amp;#39;s an incorrect remainder. If, for example, diff_tick contains ~1.001007 seconds, 1001 ms will be added on the last time, but ~1007 microseconds will be saved and added the next time, resulting in exactly a one millisecond extra drift.&lt;/p&gt;
&lt;p&gt;Using an app timer that performs cpu work like this every second is not really battery efficient anyway. Instead, whenever you want to retrieve the time, you can have a function that gets the time directly from the COUNTER register of the RTC, correctly adjusted with how many RTC overflows have happened, plus the synchronisation value that converts it to a Unix timestamp.&lt;/p&gt;
&lt;p&gt;Also make sure you configure the project to actually use the LFXO and not the internal oscillator.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>