<?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>Wake from deep sleep works while debugging but not when running standalone</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85317/wake-from-deep-sleep-works-while-debugging-but-not-when-running-standalone</link><description>I am having a similar issue to the person in this post where the wake from deep sleep on an interrupt sometimes works and sometimes doesn&amp;#39;t. But for me, it&amp;#39;s very consistent. 
 
 I enter sleep in two cases: 
 Case 1 works every time when the debugger</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 10 Mar 2022 18:35:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85317/wake-from-deep-sleep-works-while-debugging-but-not-when-running-standalone" /><item><title>RE: Wake from deep sleep works while debugging but not when running standalone</title><link>https://devzone.nordicsemi.com/thread/357508?ContentTypeID=1</link><pubDate>Thu, 10 Mar 2022 18:35:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a39ffba6-3827-4b2e-bc7c-88f3584d04cf</guid><dc:creator>Mark Q</dc:creator><description>&lt;p&gt;Further clarification from Andrew:&lt;br /&gt;&lt;br /&gt;&lt;em&gt;If I place the&amp;nbsp;bt_scan_stop() call after the printk() call, it doesn&amp;#39;t work.&amp;nbsp; So it seems that there needs to be a delay after calling&amp;nbsp;bt_scan_stop() before going to sleep if you want to be able to wake up.&amp;nbsp; That&amp;#39;s a bit odd, but we can work around that.&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake from deep sleep works while debugging but not when running standalone</title><link>https://devzone.nordicsemi.com/thread/357321?ContentTypeID=1</link><pubDate>Thu, 10 Mar 2022 07:49:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ddf724f-745c-4cc3-b9a6-9c147125ca28</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Ah, yes, sorry. There is a copy-paste error. It should have been:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;span&gt;It works for me if I take your example and call bt_scan_stop() on the on the first line in&amp;nbsp;go_to_sleep() (so line 56 in main.c).&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake from deep sleep works while debugging but not when running standalone</title><link>https://devzone.nordicsemi.com/thread/357279?ContentTypeID=1</link><pubDate>Wed, 09 Mar 2022 22:24:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d0cdbda-3307-4e68-aaf2-aa3ff77257e0</guid><dc:creator>andrew_alloy</dc:creator><description>&lt;p&gt;Line 56 is inside go_to_sleep().&amp;nbsp; Calling it iteratively doesn&amp;#39;t seem to make sense...I think you may have made a typo in your explanation?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake from deep sleep works while debugging but not when running standalone</title><link>https://devzone.nordicsemi.com/thread/357161?ContentTypeID=1</link><pubDate>Wed, 09 Mar 2022 13:04:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b13774e-335c-4147-b4cb-2717798ecf41</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;It works for me if I take your example and call&amp;nbsp;go_to_sleep() on the on the first line in&amp;nbsp;go_to_sleep() (so line 56 in main.c).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake from deep sleep works while debugging but not when running standalone</title><link>https://devzone.nordicsemi.com/thread/356992?ContentTypeID=1</link><pubDate>Tue, 08 Mar 2022 20:48:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54ab6449-4824-42a8-b490-9d2d34def0cc</guid><dc:creator>andrew_alloy</dc:creator><description>&lt;p&gt;Great.&amp;nbsp; I had tried to do that unsuccessfully but I was guessing what I should do.&lt;/p&gt;
&lt;p&gt;Would you be able to share the cleanup code that worked for you?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake from deep sleep works while debugging but not when running standalone</title><link>https://devzone.nordicsemi.com/thread/356989?ContentTypeID=1</link><pubDate>Tue, 08 Mar 2022 20:34:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:478f8dfb-b61f-42b0-9e4e-239e1c779da4</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Andrew,&lt;/p&gt;
&lt;p&gt;It seems wakeup from system off works properly after cleaning up properly before entering system off (stopping BLE activity etc.), and that is anyway a good idea. I am not able to explain why that is needed though, but I have unfortunately not been able to digg properly into this yet.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake from deep sleep works while debugging but not when running standalone</title><link>https://devzone.nordicsemi.com/thread/356735?ContentTypeID=1</link><pubDate>Tue, 08 Mar 2022 02:01:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fe56bf0-7c67-4969-8202-f5a30f314d25</guid><dc:creator>andrew_alloy</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Do you have an update?&lt;/p&gt;
&lt;p&gt;Andrew&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake from deep sleep works while debugging but not when running standalone</title><link>https://devzone.nordicsemi.com/thread/356355?ContentTypeID=1</link><pubDate>Fri, 04 Mar 2022 14:34:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a83aa47-5399-400c-8dd7-669baf03c69f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the sample. I see the same in my end. I will look more into it and get back to you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake from deep sleep works while debugging but not when running standalone</title><link>https://devzone.nordicsemi.com/thread/356158?ContentTypeID=1</link><pubDate>Thu, 03 Mar 2022 21:50:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af937b63-9a84-4027-b7d3-839fc37f5896</guid><dc:creator>andrew_alloy</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I stripped down a version to post here.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Be sure to use SDK version 1.8.0.&amp;nbsp; Open the project from the central folder.&lt;/p&gt;
&lt;p&gt;Run it and wait for 5 seconds after you see the message &amp;quot;Scanning successfully started&amp;quot; on the UART console.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;After 5 seconds you should see:&lt;/p&gt;
&lt;pre&gt;Scan timer expired&lt;br /&gt;&lt;br /&gt;I: e: sleep_event Sleep Event&lt;br /&gt;&lt;br /&gt;Going to system off...&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;That&amp;#39;s when you need to connect P0.27 (top left on dev kit) to 3.3V to wake it up.&lt;/p&gt;
&lt;p&gt;With the debugger connected you will see it boot up again. Without the debugger connected, you will not.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/4034.example.zip"&gt;devzone.nordicsemi.com/.../4034.example.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake from deep sleep works while debugging but not when running standalone</title><link>https://devzone.nordicsemi.com/thread/356123?ContentTypeID=1</link><pubDate>Thu, 03 Mar 2022 16:06:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3a3c051-fa70-4869-ae63-dd0774e34f34</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;I see you are running this on a DK. Can you upload your (preferably minimal failing) project here along with instructions on how to run it to reproduce the issue?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake from deep sleep works while debugging but not when running standalone</title><link>https://devzone.nordicsemi.com/thread/355926?ContentTypeID=1</link><pubDate>Thu, 03 Mar 2022 02:19:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29c0dd58-3622-4df2-8e27-d170b55b4e4c</guid><dc:creator>andrew_alloy</dc:creator><description>&lt;p&gt;I&amp;#39;ve tried calling the same pin configuration functions right before the call to pm_power_state_force just to be absolutely sure&amp;nbsp;but it still fails when the debugger is not attached.&lt;/p&gt;
&lt;p&gt;I also tried having it sleep from the main loop rather than an event callback but that didn&amp;#39;t work either.&lt;/p&gt;
&lt;p&gt;I see that the code executed is:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;NRF_STATIC_INLINE void nrf_power_system_off(NRF_POWER_Type * p_reg)
{
    p_reg-&amp;gt;SYSTEMOFF = POWER_SYSTEMOFF_SYSTEMOFF_Enter;
    __DSB();

    /* Solution for simulated System OFF in debug mode */
    while (true)
    {
        __WFE();
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Call stack:&amp;nbsp;&lt;img height="121" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1646273881989v1.png" width="842" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So in debug mode the SYSTEMOFF register being set to 1 doesn&amp;#39;t do anything, and it executes __WFE() to simulate system off mode.&amp;nbsp; I can recover from that with my wakeup pin.&amp;nbsp; But in standalone operation it never comes back on.&amp;nbsp; Something is fishy but I can&amp;#39;t think what it could be.&lt;/p&gt;
&lt;p&gt;I also tried changing it to active low instead of active high but that didn&amp;#39;t make a difference.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake from deep sleep works while debugging but not when running standalone</title><link>https://devzone.nordicsemi.com/thread/355905?ContentTypeID=1</link><pubDate>Wed, 02 Mar 2022 17:58:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e22f0fcb-99e0-42c7-bb27-bb6770b43f47</guid><dc:creator>andrew_alloy</dc:creator><description>&lt;p&gt;Thank you.&amp;nbsp; That makes sense it can&amp;#39;t really sleep while debugging.&amp;nbsp; But it seems to do a good job of pretending, as it does reboot when I &amp;quot;wake&amp;quot; it.&amp;nbsp; So I suppose it&amp;#39;s going through the motions but not really shutting down the power, understandably.&lt;/p&gt;
&lt;p&gt;The wakeup pin is only configured by those lines of code in one place at startup and never changed again.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m struggling to think what could be different when running &amp;quot;for real&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake from deep sleep works while debugging but not when running standalone</title><link>https://devzone.nordicsemi.com/thread/355836?ContentTypeID=1</link><pubDate>Wed, 02 Mar 2022 13:38:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49c7fe31-09b1-4419-8d1b-a3f85c685724</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The nRF is not able to enter system OFF mode while debugging, so in that case it does not actually happen.&amp;nbsp;But without a debugger this should work, as it looks like you have correctly configured the wakeup pin. Could it be that in Case 1 (the failing case), you reconfigure the wakeup pin or similar, so that it is no longer configured as &lt;em&gt;sense&lt;/em&gt;? If that is not it, perhaps you can see if you can reproduce this with a minimal sample on a DK so that I can test on my end?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>