<?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>Repeated app_timer vs RTC with maximum prescaler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51442/repeated-app_timer-vs-rtc-with-maximum-prescaler</link><description>Hi for my use-case I need the RTC in the NRF51 SoC to run continuously and uninterrupted (we know running out of battery will be a concern). Keeping the NRF51 system on 24/7 will drain battery power quickly, but the NRF51 will also be connected to sensors</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Aug 2019 13:11:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51442/repeated-app_timer-vs-rtc-with-maximum-prescaler" /><item><title>RE: Repeated app_timer vs RTC with maximum prescaler</title><link>https://devzone.nordicsemi.com/thread/206886?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2019 13:11:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ecc91ece-0f02-4136-98f8-8b610f6530cb</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
[quote user="myNrfDoesntWork"]If I use a repeated app_timer of one second, shouldn&amp;#39;t&amp;nbsp;the RTC itself never overflow?[/quote]
&lt;p&gt;It will overflow at one point, but the overflow is handled automatically by the app_timer library so that you don&amp;#39;t have to think about it. The app_timer callbacks will&amp;nbsp;continue to run as normal even after the overflow occurs.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I agree with your math. If you use a uint32 for counting seconds, and start running it now, it will not overflow until 136 years have past.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you are thinking about reserving a full 20 bytes for the second counter then the sun should burn out long before your counter overflows ;)&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Repeated app_timer vs RTC with maximum prescaler</title><link>https://devzone.nordicsemi.com/thread/206758?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2019 07:00:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc77e12f-7460-4c88-ae1f-8a3a9edb55e1</guid><dc:creator>myNrfDoesntWork</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If I use a repeated app_timer of one second, shouldn&amp;#39;t&amp;nbsp;the RTC itself never overflow? &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Using repeated app_timer I would be incrementing a counter variable every second, and an integer variable can overflow. But if the maximum unsigned integer value in C is&amp;nbsp;4294967295 then a counter variable of&amp;nbsp;4294967295 seconds would still be 136 years. If I am trying to transmit the value over BLE, then the maximum integer value is 2^(20 bytes*8 bits) - 1, which is still a lot of years before overflow.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is my logic correct, or am I missing any important details? Thanks!&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Repeated app_timer vs RTC with maximum prescaler</title><link>https://devzone.nordicsemi.com/thread/206751?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2019 06:27:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cfd0e9a3-0b83-43b2-bec7-eaf06bd3b18d</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;To me it seem the main difference between these two approaches is how often it overflows. At one point it will overflow regardless.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The main impact on average current consumption will be your wakeup frequency, and the choice of prescaler should not make a big difference.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would suggest setting a wakeup frequency suitable for the sensor sampling and other things you need to do, and update a variable according to the wakeup frequency.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Repeated app_timer vs RTC with maximum prescaler</title><link>https://devzone.nordicsemi.com/thread/206704?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2019 16:40:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:191445ab-b083-4b84-a033-e3cb6ce42d31</guid><dc:creator>myNrfDoesntWork</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks, I will check it out! But&amp;nbsp;are there any significant advantages or disadvantages with using a repeated app_timer with a duration of one/two seconds over using an app_timer with maximum prescaler (4095)&amp;nbsp;&amp;amp; maximum duration of&amp;nbsp;582.542 hours?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Repeated app_timer vs RTC with maximum prescaler</title><link>https://devzone.nordicsemi.com/thread/206500?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2019 07:04:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94a9d046-1b6e-4d40-bbd0-dd2c594f9d03</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I made a small calendar example for the nRF52 series a while back. There are no project files for the nRF51 unfortunately, but I don&amp;#39;t think it should be a lot of work to make it run on the nRF51 instead.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It allows you to use the app_timer just as you describe, and fire of an interrupt every second. Then it will update an internal variable, and use the time.h library to decode this into a time and date.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The example can be found here:&lt;br /&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;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>