<?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 sometimes expires immediately</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/62406/app-timer-sometimes-expires-immediately</link><description>Hello, 
 I am using nrf52840 and SDK 15.3.0. and the device wakes up every hour and every day for reporting data. 
 So I am using app timer to wake up also using app_timer to check timeout for sensor communication response. 
 And sometimes that sensor</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Jun 2020 13:09:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/62406/app-timer-sometimes-expires-immediately" /><item><title>RE: app timer sometimes expires immediately</title><link>https://devzone.nordicsemi.com/thread/257152?ContentTypeID=1</link><pubDate>Fri, 26 Jun 2020 13:09:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42ab963c-0cc1-4f9f-9a8e-2d75aea604a4</guid><dc:creator>eleven-x_devteam</dc:creator><description>&lt;p&gt;Sounds good, Thankyou for clarifying.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: app timer sometimes expires immediately</title><link>https://devzone.nordicsemi.com/thread/257139?ContentTypeID=1</link><pubDate>Fri, 26 Jun 2020 12:40:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b72d9ce5-5f4f-4a7b-be23-8f73f6b00b1b</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Ah, sorry. I was answering without thinking. the get_now() function gives you a counter value that always increases. (The shortest time it can take to overflow is&amp;nbsp;17851025 years, so I agree there is no point in handling that &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;)&lt;/p&gt;
&lt;p&gt;Regarding the&amp;nbsp;APP_TIMER_KEEPS_RTC_ACTIVE there were issues with this in some older SDK versions, but it is&amp;nbsp;working as expected in app_timer2.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: app timer sometimes expires immediately</title><link>https://devzone.nordicsemi.com/thread/257018?ContentTypeID=1</link><pubDate>Thu, 25 Jun 2020 18:28:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a910eeee-fc2f-462c-b767-9a3ec4a27f1e</guid><dc:creator>eleven-x_devteam</dc:creator><description>[quote userid="7377" url="~/f/nordic-q-a/62406/app-timer-sometimes-expires-immediately/255779"]The RTC should never be reset (or stopped) if you setAPP_TIMER_KEEPS_RTC_ACTIVE to 1 in your sdk_config.h.[/quote]
&lt;p&gt;Yeah, I&amp;#39;ve been using this setting but it was reset with apptimer1 sdk15.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/62406/app-timer-sometimes-expires-immediately/255779"]This is an internal static function. You can of course make it none static and u see it, but you need to handle overflows.[/quote]
&lt;p&gt;I thought get_now() can cover the overflows as well.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;It looks like m_base_counter is updated with overflow count in on_overflow_evt() like below.&lt;br /&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;static&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;on_overflow_evt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;NRF_LOG_DEBUG&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;quot;Overflow&amp;nbsp;EVT&amp;quot;&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m_base_counter&amp;nbsp;+=&amp;nbsp;(DRV_RTC_MAX_CNT&amp;nbsp;+&amp;nbsp;&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: app timer sometimes expires immediately</title><link>https://devzone.nordicsemi.com/thread/255779?ContentTypeID=1</link><pubDate>Thu, 18 Jun 2020 12:57:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e35ce5b5-3d63-4cb5-aa43-b4c132cd9bea</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="eleven-x_devteam"]So the apptimer2 supports 64 bit tick counter as well right?[/quote]
&lt;p&gt;Not really. It use 64 bit counter internally,&amp;nbsp;and it is not limited to the 24 bit of the physical RTC like the original implementation, but the API still use 32 bit ticks (uint32_t).&lt;/p&gt;
[quote user="eleven-x_devteam"]t looks like I can use apptimer2 get_now() instead of implementing extra code. Am I correct?[/quote]
&lt;p&gt;This is an internal static function. You can of course make it none static and u see it, but you need to handle overflows.&lt;/p&gt;
[quote user="eleven-x_devteam"]or do I need some more set up to avoid rtc counter reset issue?[/quote]
&lt;p&gt;The RTC should never be reset (or stopped) if you setAPP_TIMER_KEEPS_RTC_ACTIVE to 1 in your sdk_config.h.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: app timer sometimes expires immediately</title><link>https://devzone.nordicsemi.com/thread/255604?ContentTypeID=1</link><pubDate>Wed, 17 Jun 2020 15:49:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afe92cc8-de8c-46fd-aa26-aee2852fce4d</guid><dc:creator>eleven-x_devteam</dc:creator><description>&lt;p&gt;Seems like it works.&lt;/p&gt;
&lt;p&gt;So the apptimer2 supports 64 bit tick counter as well right?&lt;/p&gt;
&lt;p&gt;I was using extra code that&amp;nbsp;&lt;span&gt;calculates rtc1 with overflow counter&amp;nbsp;&lt;/span&gt;for supporting a long time os tick counter&amp;nbsp;but it looks like I can use apptimer2 get_now() instead of implementing extra code. Am I correct? or do I need some more set up to avoid rtc counter reset issue? I have never seen rtc counter reset issue with apptimer2 so far but my testing time&amp;nbsp;was not enough and just want to make sure.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: app timer sometimes expires immediately</title><link>https://devzone.nordicsemi.com/thread/254576?ContentTypeID=1</link><pubDate>Thu, 11 Jun 2020 21:37:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64d8bfe2-ef46-4219-982c-2ad53f717155</guid><dc:creator>eleven-x_devteam</dc:creator><description>&lt;p&gt;Ok I&amp;#39;ll try with app timer 2&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: app timer sometimes expires immediately</title><link>https://devzone.nordicsemi.com/thread/254404?ContentTypeID=1</link><pubDate>Thu, 11 Jun 2020 09:11:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee8f836c-83b7-459f-855e-9460121cfe6f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;MAX_RTC_COUNTER_VAL/2 is present in most SDK versions. I recommend you use the app_timer2 implementation (app_timer2.c) from SDK 16. If you are using 15.3, just copy that to your older SDK version. app_time2 is a complete rewrite, and it is the default in SDK 16. It does not suffer from the same bugs as the old app_timer implementation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>