<?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>App Timer (RTC1) drift</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16963/app-timer-rtc1-drift</link><description>Hi,
we have the need to develop an application that needs a precise second counter over time. 
 Our firmware is using the S110 SoftDevice (v8.0.0) and SDK v8.0.0 to perform scannable advertising (the second counter value is sent in the advertising data</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 14 Oct 2016 13:41:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16963/app-timer-rtc1-drift" /><item><title>RE: App Timer (RTC1) drift</title><link>https://devzone.nordicsemi.com/thread/65073?ContentTypeID=1</link><pubDate>Fri, 14 Oct 2016 13:41:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51922ad1-e32d-49d9-a96b-03fd469cd741</guid><dc:creator>Samuele Forconi</dc:creator><description>&lt;p&gt;The clock of the nRF was always slower than the real clock, but we don&amp;#39;t know if it is linear with time (we can try to run the FW for some days and check what happens).&lt;/p&gt;
&lt;p&gt;Now I&amp;#39;ve set the PRESCALER to 0 and added the 30us delay as in the previous post (to see if it improves the counting accuracy).&lt;/p&gt;
&lt;p&gt;We tried to figure out why that delay has been added to the timer handler, but in the end we haven&amp;#39;t found any real / explicable reason... we were wondering if it was  a value that was measured empirically (ie using an oscilloscope) and set in the FW to improve the time keeping accuracy.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer (RTC1) drift</title><link>https://devzone.nordicsemi.com/thread/65074?ContentTypeID=1</link><pubDate>Fri, 14 Oct 2016 13:14:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d3e590c-225f-4608-912e-e772f8c02dde</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;I don&amp;#39;t know why the delay is added, but I can try to figure it out (I can&amp;#39;t get hold of the person that wrote the code).&lt;/p&gt;
&lt;p&gt;Do you have an answer to if the clock is slower or faster than the real clock?&lt;/p&gt;
&lt;p&gt;Also is the error increasing linearly with the time? (fex one minute after one day, two minutes after two days and so on).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer (RTC1) drift</title><link>https://devzone.nordicsemi.com/thread/65072?ContentTypeID=1</link><pubDate>Thu, 13 Oct 2016 15:25:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1dba6af5-2038-4ff3-898c-c8e41a619a0e</guid><dc:creator>Samuele Forconi</dc:creator><description>&lt;p&gt;Sorry, in the meanwhile I have also coded a version of the firmware that uses a 1s timer (using the app_timer library), and it seems that the accuracy is better than the firmware that reads the RTC counter directly (but I can&amp;#39;t explain why)...&lt;/p&gt;
&lt;p&gt;In the firmware there are other timers (always in the range of seconds, not us nor ms timers), so I believe the RTC is kept active from the SoftDevice.&lt;/p&gt;
&lt;p&gt;Yes, with a PRESCALER set to 0 the tick interval is around 30.5us, but I can&amp;#39;t explain why the timer loose 1 tick every second... it is documented somewhere in the docs? If I change the PRESCALER to 4095 (125ms tick interval), will the timer loose 125ms every second?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer (RTC1) drift</title><link>https://devzone.nordicsemi.com/thread/65071?ContentTypeID=1</link><pubDate>Thu, 13 Oct 2016 14:49:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07bb3878-1f48-4689-b84c-e0fd62f044b1</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;30 us is about the resolution when prescaler is 0 (1/32768Hz = 30.5us). I don&amp;#39;t know why this is added, but you don&amp;#39;t have to worry about this. You are reading the value of the RTC (app_timer_cnt_get(&amp;amp;current_tick)) directly, not assuming that a callback was called at exactly one second interval.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer (RTC1) drift</title><link>https://devzone.nordicsemi.com/thread/65070?ContentTypeID=1</link><pubDate>Thu, 13 Oct 2016 14:39:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3046ebc5-0df6-406a-8949-12c426c2993d</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;5 minutes over 3 days is about 5/(3 * 24 * 60) = 1157ppm, which is way too high. Is the clock slower or faster than the real time, and is it always like this?&lt;/p&gt;
&lt;p&gt;Do you always have a timer running? The app_timer module will stop the RTC if no timers are running.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer (RTC1) drift</title><link>https://devzone.nordicsemi.com/thread/65069?ContentTypeID=1</link><pubDate>Thu, 13 Oct 2016 14:29:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:549cb1db-7cce-4bba-881b-bc017dba611e</guid><dc:creator>Samuele Forconi</dc:creator><description>&lt;p&gt;Yes, we have checked the circuit but it seems everything ok...
In the Nordic Eddystone firmware, I have found this piece of code inside a timer handler function:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;...
// For every 1 second interrupt, there is 30 us delay with timer prescaler set at 0.
us_delay += 30;

if (APP_TIMER_PRESCALER != 0)
{
    //If the prescaler is not 0, then a new us_delay increment needs to be calculated...
    //Trigger a run time error here to prevent developers from blindly changing the prescaler
    APP_ERROR_CHECK(NRF_ERROR_INVALID_PARAM);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From what I understand from the code, it seems that the timer handler looses 30us each time is called (with a PRESCALER set to 0), but I&amp;#39;m not able to find on the documentation anything regarding this...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer (RTC1) drift</title><link>https://devzone.nordicsemi.com/thread/65068?ContentTypeID=1</link><pubDate>Tue, 11 Oct 2016 17:38:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ab1fe76-f8ec-4b6f-99d2-7d20ca45a904</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;My first thought would be that there is some inaccuracy in your Xtal circuit design.  Have you measures your PCB.s parasitic capacitance and factored it into the tuning capacitor values?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>