always automatic wakeup after entering SYSTEM OFF mode

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: 

 case 29:  // SYSTEM OFF mode
                                  nrf_delay_ms(500);
                                  sprintf(bletext,"SYSTEM OFF......\r\n"); BLE_TEXT(bletext);
                                  sprintf(bletext,"SYSTEM OFF......\r\n"); BLE_TEXT(bletext);
                                  sprintf(bletext,"SYSTEM OFF......\r\n"); 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->SYSTEMOFF = 1;

Every time it goes to OFF mode, it will automatically restart booting after about 1-2 seconds

I used the sd_power_reset_reason_get() and it shows that it's reset from soft reset detected (SREQ)

I read several post about this topic and it looks like sd_power_system_off() doesn't work in debugging mode. I don't know how to check if I'm in debug mode or not, so I used both sd_power_system_off() and NRF_POWER->SYSTEMOFF = 1, same problem, no difference. And I tried both connect our pcb to the nRF52DK and pcb runs separately communicating with nRF52DK through BLE, same problem.

Can anyone help with this? Thanks in advance

  • Actually automatic restart after 4-5 seconds. I'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 sd_power_system_off() or NRF_POWER->SYSTEMOFF = 1?  If it really entered the OFF mode, what can trigger a soft reset?

  • The system will stay in OFF mode if I comment out 

    err_code = bsp_wakeup_button_enable(BUTTON_5);
    APP_ERROR_CHECK(err_code);

    We use a custom PCB and there'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:

    // in pca10040.h
    #define BUTTONS_NUMBER 5   //4------>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--->5
    
    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 "bsp_wakeup_button_enable(BUTTON_5);", it will automatically wakeup without being pressed, what might be wrong?

  • 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.

  • It's connected to PIN29 (p0.24) using #define BUTTON_5  NRF_GPIO_PIN_MAP(0,24). On HW it connects PIN29 and GND (already pullup in bsp.c, and active_state = 0)

    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's not floating

    Thanks for your help

  • Hi,

    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 pull resistors for every GPIO, so there is no need for an external pull-up - just enable the internal pull-up. 

Related