<?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>Best way to track seconds precisely on our nRF52832</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66104/best-way-to-track-seconds-precisely-on-our-nrf52832</link><description>Hello, I&amp;#39;ve seen several posts about this, but I&amp;#39;m a little hesitant to use older posts since you guys put out new and improved versions pretty quickly. We are using SDK 16.0 and an nRF52832. 
 What is the best way to keep track of precise real time </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 15 Oct 2020 14:24:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66104/best-way-to-track-seconds-precisely-on-our-nrf52832" /><item><title>RE: Best way to track seconds precisely on our nRF52832</title><link>https://devzone.nordicsemi.com/thread/275145?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2020 14:24:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64350593-0705-4db8-83a2-811ca162c127</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;Let us continue this in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/67210/mysterious-clock-error-when-using-rtc-on-nrf52832"&gt;the other ticket&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to track seconds precisely on our nRF52832</title><link>https://devzone.nordicsemi.com/thread/274953?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2020 19:24:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2051889-8dd6-4965-a94c-196755fc5cb1</guid><dc:creator>riceman0</dc:creator><description>&lt;p&gt;Actually... I see that I&amp;#39;ve already verified the answer for this question... sorry I will start a new one.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to track seconds precisely on our nRF52832</title><link>https://devzone.nordicsemi.com/thread/274952?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2020 19:23:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ce77e6f-4a8a-4859-8319-111d2694ee22</guid><dc:creator>riceman0</dc:creator><description>&lt;p&gt;Hello, thanks for the detailed answer.&amp;nbsp; Using Jay&amp;#39;s example, it uses a prescaler of 0xFFF (+1=4096), which sets a timer period of 125msec and then we set our &amp;quot;callback interval&amp;quot; using&amp;nbsp;nrf_cal_set_callback with a parameter of 4 seconds.&amp;nbsp; This causes the RTC-&amp;gt;CC[0] register to be set to 4*8=32, which should come out to exactly 4 seconds (no resolution error).&amp;nbsp; So I think #2 should not be a contributor?&lt;/p&gt;
&lt;p&gt;What I&amp;#39;ve done is I&amp;#39;ve printed out a serial message on the callbacks, which should be 4 second intervals.&amp;nbsp; What I am seeing is this, consistently:&lt;/p&gt;
&lt;p&gt;Tick 0 at 0 msec&lt;/p&gt;
&lt;p&gt;Tick 93 at 371875msec (3998.65msec/tick)&lt;/p&gt;
&lt;p&gt;Tick 155 at 619796msec (3998.68msec/tick)&lt;/p&gt;
&lt;p&gt;Tick 574 at 2275250msec (3998.68msec/tick)&lt;/p&gt;
&lt;p&gt;This is consistent across my tests, even when I boil my application down to just this timer.&amp;nbsp; It comes out to an error of about 30 seconds per day.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve asked our EE to confirm the ppm of our crystal, and it seems like this should not cause errors this big, don&amp;#39;t you think?&lt;/p&gt;
&lt;p&gt;Your idea #3 I&amp;#39;m not familiar with.&amp;nbsp; What happens, would the noise somehow cause extra pulses on a clock signal?&amp;nbsp; Would this cause the clock to run faster than configured?&amp;nbsp; (Which would be the opposite direction of my error, right?)&lt;/p&gt;
&lt;p&gt;Seeing as how the error is so consistent, I *could* compensate with a constant to fix it, but this would be very risky without understanding the source of the error, obviously.&amp;nbsp; Could you comment on my inferences above, and does anything else come to mind when I provide the data above?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to track seconds precisely on our nRF52832</title><link>https://devzone.nordicsemi.com/thread/273234?ContentTypeID=1</link><pubDate>Tue, 06 Oct 2020 12:53:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cab16a64-2bad-4209-bcfd-3a9c7237aa1e</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user="riceman0"]thanks for the answers.[/quote]
&lt;p&gt;No problem at all, we are happy to help!&lt;/p&gt;
[quote user="riceman0"]We are using that technique (thanks Jay) and seeing that the drift is approximately one minute per day.&amp;nbsp; Is this what you guys see?&amp;nbsp; Since we can&amp;#39;t count on an opportunity to sync with a central, and real time is important, we are hoping we are making some mistake that can be fixed, or (if this is expected drift) we are trying to think of any way to improve that.[/quote]
&lt;p&gt;One minute per day sounds much.&lt;br /&gt;&lt;br /&gt;When you are using the app_timer, the timeout handler will update RTC&amp;nbsp;compare register on each iteration, so drift should&amp;nbsp;depend on (1.) clock accuracy + (2.) accuracy of the compare register compared to the timeout configured and (3.) noise/ripple on VDD.&lt;/p&gt;
&lt;p&gt;(1.) Clock accuracy; in this case will be 5ppm = 5us @ 1second. However this should be verified by measurement, because the load capacitors can affect the tolerance much more than what the crystal is specified to be. The load capacitors will offset the frequency by a fixed value.&amp;nbsp;&lt;br /&gt;&lt;span&gt;For example, on the nRF52-DK the 32kHz external crystal is 20 ppm, this will give you a drift at 10.51 minutes for 1 year. The lowest ppm I have seen for a 32kHz external crystal is 5 ppm (2.63 minutes drift for 1 year). What is the ppm of your external crystal?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;(2.) Accuracy of compare register; a RTC&amp;nbsp;tick take 1/32768kHz and this fit well with a 1second [32768 periods]. That would for instance not be the case with a 1ms timeout, since that will equal 3276.8periods, which will have an error of ~10us for each 1ms timeout. What is your timer width?&lt;br /&gt;&lt;span&gt;&lt;/span&gt;&lt;br /&gt;(3.) noise/ripple on VDD. Noise/ripple on VDD; For instance the 32kHz is a analog signal in the few hundred mV peak-to-peak amplitude. If you have much ripple (e.g. &amp;gt;100mV) on VDD, for instance due to&amp;nbsp;current drawn by the radio,&amp;nbsp;then this may have an effect the clock periods and thereby drift. Have you done any measurements on this, if so; what were they?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to track seconds precisely on our nRF52832</title><link>https://devzone.nordicsemi.com/thread/272795?ContentTypeID=1</link><pubDate>Fri, 02 Oct 2020 18:09:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56098297-4e8c-41aa-876e-b3b09f3d5b76</guid><dc:creator>riceman0</dc:creator><description>&lt;p&gt;Hey guys, thanks for the answers.&amp;nbsp; We are using that technique (thanks Jay) and seeing that the drift is approximately one minute per day.&amp;nbsp; Is this what you guys see?&amp;nbsp; Since we can&amp;#39;t count on an opportunity to sync with a central, and real time is important, we are hoping we are making some mistake that can be fixed, or (if this is expected drift) we are trying to think of any way to improve that.&lt;/p&gt;
&lt;p&gt;Thanks again!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to track seconds precisely on our nRF52832</title><link>https://devzone.nordicsemi.com/thread/270462?ContentTypeID=1</link><pubDate>Mon, 21 Sep 2020 07:19:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:136caaf7-e486-4eab-981a-37aaab32c7f8</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;@Jay &amp;#39;s referenced github repository is an excellent example of how you may go about doing this.&lt;br /&gt;Unfortunately, if you only rely on the RTC then you may experience some drift as time passes ( influenced by the operating conditions ). If your application needs to minimize this drift you may look at implementing the&amp;nbsp;&lt;em&gt;Current Time Service &lt;/em&gt;( or a similar custom service )&amp;nbsp;on your central, so that your peripheral can sync its time with the central, if it is connected at any time.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to track seconds precisely on our nRF52832</title><link>https://devzone.nordicsemi.com/thread/270389?ContentTypeID=1</link><pubDate>Fri, 18 Sep 2020 17:16:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4839c19-55b7-4de9-bd1a-2495d23466f0</guid><dc:creator>Jay Tyzzer</dc:creator><description>&lt;p&gt;Please take a look at this project located in the github.&amp;nbsp; Maye there is something there you can use or jump off from.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/NordicPlayground/nrf5-calendar-example"&gt;https://github.com/NordicPlayground/nrf5-calendar-example&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;quot;This is a small example of how to keep track of time using the RTC timer and the time.h library. By default the example uses the external 32kHz crystal for maximum accuracy.&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>