<?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>Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/39459/observer-under-freertos-events-stop-coming-after-a-few-minutes</link><description>Observer under FreeRTOS: Events stop coming after a few minutes. 
 Hi there, 
 I am using the nRF52832 as simple observer running under FreeRTOS on a custom board. The built is based on the SDK HRM peripheral example. I have stripped down my code so that</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 26 Nov 2023 17:40:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/39459/observer-under-freertos-events-stop-coming-after-a-few-minutes" /><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/457430?ContentTypeID=1</link><pubDate>Sun, 26 Nov 2023 17:40:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ace661f5-0554-4afe-8789-e921a344b592</guid><dc:creator>Arie_tondo</dc:creator><description>&lt;p&gt;I also had similar problem and it solved it&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/208219?ContentTypeID=1</link><pubDate>Thu, 05 Sep 2019 13:04:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99e1ce87-2fb7-46cd-83a2-f5714af77c90</guid><dc:creator>Kosmine</dc:creator><description>&lt;p&gt;Also had this problem. Lucky I stumbled on this, because it seems to have fixed my problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/179367?ContentTypeID=1</link><pubDate>Sun, 31 Mar 2019 20:03:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2a7c8fe-493e-4970-9f03-accedf6639f1</guid><dc:creator>thin_ice</dc:creator><description>&lt;p&gt;stupid question... if SD keeps raising interrupts by&amp;nbsp;SD_EVT_IRQHandler, then&amp;nbsp;why would the scanner stop working forever as described in the problem statement which seemed to imply that the softdevice_task was unable to wake up ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/155795?ContentTypeID=1</link><pubDate>Fri, 02 Nov 2018 15:35:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fd5e7da-bf14-4c8a-90fa-a1cc326de0fe</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Siddhesh,&lt;/p&gt;
&lt;p&gt;The changes in this post are for SDK 15 and not for prior versions.&amp;nbsp;&lt;br /&gt;I have created an internal ticket (NRFFOSDK-12391) for this fix to be more tested and included in future release.&lt;/p&gt;
&lt;p&gt;Unfortunately, Technical Support cannot control as to which release this fix gets included in..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/155215?ContentTypeID=1</link><pubDate>Tue, 30 Oct 2018 18:26:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8bab0d1a-4f53-49e3-bd62-3d826c40a168</guid><dc:creator>Siddhesh</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;br /&gt;Will this change will be implemented in the next SDK version i.e. 15.3&lt;br /&gt;&lt;br /&gt;Is the change in port_cmsis_systick.c according to the following&amp;nbsp; post valid ?&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/24733/nrf52840-sdk-14-0-0-and-tickless-idle-freertos---some-suggestions"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/24733/nrf52840-sdk-14-0-0-and-tickless-idle-freertos---some-suggestions&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Any timeline on the release of SDK 15.3 ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/155100?ContentTypeID=1</link><pubDate>Tue, 30 Oct 2018 12:23:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47a891f4-3c52-47b6-af4b-60b86bd4eb1a</guid><dc:creator>CheMax</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;Thanks. &lt;span class="" id="result_box" lang="en"&gt;&lt;span class=""&gt;I struggled with this problem for 4 days and already wanted to ask a question, but I found this post.&lt;/span&gt; &lt;span class=""&gt;You saved me!&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/154633?ContentTypeID=1</link><pubDate>Fri, 26 Oct 2018 08:51:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:471823da-3ad7-4a73-b25d-0fc208b93866</guid><dc:creator>Norbert</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;Excellent catch!&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;am testing the fix in my non-stripped application. It has been running now without fault for an hour with ~40 advertisers nearby&lt;span&gt;&amp;nbsp;&lt;/span&gt;while&lt;span&gt;&amp;nbsp;&lt;/span&gt;the application w/o fix was failing after 2 minutes at most. So I am convinced that the bug is fixed. To be sure, I will keep the app running for the weekend.&lt;/p&gt;
&lt;p&gt;This is something to go into the next release of the SDK.&lt;/p&gt;
&lt;p&gt;Great work!&lt;/p&gt;
&lt;p&gt;Thanks a lot,&lt;/p&gt;
&lt;p&gt;Norbert&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/154353?ContentTypeID=1</link><pubDate>Wed, 24 Oct 2018 19:27:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8488cf99-8aec-44fd-a478-c5a1991ffd35</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Awesome ..&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/154351?ContentTypeID=1</link><pubDate>Wed, 24 Oct 2018 18:58:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f910977b-82f0-467d-aab5-5e7315ba8591</guid><dc:creator>eric-appion</dc:creator><description>&lt;p&gt;I had a related problem, reported in a private case, and this code change does fix it. Thanks Susheel!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/154246?ContentTypeID=1</link><pubDate>Wed, 24 Oct 2018 10:35:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc38be3b-8388-410f-8a38-dcf9356e40aa</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;found a race condition in nrf_sdh_freertos.c file&lt;/p&gt;
&lt;p&gt;softdevice task() tries to pull events from SD and then suspends the tasks unconditionally until the SD_EVT_IRQHandler resumes it.&lt;/p&gt;
&lt;p&gt;But, if the below happens&lt;/p&gt;
&lt;p&gt;nrf_sdh_evts_poll();&amp;nbsp;&lt;/p&gt;
&lt;p&gt;##### Interrupted by SD_EVT_IRQHandler&amp;nbsp;which does a TaskResume##&lt;/p&gt;
&lt;p&gt;### but when the context comes back to softdevice_task() it still suspends itself####&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;vTaskSuspend(NULL);&lt;/p&gt;
&lt;p&gt;###at this point we have lost the chance to enable the scanner again###&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;SOLUTION&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;replace&amp;nbsp; the task controls to TaskNotification as below&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void SD_EVT_IRQHandler(void)
{
     BaseType_t xYieldRequired;

     //xYieldRequired = xTaskResumeFromISR( m_softdevice_task );
     vTaskNotifyGiveFromISR(m_softdevice_task, &amp;amp;xYieldRequired);

     if( xYieldRequired == pdTRUE )
     {
         portYIELD_FROM_ISR(xYieldRequired);
     }
}


/* This function gets events from the SoftDevice and processes them. */
static void softdevice_task(void * pvParameter)
{
    NRF_LOG_DEBUG(&amp;quot;Enter softdevice_task.&amp;quot;);

    if (m_task_hook != NULL)
    {
        m_task_hook(pvParameter);
    }

    while (true)
    {
        nrf_sdh_evts_poll(); // Let the handlers run first, in case the EVENT occured before creating this task.
        //vTaskSuspend(NULL);

      (void) ulTaskNotifyTake(pdTRUE,         /* Clear the notification value before exiting (equivalent to the binary semaphore). */
                      portMAX_DELAY); /* Block indefinitely (INCLUDE_vTaskSuspend has to be enabled).*/

    }
}
&lt;/pre&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am pretty sure this will fix the problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/153594?ContentTypeID=1</link><pubDate>Fri, 19 Oct 2018 09:02:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40294f72-46a8-467b-a7e7-aa057a9094f2</guid><dc:creator>Norbert</dc:creator><description>&lt;p&gt;PM posted. Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/153421?ContentTypeID=1</link><pubDate>Thu, 18 Oct 2018 09:49:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2d8067f-9f90-448e-8c8c-7b9a076cd44b</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;you can attach your project link or send me a private message of the link. I can then review the architecture of your tasks and their priorities.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/153318?ContentTypeID=1</link><pubDate>Wed, 17 Oct 2018 15:31:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2faa9a3-915e-4fdd-98cf-b13e67ca5077</guid><dc:creator>Norbert</dc:creator><description>&lt;p&gt;Aryan,&lt;/p&gt;
&lt;p&gt;I would be happy to provide you the stripped-down test case, if you could spare the time to look into it. Just let me know how I can push a project to you.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/153317?ContentTypeID=1</link><pubDate>Wed, 17 Oct 2018 15:27:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af188532-8f26-4b8f-803e-88e8e7382282</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Norbert,&lt;/p&gt;
&lt;p&gt;The fact that your solution worked makes me believe stronger that this was a deadlock issue. You serialized the access using a binary semaphore and the problem went away, I cannot say with 100% certainty without understanding your different priority tasks and when they suspend and resume.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/153290?ContentTypeID=1</link><pubDate>Wed, 17 Oct 2018 14:43:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfc3731b-c679-4dce-b77d-30f137809e9f</guid><dc:creator>Norbert</dc:creator><description>&lt;p&gt;Not sure. As I said, I have stripped down the project to only one task (the one running the SD), so there cannot be a deadlock between tasks.&lt;/p&gt;
&lt;p&gt;My current workaround is to communicate the event to a lower-priority task using a binary semaphore and treat the event there. This takes only ~20us in the event handler and the problem goes away.&lt;/p&gt;
&lt;p&gt;However this does not satisfy me as I think there is still something wrong at the base.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/153284?ContentTypeID=1</link><pubDate>Wed, 17 Oct 2018 14:34:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3064cb6c-fe71-4a4c-b916-04f5759a3213</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="ngrunert"]So the probability of getting two reports coming in very close together is pretty high.[/quote]
&lt;p&gt;&amp;nbsp;This should not be a problem for the SD and I do not think is the reason for what you see.&lt;/p&gt;
&lt;p&gt;I think that you are seeing a deadlock somewhere in one of your threads. Hard to say where and why, but if there are any conditions where you are waiting for some flags set in another thread, then make sure that you have scoped out a possibility of having a deadlock there since these checks are not normally atomic.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Observer under FreeRTOS: Events stop coming after a few minutes.</title><link>https://devzone.nordicsemi.com/thread/152862?ContentTypeID=1</link><pubDate>Mon, 15 Oct 2018 11:59:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a8e341c-869d-4764-aa2e-374a172bae90</guid><dc:creator>Norbert</dc:creator><description>&lt;p&gt;Forgot to mention: I have a lot (&amp;gt;20) of advertisers running in the vicinity to stress my system. So the probability of getting two reports coming in very close together is pretty high.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>