<?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 assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/81058/app-timer-assert---app_timer_safe_window</link><description>I have started getting an assert in my code while testing new functionality. 
 I am using SDK 17.1.0 and the nRF52840 DK 
 The assert is line 321 in app_timer2.c 
 
 
 
 Looking at the the description of APP_TIMER_SAFE_WINDOW_MS in sdk_config.h 
 
 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 03 Oct 2023 04:57:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/81058/app-timer-assert---app_timer_safe_window" /><item><title>RE: App Timer assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/thread/448593?ContentTypeID=1</link><pubDate>Tue, 03 Oct 2023 04:57:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11a4a201-5085-4369-a3e1-0349db925222</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Krzysztof says that the assert is too strict and could give false positive (which I already mentioned)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Anyway, it means that assert is too strict and does not cover for this case. 
I will look into fixing this assert. The SDK16 version was not covering timeouts 
longer than 24 bits thus it was changed. For now you can get back to assert from 
v16 as long as you are not using timeouts &amp;gt; 24 bits.&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/thread/448557?ContentTypeID=1</link><pubDate>Mon, 02 Oct 2023 15:16:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4cc5638a-3c8f-473b-991e-e22fb057178e</guid><dc:creator>Rost</dc:creator><description>&lt;p&gt;:) Finally I found something reasonable and repeated the issue with debugging, the CC is&amp;nbsp;incorrectly set as described &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/65259/app_timer2-assert-in-on_compare_evt-after-upgrade-from-sdk-16-to-sdk-17/274010"&gt;here by Krzysztof&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The fix would be as shown in post &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/65259/app_timer2-assert-in-on_compare_evt-after-upgrade-from-sdk-16-to-sdk-17/266722" rel="noopener noreferrer" target="_blank"&gt;above&lt;/a&gt;&amp;nbsp;in SDK17.1 in file app_timer2.c:321&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ASSERT(app_timer_cnt_diff_compute(drv_rtc_counter_get(p_instance), 
       mp_active_timer-&amp;gt;end_val &amp;amp; RTC_COUNTER_COUNTER_Msk) &amp;lt; APP_TIMER_SAFE_WINDOW);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/thread/448434?ContentTypeID=1</link><pubDate>Mon, 02 Oct 2023 05:57:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdf8ac97-9b44-4d0b-882b-e253a06330f8</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Rost,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Good thoughts, I agree to most of it. But sometimes the developer puts an assert and figures out later when the assert is hitting in a condition when the use case is genuine, then their assumption of the state machine in a particular state is wrong. In this case, the actual developer thinks that the assert is catching a lot of false positives so probably that assert should not be there.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In General it is a good habit for a developer to put debug asserts in places where they know a condition should not occur, but sometimes (rarely), those asserts have bugs aswell.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/thread/448375?ContentTypeID=1</link><pubDate>Fri, 29 Sep 2023 14:22:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c6eda88-bbea-4c69-87ca-4973e6823743</guid><dc:creator>Rost</dc:creator><description>&lt;p&gt;Sorry guys, I assumed initially that&amp;#39;s a joke, but I see that quite serious suggestion.&lt;/p&gt;
&lt;p&gt;Once a developer puts any kind of ASSERT, usually (not always) it protects from some more crucial conditions, generally protect one developer from another developer&amp;#39;s stupidity, in common case it avoid many obvious errors in production. So smart developers try to insert such ASSERTs to show on early stage of code about wrong arguments, incorrect conditions, problems on runtime.&lt;/p&gt;
&lt;p&gt;I caught the same error today, that&amp;#39;s why I&amp;#39;ve been writing the message right now.I don&amp;#39;t know a reason&amp;nbsp;why it happens in my code, but what&amp;nbsp;should NOT be done absolutely: to comment the ASSERT in own SDK code while you haven&amp;#39;t get deep understanding why the timer handling goes out of the range of expected lag window.&lt;/p&gt;
&lt;p&gt;Especially for people with such &amp;quot;easy fixes&amp;quot; approach in their head: just turn into Release mode from Debug, so you get no ASSERT macro anymore, but the assert call means you have got already an issue in your code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/thread/423863?ContentTypeID=1</link><pubDate>Thu, 04 May 2023 19:39:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68ddc31f-a248-40f9-9ad9-6bb7cb0e6791</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;It is verified by the customer and not regression tested on our end. That is a workaround that is suggested by Nordic to be used at your own risk since we do not do any production release testing on that workaround and most likely will not be able to do it in the near future on the older SDK solutions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/thread/423743?ContentTypeID=1</link><pubDate>Thu, 04 May 2023 10:54:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32c7aab5-a700-473b-902a-ec5b77d1e31a</guid><dc:creator>tellg</dc:creator><description>&lt;p&gt;Is the suggested fix a verified fix recommended by Nordic?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/thread/381983?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 10:57:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e700c463-1827-4412-a017-0c7fc8dc1482</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There unfortunately be no minor fixes coming into the SDK as I have learnt there are no planned released for nRF5 SDK as of now. All resources and roadmaps are for newer nRF Connect SDK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/thread/381966?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 10:25:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30f871bb-ca33-4e29-9e8b-3b7ed8499009</guid><dc:creator>tellg</dc:creator><description>&lt;p&gt;Any new status on this? I am using the same nrf5SDK version (17.1.0) and sometimes experience this too.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/thread/338821?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 14:05:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f748ab71-ef9f-4da1-b209-45a48d2081a3</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="TomDavies"]Are there plans to issue an update to the SDK to fix the issue?[/quote]
&lt;p&gt;Yes, hopefully this will be fixed soon, i will send a gentle reminder to the team.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/thread/338749?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 10:26:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d73730ef-cc47-4773-8325-8b0a98cb3229</guid><dc:creator>Tom</dc:creator><description>&lt;p&gt;Thanks Sushell, I forgot to circle back on this one but the test was running for almost a week without any issues.&lt;/p&gt;
&lt;p&gt;Are there plans to issue an update to the SDK to fix the issue?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/thread/336834?ContentTypeID=1</link><pubDate>Mon, 01 Nov 2021 11:11:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8aac3fa8-2961-41d0-9cc7-1bdbf89969dd</guid><dc:creator>Tom</dc:creator><description>&lt;p&gt;I&amp;#39;ve made the change and rerunning the tests. So far, so good. I will report back in a couple of days, if there are no more crashes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/thread/336555?ContentTypeID=1</link><pubDate>Thu, 28 Oct 2021 17:58:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:318c082d-6ee9-4e17-83f3-bf7f78680fc3</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/65259/app_timer2-assert-in-on_compare_evt-after-upgrade-from-sdk-16-to-sdk-17"&gt; known issue&lt;/a&gt;It looks like this is a known issue. It could be a false positive, try remove the assert in on_compare_evt&amp;nbsp;&lt;/p&gt;
&lt;p&gt;and replace it with the below&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        ASSERT(app_timer_cnt_diff_compute(drv_rtc_counter_get(p_instance),
                                          mp_active_timer-&amp;gt;end_val &amp;amp; RTC_COUNTER_COUNTER_Msk) &amp;lt; APP_TIMER_SAFE_WINDOW);
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/thread/336057?ContentTypeID=1</link><pubDate>Tue, 26 Oct 2021 19:04:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78953cc3-eea2-496f-a221-e818d86e84b9</guid><dc:creator>Tom</dc:creator><description>&lt;p&gt;Thanks for getting back to me Susheel.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;By registration do you mean calls to app_timer_create?&lt;/p&gt;
&lt;p&gt;There are 4 repeated timers and 2 single shot timers. When the assert occurred 3 of the repeated timers would have been running and neither of the single shot timers should have been running (triggered by user input, but unit was left testing and wouldn&amp;#39;t have received the correct triggers to start the single shot timers).&lt;/p&gt;
&lt;p&gt;They are all created&amp;nbsp;at boot up, once the system is initialised there are no other timers created.&lt;/p&gt;
&lt;p&gt;All the timers have their own callback functions and both the single shot timers log that they have been called (there were no logs to indicate that the single shot timers handlers were called but I will verify this again).&lt;/p&gt;
&lt;p&gt;Of the remaining timers, one is responsible for feeding the WDT, so seems unlikely to be the one not handled, otherwise the WDT would have kicked in. The others drive a bluetooth notification and toggling a status LED.&lt;/p&gt;
&lt;p&gt;I will add debug logs to the create calls and the LED toggle, I will log bluetooth activity and hopefully I&amp;#39;ll be able to narrow down which isn&amp;#39;t being handled.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Once I can identify which isn&amp;#39;t being handled, what would be the next steps to working out why it isn&amp;#39;t being handled?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: App Timer assert - APP_TIMER_SAFE_WINDOW</title><link>https://devzone.nordicsemi.com/thread/336053?ContentTypeID=1</link><pubDate>Tue, 26 Oct 2021 18:12:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:274d396f-8313-4391-984a-07fa95623b3a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;what kind of app_timer registration are you having? probably you should have some debug logs that print when you register a timer and also some debug logs when the timer callback is called. This becomes easier if it is a&amp;nbsp;APP_TIMER_MODE_SINGLE_SHOT timer. This should not have happened if you are not disabling the application timer interrupts. If you have not changed anything in the sdk_config.h file and the app_timer2 code, then it looks like this is a bug that seems to very hard to trigger and debug.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>