<?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>__WFE() returned even if there was no event. Can you help?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/81961/__wfe-returned-even-if-there-was-no-event-can-you-help</link><description>nRF52832, SDK 13.0, SD 132, CMSIS RTOS, 
 
 Have a question about CPU events. See below code. 
 
 
 for (; ; ) 
 { 
 evt = osMessageGet(main_msgBox, osWaitForever); 
 /* Processing the message */ 
 ........................................... 
 __set_FPSCR</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Jun 2023 09:18:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/81961/__wfe-returned-even-if-there-was-no-event-can-you-help" /><item><title>RE: __WFE() returned even if there was no event. Can you help?</title><link>https://devzone.nordicsemi.com/thread/428662?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2023 09:18:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6612ec10-9a53-4016-bb6e-cd24faa79210</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;__WFE() should&amp;nbsp;not be called directly in Zephyr. Instead, you should let your program return to the idle thread when there is no more work to do (see&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/kernel/services/threads/system_threads.html#system-threads"&gt;System Threads&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;Note that masked interrupts can also trigger wakeup.&amp;nbsp;&lt;a id="" href="https://developer.arm.com/documentation/dui0552/a/the-cortex-m3-processor/power-management/wakeup-from-sleep-mode"&gt;https://developer.arm.com/documentation/dui0552/a/the-cortex-m3-processor/power-management/wakeup-from-sleep-mode&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: __WFE() returned even if there was no event. Can you help?</title><link>https://devzone.nordicsemi.com/thread/428650?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2023 09:01:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de6b52b7-f083-418e-9eae-c38af61c6640</guid><dc:creator>thang47</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1685609986212v2.png"&gt;/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1685609986212v2.png&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;When I use the command:&lt;br /&gt;__SEV();&lt;br /&gt;__WFE();&lt;br /&gt;__WFE();&lt;br /&gt; to enter sleep mode. Then it wakes up every 4 minutes, even though no interrupt occurs&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: __WFE() returned even if there was no event. Can you help?</title><link>https://devzone.nordicsemi.com/thread/428645?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2023 08:42:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c6ddb2e-418c-43fc-900d-1ac83161de06</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Please describe your setup and&amp;nbsp;the exact problem you are facing.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: __WFE() returned even if there was no event. Can you help?</title><link>https://devzone.nordicsemi.com/thread/428632?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2023 08:06:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77482f4c-5618-4f90-a72e-9744d65dbf71</guid><dc:creator>thang47</dc:creator><description>&lt;p&gt;Hi, I also had the same problem. Don&amp;#39;t know if you have solved it yet?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: __WFE() returned even if there was no event. Can you help?</title><link>https://devzone.nordicsemi.com/thread/340222?ContentTypeID=1</link><pubDate>Tue, 23 Nov 2021 05:41:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54dca6fb-af7f-48e7-92f7-a88743b22a53</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Interrupts which are enabled will be serviced immediately after wakeup and will therefore never be read as pending from the main context. If you want that, you either have to mask or disable your interrupt(s). &lt;/p&gt;
&lt;p&gt;e.g.,&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;__disable_irq();
__WFI();

for (int8 i=-15; i&amp;lt;39; i++)
{

if (NVIC_GetPendingIRQ(i) == 1)
    NRF_LOG_ERROR (&amp;quot;Pending IRQ = %d\r\n&amp;quot;, i);
}
__enable_irq(); // Allow interrupts to be serviced again&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: __WFE() returned even if there was no event. Can you help?</title><link>https://devzone.nordicsemi.com/thread/340206?ContentTypeID=1</link><pubDate>Tue, 23 Nov 2021 00:33:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b051e1eb-4709-4148-bfa5-d3888851af1c</guid><dc:creator>joojoo5</dc:creator><description>&lt;p&gt;To Vidar,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for your comments.&lt;/p&gt;
&lt;p&gt;And, I tried&amp;nbsp; both __SEV(); __WFE(); __WFE(); and __WFE(); __SEV(); __WFE(); but unfortunately it didn&amp;#39;t work.&lt;/p&gt;
&lt;p&gt;And, I tried __WFI() as well but no luck.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As you can see my original question, after __WFE() there is no pending IRQ.&lt;/p&gt;
&lt;p&gt;I still don&amp;#39;t understand why it went out from the __WFE() or series of __WFE() or __WFI().&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I think that is the key issue here.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please assist.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: __WFE() returned even if there was no event. Can you help?</title><link>https://devzone.nordicsemi.com/thread/340056?ContentTypeID=1</link><pubDate>Mon, 22 Nov 2021 12:29:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2329462b-af57-4015-898a-d3845edfa37e</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The __WFE instruction needs to be executed twice to put the system in sleep after an interrupt has been serviced, please see this answer by Anders here in this post for more details: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/490/how-do-you-put-the-nrf51822-chip-to-sleep/2571#2571"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/490/how-do-you-put-the-nrf51822-chip-to-sleep/2571#2571&lt;/a&gt;. It looks like a __WFI might be better suited for your current implementation.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>