<?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>How to avoid going back to sleep after waking up from Timer interrupt?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96639/how-to-avoid-going-back-to-sleep-after-waking-up-from-timer-interrupt</link><description>Hi 
 I am using nrRF52832 S132, I have a timer interrupt which wakes up the processor from sleep periodically. 
 In that timeout interrupt even handler, I queue and event which I wish to be executed from main loop using the scheduler (I don&amp;#39;t want to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 Feb 2023 12:50:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96639/how-to-avoid-going-back-to-sleep-after-waking-up-from-timer-interrupt" /><item><title>RE: How to avoid going back to sleep after waking up from Timer interrupt?</title><link>https://devzone.nordicsemi.com/thread/410078?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2023 12:50:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ab0eb51-d426-45a2-9ad9-98e4d808779f</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Because it just woke up to go to sleep again in that case, so you should only have one entry to sleep (which you now have).&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to avoid going back to sleep after waking up from Timer interrupt?</title><link>https://devzone.nordicsemi.com/thread/410065?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2023 12:22:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f5aa92a-8d6c-4e3d-852e-b08c6e384b85</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;Yes, That was the case,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But why would that cause what I described?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to avoid going back to sleep after waking up from Timer interrupt?</title><link>https://devzone.nordicsemi.com/thread/410058?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2023 12:02:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66bce512-6d8b-4b33-9e94-d63cf998ceb1</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;nrf_pwr_mgmt_run() is a wrapper around&amp;nbsp;sd_app_evt_wait() so that is fine. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(I suspect you were using both&amp;nbsp;nrf_pwr_mgmt_run() and&amp;nbsp;sd_app_evt_wait() in your while loop previously then?)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to avoid going back to sleep after waking up from Timer interrupt?</title><link>https://devzone.nordicsemi.com/thread/409939?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2023 17:54:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:063b7f60-53d1-4637-85c2-f22412485cfb</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I do have softdevice enabled,&amp;nbsp;I am using&amp;nbsp;nrf_pwr_mgmt_run(), and it seems to go to sleep just fine, so why is the&amp;nbsp;sd_app_evt_wait() necessary? do they not serve the same function?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to avoid going back to sleep after waking up from Timer interrupt?</title><link>https://devzone.nordicsemi.com/thread/409916?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2023 15:33:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb3f3f27-75f3-4bfb-869e-d2017563b768</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You should be using&amp;nbsp;&lt;span&gt;sd_app_evt_wait() to go to sleep (when you have a softdevice enabled), however sd_app_evt_wait() should only be called one place: in the while-loop in main. Do not use _WFE() or _SEV() if you have a softdevice enabled.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to avoid going back to sleep after waking up from Timer interrupt?</title><link>https://devzone.nordicsemi.com/thread/409852?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2023 12:38:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22a0ec30-660c-4647-ae6e-bd13a4856f4a</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;Hi Kenneth&lt;/p&gt;
&lt;p&gt;I further investigate and compared, the problem seems to be me calling the function -&amp;nbsp;sd_app_evt_wait();&lt;/p&gt;
&lt;p&gt;I removed it and now it works. I also checked my sleep current consumption and it seems to be as low as before&lt;/p&gt;
&lt;p&gt;So I am not sure why I place the&amp;nbsp;&lt;span&gt;sd_app_evt_wait() there in the first place, nor do I know why would it cause the issue I described.&lt;/span&gt;&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: How to avoid going back to sleep after waking up from Timer interrupt?</title><link>https://devzone.nordicsemi.com/thread/409790?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2023 10:08:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fd855c3-3942-4475-aafa-bea7244a5564</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;This is one of those issues I would expect to occur infrequently, in other words it may sometimes happen if the interrupt event handler is called right before the while-loop in main want to go to idle (sleep), but if it happens continously I would likely have looked at your while-loop and compared it with the ble peripheral examples. Edit: Maybe even consider a 1us delay on wakeup from idle in main() before checking flags etc and going back to idle.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>