<?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>Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65415/interrupts-not-waking-freertos-up-in-tickless-mode</link><description>Hi 
 I&amp;#39;m working with FreeRTOS with Tickless (RTC) and I was wondering what one should do in order to avoid the FreeRTOS Idle Task to be waken up every time an Interrupt Service Routine has completed the execution. 
 In Cortex-M4 the SLEEPONEXIT flag</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 10 Sep 2020 12:53:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65415/interrupts-not-waking-freertos-up-in-tickless-mode" /><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/268986?ContentTypeID=1</link><pubDate>Thu, 10 Sep 2020 12:53:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4896452a-f4cf-452c-89fe-7e4ac17c779c</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="dfer"]any Task switch sets the Event flag with __SEV, see&amp;nbsp;&lt;span style="background-color:rgb(255, 255, 255);"&gt;portYIELD&lt;/span&gt; macro (why? I guess &lt;span style="background-color:rgb(255, 255, 255);"&gt;&amp;nbsp;SCB-&amp;gt;ICSR = SCB_ICSR_PENDSVSET_Msk&lt;/span&gt; would be enough, the PendSV interrupt would be set pending and the event flag is set pending, see SEVONPEND)&amp;nbsp;[/quote]
&lt;p&gt;You are right. I think SEV is not needed here, but I think it is a harmless addition. SEVONPEND bit set does not need SEV to be added explicitly after pending this to ICSR.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="dfer"]So the chances that we come to&amp;nbsp;vPortSuppressTicksAndSleep with the event flag already set are high. This event flag setting has happened most probably in the past and the scheduler has already served the necessary task switches.&amp;nbsp;[/quote]
&lt;p&gt;Agreed...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="dfer"]After this, a masked application interrupt sets the event flag but the ISR is &lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;not&lt;/strong&gt; &lt;/span&gt;executed.&amp;nbsp;[/quote]
&lt;p&gt;Agreed, because of SEVONPEND.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="dfer"]After sd_nvic_critical_region_enter, the function&amp;nbsp;eTaskConfirmSleepModeStatus is called, which will abort the sleep process if a task or a task switch is pending (see served ISR above(*) ) - so here I see no problems.[/quote]
&lt;p&gt;&amp;nbsp;Agreed.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="dfer"]If an interrupt happens after&amp;nbsp;eTaskConfirmSleepModeStatus, it will set the event flag and the next WFE will be skipped - here I see no problem.[/quote]
&lt;p&gt;&amp;nbsp;Agreed.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="dfer"]If an interrupt occurs after WFE, the normal wake up prcedure will happen and again here I see no problems.[/quote]
&lt;p&gt;&amp;nbsp;Agreed.&lt;/p&gt;
&lt;p&gt;i agree with you Davide, i missed to see the check&amp;nbsp;&lt;span&gt;eTaskConfirmSleepModeStatus. Should be safe to clear the event just before entering the critical section.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/268790?ContentTypeID=1</link><pubDate>Wed, 09 Sep 2020 14:32:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dea95bd-6a15-4c03-81e6-1e77427b66b1</guid><dc:creator>dfer</dc:creator><description>&lt;p&gt;I feel we are a bit drifting from each other away.&lt;/p&gt;
&lt;p&gt;So to recap:&lt;/p&gt;
&lt;p&gt;any Task switch sets the Event flag with __SEV, see&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;portYIELD&lt;/span&gt; macro (why? I guess &lt;span style="background-color:#ffffff;"&gt;&amp;nbsp;SCB-&amp;gt;ICSR = SCB_ICSR_PENDSVSET_Msk&lt;/span&gt; would be enough, the PendSV interrupt would be set pending and the event flag is set pending, see SEVONPEND)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;the tick interrupt sets the event flag with __SEV (why? see comment above)&lt;/p&gt;
&lt;p&gt;any Interrupt sets the Event flag automatically (see SEVONPEND)&lt;/p&gt;
&lt;p&gt;So the chances that we come to&amp;nbsp;vPortSuppressTicksAndSleep with the event flag already set are high. This event flag setting has happened most probably in the past and the scheduler has already served the necessary task switches.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now, resetting the event flag &lt;strong&gt;&lt;span style="text-decoration:underline;"&gt;before&lt;/span&gt; &lt;/strong&gt;the&amp;nbsp;sd_nvic_critical_region_enter&amp;nbsp;function call should be ok, because the ISR of an interrupt happening just before &lt;span&gt;sd_nvic_critical_region_enter&lt;/span&gt;&lt;span&gt;&amp;nbsp;would be anyway invoked. If this ISR(*) triggers a FreeRTOS task, the scheduler would set that task to Ready.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Now the&amp;nbsp;sd_nvic_critical_region_enter&amp;nbsp; is called.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;After this, a masked application interrupt sets the event flag but the ISR is &lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;not&lt;/strong&gt; &lt;/span&gt;executed.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;After sd_nvic_critical_region_enter, the function&amp;nbsp;eTaskConfirmSleepModeStatus is called, which will abort the sleep process if a task or a task switch is pending (see served ISR above(*) ) - so here I see no problems.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If an interrupt happens after&amp;nbsp;eTaskConfirmSleepModeStatus, it will set the event flag and the next WFE will be skipped - here I see no problem.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If an interrupt occurs after WFE, the normal wake up prcedure will happen and again here I see no problems.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/268781?ContentTypeID=1</link><pubDate>Wed, 09 Sep 2020 13:48:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abaf40d0-7a84-4e96-9fc0-43728c982eb8</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I see your point but&amp;nbsp;&lt;/p&gt;
[quote user="dfer"]The Event flag is Always set because either a Task has been Yielded or an Interrupt has occured while the processor was not sleeping. The first time&amp;nbsp;&lt;span style="background-color:rgb(255, 255, 255);"&gt;__WFE();&lt;/span&gt; is executed will almost always go Forward without sleeping, causing another call to&amp;nbsp;&lt;span style="background-color:rgb(255, 255, 255);"&gt;vPortSuppressTicksAndSleep&lt;/span&gt; form FreeRTOS.[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I see that the first one (Event set due to task yield) is not a problem, since the scheduler needs to be called before sleeping which is correct behavior that the sleep is aborted. You should not at this point try to clear that event that is the result of any state change of the task, this could cause deadlocks.&lt;/p&gt;
&lt;p&gt;But I see that you have a point that if there is an interrupt&amp;nbsp; happening inbetween the critical section, then the vPortSuppressTicksAndSleep code unnecessarily exits the sleep routine.&lt;/p&gt;
&lt;p&gt;Wow, this is a good find. I am sorry that i missed to see the details of your previous reply. An interrupt could occur even while in critical section setting the event flag, so I am not sure that just clearing the event before entering critical section helps that much??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/268741?ContentTypeID=1</link><pubDate>Wed, 09 Sep 2020 12:15:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1c5e89c-36dd-447a-b638-63b4c79572ec</guid><dc:creator>dfer</dc:creator><description>&lt;p&gt;Yes as said it you set a debug port before going to sleep and then reset ti immediately after WFE you&amp;#39;ll see that the function is always executed twice.&lt;/p&gt;
&lt;p&gt;Back to your comment &amp;quot;&lt;span style="background-color:#ffffff;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;Your original suggestion to have __SEV; __WFE before just entering the critical_section is unnecessary since an event/interrupt can happen just after that.&lt;/span&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;this isn&amp;#39;t right, since I would do the SEV/WFE before&amp;nbsp;&lt;span style="background-color:#ffffff;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="background-color:#ffffff;color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;sd_nvic_critical_region_enter&lt;/span&gt; and later I would call only WFE (not SEV) thus no interrupts/events would be lost. If an interrupt occurs after&amp;nbsp;&lt;span style="background-color:#ffffff;color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;sd_nvic_critical_region_enter&lt;span style="color:#007600;"&gt;, it would set the event flag, thus preventing the processor to go to sleep at the next WFE&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#007600;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/268736?ContentTypeID=1</link><pubDate>Wed, 09 Sep 2020 11:59:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9982cf79-3f05-477a-bd33-2cf89e20ae9c</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;You are right, that seems risky. But I think I am deviating a bit from the original discussion.&lt;/p&gt;
&lt;p&gt;Your original suggestion to have __SEV; __WFE before just entering the critical_section is unnecessary since an event/interrupt can happen just after that.&lt;/p&gt;
&lt;p&gt;Do you have any benchmark results that can show that the current sleep implementation makes it execute twice before actually going to sleep?&lt;/p&gt;
&lt;p&gt;If that is really happening, this discussion would be very serious. Initial tests i did does not show what you wrote. But i have not tested extensively.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/268698?ContentTypeID=1</link><pubDate>Wed, 09 Sep 2020 09:55:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:487fb63f-f001-4702-b191-be2b0bd5e330</guid><dc:creator>dfer</dc:creator><description>&lt;p&gt;No I didn&amp;#39;t mean that. I meant between&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;sd_nvic_critical_region_enter&lt;/span&gt; and __SEV()&lt;/p&gt;
&lt;p&gt;In my opinion this Interrupt would be &amp;quot;lost&amp;quot;. Yes, the pending bit would stay set, but the Idle Task wouldn&amp;#39;t be woken up after the second __WFE because the Event flag is cleared.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t think that the Event flag would be set again if the Interrupt is still pending, I think it is a one shot Operation (set Interrupt pending -&amp;gt; set Event flag, but only once).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/268689?ContentTypeID=1</link><pubDate>Wed, 09 Sep 2020 09:23:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14a182bf-6e19-4e1a-9602-074a58df49d4</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I would recommend you to &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/490/how-do-you-put-the-nrf51822-chip-to-sleep"&gt;read &lt;/a&gt;this thread.&lt;/p&gt;
[quote user="dfer"] so a possible interrupt could have happened in between and we would clear the related event flag before going to sleep.[/quote]
&lt;p&gt;&amp;nbsp;The FreeRTOS port of Nordic enables &lt;a href="https://developer.arm.com/documentation/dui0497/a/the-cortex-m0-instruction-set/miscellaneous-instructions/wfe"&gt;SEVONPEND&lt;/a&gt;, so If the interrupt happens between the SEV and WFE, then you are right that the event is cleared, but the pend bit is set after one more clock cycle, so that should be ok as far as i can see.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/268028?ContentTypeID=1</link><pubDate>Fri, 04 Sep 2020 11:10:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd943b96-b6b6-4489-892e-4050e157140e</guid><dc:creator>dfer</dc:creator><description>&lt;p&gt;I am not really sure but I see a danger that, if i do as you suggest, an event could be lost.&lt;/p&gt;
&lt;p&gt;The sequence disables the application interrupts (&lt;span style="background-color:#ffffff;"&gt;sd_nvic_critical_region_enter&lt;/span&gt;), then asks FreeRTOS if there is a task pending, and then sets the RTC up.&lt;/p&gt;
&lt;p&gt;Only after this, the event flag would be cleared. But the interrupts are already disabled, so a possible interrupt could have happened in between and we would clear the related event flag before going to sleep.&lt;/p&gt;
&lt;p&gt;This is the documentation I&amp;#39;ve found About WFE:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;WFE
Wait For Event.
Syntax
WFE{cond}
where:
cond Is an optional condition code, see Conditional execution on page 3-18.
Operation
WFE is a hint instruction.
If the event register is 0, WFE suspends execution until one of the following events occurs:
• an exception, unless masked by the exception mask registers or the current priority level
• an exception enters the Pending state, if SEVONPEND in the System Control Register is set
• a Debug Entry request, if Debug is enabled
• an event signaled by a peripheral or another processor in a multiprocessor system using 
the SEV instruction.
If the event register is 1, WFE clears it to 0 and returns immediately.&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/268012?ContentTypeID=1</link><pubDate>Fri, 04 Sep 2020 10:31:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2d8ef77-4285-4fb0-8cfd-8b54ba843b8f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I think __SEV;__WFE;__WFE sequence is a safe and well tested sequence to make the chip go to sleep on the second __WFE. Ofcourse there is a time chance that a new event flag is set after the execution of __SEV and __WFE but that is something we need to live with.&lt;/p&gt;
&lt;p&gt;I am not sure why introducing __SEV;__WFE in the place you suggest improves the possibility of clearing the event flag. There are many instructions from this point to the actual next WFE where there is a great possibility for a new event to enter and raise the event flag.&lt;/p&gt;
&lt;p&gt;In this function can you test the performance by not using sd_app_evt_wait and using __SEV;__WFE;__WFE instead of that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/267992?ContentTypeID=1</link><pubDate>Fri, 04 Sep 2020 08:59:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5314573-a864-458d-b636-418c94a9ff06</guid><dc:creator>dfer</dc:creator><description>&lt;p&gt;Or even better here:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    /* Make sure the SysTick reload value does not overflow the counter. */
    if ( xExpectedIdleTime &amp;gt; portNRF_RTC_MAXTICKS - configEXPECTED_IDLE_TIME_BEFORE_SLEEP )
    {
        xExpectedIdleTime = portNRF_RTC_MAXTICKS - configEXPECTED_IDLE_TIME_BEFORE_SLEEP;
    }

    __SEV(); __WFE();// reset the event flag, if an interrupt has occurred and has triggered a task it will be caught in eTaskConfirmSleepModeStatus

    /* Block all the interrupts globally */
#ifdef SOFTDEVICE_PRESENT
    do{
        uint8_t dummy = 0;
        uint32_t err_code = sd_nvic_critical_region_enter(&amp;amp;dummy);
        APP_ERROR_CHECK(err_code);
    }while (0);
#else
    __disable_irq();
#endif

    enterTime = nrf_rtc_counter_get(portNRF_RTC_REG);

    if ( eTaskConfirmSleepModeStatus() != eAbortSleep )
    {&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/267979?ContentTypeID=1</link><pubDate>Fri, 04 Sep 2020 08:33:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66f68133-23ea-430d-9ed7-b65870715a68</guid><dc:creator>dfer</dc:creator><description>&lt;p&gt;Hi Susheel&lt;/p&gt;
&lt;p&gt;after several attempts it seems that the SPEEPONEXIT functionality is somehow prevented by the softdevice.&lt;/p&gt;
&lt;p&gt;Everything gets stuck after a time and I cannot understand why.&lt;/p&gt;
&lt;p&gt;I would have another suggestion that would prevent the&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;vPortSuppressTicksAndSleep&lt;/span&gt; to always be executed twice before managing to go to sleep:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    /* Make sure the SysTick reload value does not overflow the counter. */
    if ( xExpectedIdleTime &amp;gt; portNRF_RTC_MAXTICKS - configEXPECTED_IDLE_TIME_BEFORE_SLEEP )
    {
        xExpectedIdleTime = portNRF_RTC_MAXTICKS - configEXPECTED_IDLE_TIME_BEFORE_SLEEP;
    }
    /* Block all the interrupts globally */
#ifdef SOFTDEVICE_PRESENT
    do{
        uint8_t dummy = 0;
        uint32_t err_code = sd_nvic_critical_region_enter(&amp;amp;dummy);
        APP_ERROR_CHECK(err_code);
    }while (0);
#else
    __disable_irq();
#endif

    __SEV(); __WFE();// reset the event flag, if an interrupt has occured and has triggered a task it will be cought in eTaskConfirmSleepModeStatus

    enterTime = nrf_rtc_counter_get(portNRF_RTC_REG);

    if ( eTaskConfirmSleepModeStatus() != eAbortSleep )
    {
        TickType_t xModifiableIdleTime;
        TickType_t wakeupTime = (enterTime + xExpectedIdleTime) &amp;amp; portNRF_RTC_MAXTICKS;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;__SEV(); __WFE();&lt;/span&gt; sequence resets the Event flag. If it was set because an Interrupt has occured, and this Interrupt has triggered a FreeRTOS Task, the subsequent&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;eTaskConfirmSleepModeStatus&lt;/span&gt; would detect this and Abort the Sleep sequence.&lt;/p&gt;
&lt;p&gt;The Event flag is Always set because either a Task has been Yielded or an Interrupt has occured while the processor was not sleeping. The first time&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;__WFE();&lt;/span&gt; is executed will almost always go Forward without sleeping, causing another call to&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;vPortSuppressTicksAndSleep&lt;/span&gt; form FreeRTOS.&lt;/p&gt;
&lt;p&gt;What do you think about this? I&amp;#39;ve tested it quickly and it seems working.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/267744?ContentTypeID=1</link><pubDate>Thu, 03 Sep 2020 07:09:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c60fe65d-726d-4f84-b9e6-ae147def3585</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I am not sure Davide, it should work, it is an ARM feature and does not seem to be optional.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/267641?ContentTypeID=1</link><pubDate>Wed, 02 Sep 2020 13:22:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00685549-b49d-4b0f-9c93-45f571cb8f41</guid><dc:creator>dfer</dc:creator><description>&lt;p&gt;Hi Susheel do you have any idea why the&amp;nbsp;&lt;span style="background-color:#ffffff;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;SLEEPONEXIT &lt;/span&gt; functionality doesn&amp;#39;t work?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/267248?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 12:48:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:927a5dbc-8f2d-4917-8dad-7092af2d40bf</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="dfer"]I forgot to mention that the tick interrupt will always reset the&amp;nbsp;&lt;span style="background-color:rgb(255, 255, 255);color:rgb(17, 23, 26);font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;SLEEPONEXIT&lt;/span&gt;&lt;span style="background-color:rgb(255, 255, 255);color:rgb(17, 23, 26);float:none;font-family:&amp;#39;GT Eesti&amp;#39;, Helvetica, Arial, sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt; &lt;/span&gt;flag (a Task switch is Always necessary in tickless mode at this Point).[/quote]
&lt;p&gt;&amp;nbsp;This will be a good failsafe mechanism. I think it should work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/267243?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 12:39:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79f3344d-f87f-4619-8051-abb7b26ff852</guid><dc:creator>dfer</dc:creator><description>&lt;p&gt;In my other system I have about 30 tasks.&lt;/p&gt;
&lt;p&gt;I forgot to mention that the tick interrupt will always reset the&amp;nbsp;&lt;span style="background-color:#ffffff;color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;SLEEPONEXIT&lt;/span&gt;&lt;span style="background-color:#ffffff;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt; &lt;/span&gt;flag (a Task switch is Always necessary in tickless mode at this Point).&lt;/p&gt;
&lt;p&gt;I cannot imagine why it shouldn&amp;#39;t work, the other System runs since months with this method&amp;hellip;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/267236?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 12:23:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fc492cb-7684-4a49-8a14-b4740efd71e3</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Davide,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;[quote user="dfer"][/quote]&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s say I call&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;xTaskGenericNotifyFromISR&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The function delivers the flag&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;pxHigherPriorityTaskWoken&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;I then check this flag in my ISR and, if set, I reset the&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;SLEEPONEXIT&lt;/span&gt; flag. This ensures that the Idle task is woken up in order to perform the book keeping you were talking about.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;This sounds like a reasonable thing to do, if there are only two tasks in your ssytem (the one giving notification and the other receiving it). But if there are other tasks, and if there is a dependency (inter task) between them, then your idea might not work.&lt;/p&gt;
&lt;p&gt;If only two tasks, then I think this will work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/267232?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 12:06:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:353b9157-2a5b-4447-ab38-bcf9255443d1</guid><dc:creator>dfer</dc:creator><description>&lt;p&gt;My example is taken from generic code, but basically I reset&amp;nbsp;&lt;span style="background-color:#ffffff;color:#11171a;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;SLEEPONEXIT&lt;/span&gt;&lt;span style="background-color:#ffffff;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt; &lt;/span&gt;every time I&amp;#39;m sure a Task switch has to be performed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/267226?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 12:00:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d051c03-7fe1-40cc-86ff-091ae603e9b0</guid><dc:creator>dfer</dc:creator><description>&lt;p&gt;Thank you Susheel&lt;/p&gt;
&lt;p&gt;waking up the Idle task needs energy. If I could avoid it then I would be very happy.&lt;/p&gt;
&lt;p&gt;I have another project with a Cortex-M4 where I&amp;#39;ve done the folllowing:&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s say I call&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;xTaskGenericNotifyFromISR&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The function delivers the flag&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;pxHigherPriorityTaskWoken&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;I then check this flag in my ISR and, if set, I reset the&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;SLEEPONEXIT&lt;/span&gt; flag. This ensures that the Idle task is woken up in order to perform the book keeping you were talking about.&lt;/p&gt;
&lt;p&gt;If the&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;pxHigherPriorityTaskWoken&lt;/span&gt; flag is not set, I let the&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;SLEEPONEXIT&lt;/span&gt;&lt;span style="background-color:#ffffff;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt; &lt;/span&gt;flag set and the processor will go directly in Sleep after the ISR, thus saving useless energy, because the Idle Task would do just nothing.&lt;/p&gt;
&lt;p&gt;This is very needed also because, if you Instrument the&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;vPortSuppressTicksAndSleep&lt;/span&gt;, you will notice that it is executed always twice before it can go really in sleep mode. This is energy that I would like to save.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Interrupts not waking FreeRTOS up in Tickless mode</title><link>https://devzone.nordicsemi.com/thread/267212?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 11:47:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3664a77-18e0-45d9-80c7-d6cf0e0ad6a0</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Davide,&lt;/p&gt;
&lt;p&gt;The tickless idle sleep wakeup only processes to see if there any other pending interrupts to be processed. If there are and if they are lower in priority than the kernel itself, then idle task needs to do the book keeping.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Enabling SLEEPONEXIT would keep the state machine of the kernel stuck in the idle loop for ever and might cause asserts in the future. What is it you are trying to achieve exactly? why is the post processing of idle task wakeup seems to be very expensive in your usecase?&lt;/p&gt;
&lt;div style="left:-38px;top:48.2585px;"&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>