<?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>always automatic wakeup after entering SYSTEM OFF mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80699/always-automatic-wakeup-after-entering-system-off-mode</link><description>Hi everyone, 
 I wanna implement the wakeup from SYSTEM OFF by button. The project is based on the ble_app_uart example. After receiving a command from BLE, nrf will go to SYSTEM OFF , the code is here: 
 Every time it goes to OFF mode, it will automatically</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 30 Oct 2021 01:15:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80699/always-automatic-wakeup-after-entering-system-off-mode" /><item><title>RE: always automatic wakeup after entering SYSTEM OFF mode</title><link>https://devzone.nordicsemi.com/thread/336744?ContentTypeID=1</link><pubDate>Sat, 30 Oct 2021 01:15:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5159ce31-7f22-48a8-b769-516609232bb6</guid><dc:creator>yoyou</dc:creator><description>&lt;p&gt;thank you very much,According to your guidance，The problem is solved。as follows：&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;App:&lt;/p&gt;
&lt;p&gt;#define _BT_PIN_NUMBER NRF_GPIO_PIN_MAP(1,1)&lt;/p&gt;
&lt;p&gt;static void sleep_mode_enter(void)&amp;nbsp;&amp;nbsp;&lt;br /&gt;{&lt;br /&gt; &amp;nbsp; &amp;nbsp;indication_set(BSP_INDICATE_IDLE);&lt;br /&gt;&amp;nbsp; &amp;nbsp;APP_ERROR_CHECK(err_code);&lt;br /&gt;&amp;nbsp; &amp;nbsp;nrf_gpio_cfg_sense_input(_BT_PIN_NUMBER,BUTTON_PULL,NRF_GPIO_PIN_SENSE_LOW);&lt;br /&gt; &amp;nbsp; &amp;nbsp;// nrf_gpio_cfg_sense_set(_BT_PIN_NUMBER, GPIO_PIN_CNF_SENSE_Low);&lt;br /&gt;&amp;nbsp; &amp;nbsp;err_code = sd_power_system_off();&lt;br /&gt;&amp;nbsp; &amp;nbsp;APP_ERROR_CHECK(err_code);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;bootloader：&lt;/p&gt;
&lt;p&gt;#define NRF_BL_DFU_ENTER_METHOD_BUTTON 0&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for your help&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: always automatic wakeup after entering SYSTEM OFF mode</title><link>https://devzone.nordicsemi.com/thread/336693?ContentTypeID=1</link><pubDate>Fri, 29 Oct 2021 13:16:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfb444bd-76fa-4004-8276-6282725eac6a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There is a potential problem with the bootloader. If you&amp;nbsp;built the bootloader with&amp;nbsp;NRF_BL_DFU_ENTER_METHOD_BUTTON set to 1, then the pin you have specified with&amp;nbsp;NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN is configured as an input with sense like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    nrf_gpio_cfg_sense_input(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN,
                             BUTTON_PULL,
                             NRF_GPIO_PIN_SENSE_LOW);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Unfortunately the bootloader does revert this configuration back to the default values before starting the application, so this will still be active when the application starts. If you use the same pin as wakeup source in your application as you use to signal that the bootloader should enter DFU mode that is OK, but if not, this can cause problems as you suddenly have a wakeup source you were not aware of.&lt;/p&gt;
&lt;p&gt;If this is the problem you could fix this by modifying the bootloader either by simply setting&amp;nbsp;NRF_BL_DFU_ENTER_METHOD_BUTTON&amp;nbsp; to 0 if it is not needed, or alternatively call&amp;nbsp;nrf_gpio_cfg_default(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN); for instance in the end of&amp;nbsp;dfu_enter_check() in&amp;nbsp;components\libraries\bootloader\nrf_bootloader.c.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: always automatic wakeup after entering SYSTEM OFF mode</title><link>https://devzone.nordicsemi.com/thread/336626?ContentTypeID=1</link><pubDate>Fri, 29 Oct 2021 09:20:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bac42d4a-85ad-4657-b37a-f57ce2e2475c</guid><dc:creator>yoyou</dc:creator><description>&lt;p&gt;nrf_gpio_cfg_sense_set(_BT_PIN_NUMBER, GPIO_PIN_CNF_SENSE_Low);&lt;/p&gt;
&lt;p&gt;err_code = sd_power_system_off();&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;S140&amp;nbsp; &amp;nbsp;SDK17&amp;nbsp; &amp;nbsp;52840,&amp;nbsp; only one button that connect to P1.1.&lt;/p&gt;
&lt;p&gt;when no bootloader&amp;nbsp;&lt;span&gt;everything&amp;#39;s fine.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;app+bootloader ,always automatic wakeup after entering SYSTEM OFF mode.&lt;/p&gt;
&lt;p&gt;Does anyone know how to solve it？&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for your help&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: always automatic wakeup after entering SYSTEM OFF mode</title><link>https://devzone.nordicsemi.com/thread/334729?ContentTypeID=1</link><pubDate>Tue, 19 Oct 2021 06:43:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebfd77b6-6318-4024-852b-9bc7f2d57510</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Yuank"]sd_power_system_off()&amp;nbsp;and NRF_POWER-&amp;gt;SYSTEMOFF = 1, I guess it&amp;#39;s not emulated off?[/quote]
&lt;p&gt;As long as you are not debugging, then both these methods will enter system OFF mode.&lt;/p&gt;
[quote user="Yuank"]I&amp;#39;m not sure about WDT, if it&amp;#39;s not set by default, I have no code for that.[/quote]
&lt;p&gt;Then you are not using the WDT.&lt;/p&gt;
[quote user="Yuank"]everything is fine, no auto reset and wake up on button, RESETREAS shows wakeup on GPIO DETECT[/quote]
&lt;p&gt;Ah, I see. I did not think to ask what you did in&amp;nbsp;configure_gpio_wakeup(), but that is interesting. The call to&amp;nbsp;nrf_gpio_cfg_sense_set() is also done by bsp_wakeup_button_enable(), but this does not clear the latch state of that pin. If for some reason there is a latched interrupt this will cause problems without it. I cannot see why this is, though.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: always automatic wakeup after entering SYSTEM OFF mode</title><link>https://devzone.nordicsemi.com/thread/334701?ContentTypeID=1</link><pubDate>Mon, 18 Oct 2021 23:27:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93187d84-24ec-4da8-a398-140073ae3057</guid><dc:creator>Yuank</dc:creator><description>&lt;p&gt;The sum up is right.&lt;/p&gt;
&lt;p&gt;The custom pcb runs separately and the DK is used to receive the BLE data and show it on DC serial port,&amp;nbsp;is that considered as debugging mode? And I tried both&amp;nbsp;&lt;span&gt;sd_power_system_off()&amp;nbsp;and NRF_POWER-&amp;gt;SYSTEMOFF = 1, I guess it&amp;#39;s not emulated off? I&amp;#39;m not sure about WDT, if it&amp;#39;s not set by default, I have no code for that.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As I mentioned below, if I use&lt;pre class="ui-code" data-mode="text"&gt;void configure_gpio_wakeup(uint32_t pin_number, nrf_gpio_pin_sense_t sense)

{

nrf_gpio_pin_latch_clear(pin_number);

nrf_gpio_cfg_watcher(pin_number);

nrf_gpio_cfg_sense_set(pin_number, sense);

}

configure_gpio_wakeup(BUTTON_5, NRF_GPIO_PIN_SENSE_LOW);&lt;/pre&gt; everything is fine, no auto reset and wake up on button, RESETREAS shows wakeup on GPIO DETECT&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: always automatic wakeup after entering SYSTEM OFF mode</title><link>https://devzone.nordicsemi.com/thread/334513?ContentTypeID=1</link><pubDate>Mon, 18 Oct 2021 08:48:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a8ec7ad-bf49-445e-87bb-2e8bae93829e</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t see anything obviously wrong here. Just to sum up:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The device always wakes up after 4-5 seconds in system off, but only if you have called&amp;nbsp;bsp_wakeup_button_enable(BUTTON_5); before entering system OFF.&lt;/li&gt;
&lt;li&gt;And you cannot wake up before this from system of by pressing&amp;nbsp;the button.&lt;/li&gt;
&lt;li&gt;If wakeup button was not configured, device stays in system off forever.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Is that correct?&lt;/p&gt;
&lt;p&gt;I noticed another thing from one of your earlier posts. There you wrote that &amp;quot;RESETREAS register always shows reset by soft reset&amp;quot;. That is not expected. You should see that it had woken up from system-off mode. Could it be that you are not testing system off mode, but rather emulated system off? Do you have a debugger attached when doing this test? I ask because system off does not work while debugging.&lt;/p&gt;
&lt;p&gt;Other questions: have you tested that this button works as expected when not using it to wake up from system off mode, so that the HW is good? Do you have a WDT running? If yes, have you tested without it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: always automatic wakeup after entering SYSTEM OFF mode</title><link>https://devzone.nordicsemi.com/thread/334418?ContentTypeID=1</link><pubDate>Fri, 15 Oct 2021 18:12:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b470761-56ba-4e3c-ae79-d1c251b119a6</guid><dc:creator>Yuank</dc:creator><description>&lt;p&gt;Still can&amp;#39;t get why &amp;quot;bsp_wakeup_button_enable(BUTTON_5);&amp;quot; will cause the auto wakeup, but if I use &amp;quot;configure_gpio_wakeup(BUTTON_5, NRF_GPIO_PIN_SENSE_LOW);&amp;quot;, everything&amp;#39;s fine.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: always automatic wakeup after entering SYSTEM OFF mode</title><link>https://devzone.nordicsemi.com/thread/334416?ContentTypeID=1</link><pubDate>Fri, 15 Oct 2021 16:50:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b55e0f6f-ffae-48fc-b596-6fbffec5ad7e</guid><dc:creator>Yuank</dc:creator><description>&lt;p&gt;It&amp;#39;s already pullup in bsp.c when I #define BSP_BUTTON_4&amp;nbsp; &amp;nbsp;BUTTON_5&lt;/p&gt;
&lt;p&gt;And during the 4-5 seconds before it automatic wakeup, the button doesn&amp;#39;t work(won&amp;#39;t wakeup the chip on press) and after the wakeup, pressing the button will enter the bsp_event&lt;/p&gt;
&lt;p&gt;Following is all the code about this button&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// in pca10040.h
#define BUTTONS_NUMBER 5   //4------&amp;gt;5
#define BUTTON_5  NRF_GPIO_PIN_MAP(0,24)
#define BUTTONS_LIST { BUTTON_1, BUTTON_2, BUTTON_3, BUTTON_4, BUTTON_5 }
#define BSP_BUTTON_4   BUTTON_5

// in sdk_config.h
#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 5   //4---&amp;gt;5

// in bsp.c
#ifdef BSP_BUTTON_4
    {BSP_BUTTON_4, false, BUTTON_PULL, bsp_button_event_handler},
    #endif
    
// in main.c
// in bsp_event_handler
case BSP_EVENT_KEY_4:  //BUTTON_5
            sprintf(bletext,&amp;quot;button_pcb detected\r\n&amp;quot;);BLE_TEXT(bletext);
            break;
// in ble_nus_event_handler
case 29:  // SYSTEM OFF mode
            nrf_delay_ms(500);
            sprintf(bletext,&amp;quot;SYSTEM OFF......\r\n&amp;quot;); BLE_TEXT(bletext);
            sprintf(bletext,&amp;quot;SYSTEM OFF......\r\n&amp;quot;); BLE_TEXT(bletext);
            sprintf(bletext,&amp;quot;SYSTEM OFF......\r\n&amp;quot;); BLE_TEXT(bletext);
            nrf_delay_ms(500);

            err_code = bsp_wakeup_button_enable(BUTTON_5);
            APP_ERROR_CHECK(err_code);
                                 
            nrf_delay_ms(500);
            /*err_code = sd_power_system_off();
            APP_ERROR_CHECK(err_code);*/
            NRF_POWER-&amp;gt;SYSTEMOFF = 1;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: always automatic wakeup after entering SYSTEM OFF mode</title><link>https://devzone.nordicsemi.com/thread/334412?ContentTypeID=1</link><pubDate>Fri, 15 Oct 2021 16:38:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15e6c013-2e4d-4350-b801-22c13986d7be</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Is it so that pin 29 is connected to ground when pushed, and that you do not have a pull-up? If so it will be floating when the button is not pressed, so yes, you need a pull-up. Note that there are internal&amp;nbsp;pull resistors for every GPIO, so there is no need for an external pull-up - just enable the internal pull-up.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: always automatic wakeup after entering SYSTEM OFF mode</title><link>https://devzone.nordicsemi.com/thread/334410?ContentTypeID=1</link><pubDate>Fri, 15 Oct 2021 16:31:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c5679d3-a1ff-47cf-8b14-5e71b2a33f56</guid><dc:creator>Yuank</dc:creator><description>&lt;p&gt;It&amp;#39;s connected to PIN29 (p0.24) using&amp;nbsp;#define BUTTON_5&amp;nbsp; NRF_GPIO_PIN_MAP(0,24). On HW it connects PIN29 and GND (already pullup in bsp.c, and active_state = 0)&lt;/p&gt;
&lt;p&gt;I have a bsp event for that button and I only enter that event when I press the button, is that enough to prove that it&amp;#39;s not floating&lt;/p&gt;
&lt;p&gt;Thanks for your help&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: always automatic wakeup after entering SYSTEM OFF mode</title><link>https://devzone.nordicsemi.com/thread/334294?ContentTypeID=1</link><pubDate>Fri, 15 Oct 2021 09:41:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3292f0a9-10cd-40e6-a8b6-8e792bd7e3d1</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Which pin does BUTTON_5 map to in your code? And how is this pin connected on your HW? When you configure that as an input and as a wakeup source, a change on the state of that pin can wake up the device. If that is controlled by something else and/or is floating, you will not have any control over what happens. Generally it is essential to have control over your inputs and to ensure that you hever have floating digital inputs.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: always automatic wakeup after entering SYSTEM OFF mode</title><link>https://devzone.nordicsemi.com/thread/334245?ContentTypeID=1</link><pubDate>Fri, 15 Oct 2021 01:09:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b9d62f9-01da-4dbc-bbe9-23b47bfd3930</guid><dc:creator>Yuank</dc:creator><description>&lt;p&gt;The system will stay in OFF mode if I comment out&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;err_code = bsp_wakeup_button_enable(BUTTON_5);
APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;We use a custom PCB and there&amp;#39;s no bsp_buttons on it, but we have a button connected to P0.24, and I added it in pca10040.h and sdk_config.h as following:&lt;pre class="ui-code" data-mode="text"&gt;
// in pca10040.h
#define BUTTONS_NUMBER 5   //4------&amp;gt;5
#define BUTTON_5  NRF_GPIO_PIN_MAP(0,24)
#define BUTTONS_LIST { BUTTON_1, BUTTON_2, BUTTON_3, BUTTON_4, BUTTON_5 }

// in sdk_config.h
#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 5   //4---&amp;gt;5
&lt;/pre&gt; And in main bsp_event_handler, we do enter the case BSP_EVENT_KEY_4 when the button is pressed, so I guess it should work the same as those buttons on the DK. But after I set that button for wakeup as &amp;quot;bsp_wakeup_button_enable(BUTTON_5);&amp;quot;, it will automatically wakeup without being pressed, what might be wrong?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: always automatic wakeup after entering SYSTEM OFF mode</title><link>https://devzone.nordicsemi.com/thread/334244?ContentTypeID=1</link><pubDate>Fri, 15 Oct 2021 00:10:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf39429a-d08e-4587-8bed-199583ff0c91</guid><dc:creator>Yuank</dc:creator><description>&lt;p&gt;Actually automatic restart after 4-5 seconds. I&amp;#39;m not sure if anything else (timers etc.)wakes it up, but the RESETREAS register always shows reset by soft reset. Did I set it to OFF mode correctly or is there anything else I need to set other than&amp;nbsp;sd_power_system_off() or&amp;nbsp;NRF_POWER-&amp;gt;SYSTEMOFF = 1?&amp;nbsp; If it really entered the OFF mode, what can trigger a soft reset?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>