<?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>RTC to get date and time</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/5284/rtc-to-get-date-and-time</link><description>Good afternoon,
I want to get date and time from the RTC1 and working on the S110.
As the RTC1 counter is just 24-bit long, final counter value (overflow) has to be taken into account.
Regarding the function &amp;#39; app_timer_cnt_diff_compute&amp;#39;: does it take</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Jan 2015 09:43:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/5284/rtc-to-get-date-and-time" /><item><title>RE: RTC to get date and time</title><link>https://devzone.nordicsemi.com/thread/18490?ContentTypeID=1</link><pubDate>Wed, 28 Jan 2015 09:43:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3414945d-a934-4fd4-a9d2-80ad3c691cf8</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If you dive into the inner workings of app_timer_cnt_diff_compute() you will eventually find out that the time difference is computed this way:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;((ticks_now - ticks_old) &amp;amp; MAX_RTC_COUNTER_VAL); // MAX_RTC_COUNTER_VAL = 0xFFFFFF;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;so you will always get a positive integer output, and the function will show the correct value as long as the time difference is no more than MAX_RTC_COUNTER_VAL.&lt;/p&gt;
&lt;p&gt;There is an example called rtc_pca10028 in the nRF51 SDK that demonstrates the RTC. It does not use the app_timer_cnt_diff_compute() function, but it should be easy enough to integrate it and test it.&lt;/p&gt;
&lt;p&gt;See &lt;a href="https://devzone.nordicsemi.com/question/6540/nrf51822-long-time-timekeeping/"&gt;this thread&lt;/a&gt; about RTC and calendar functionality.&lt;/p&gt;
&lt;p&gt;Martin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>