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

  • nrf_gpio_cfg_sense_set(_BT_PIN_NUMBER, GPIO_PIN_CNF_SENSE_Low);

    err_code = sd_power_system_off();
    APP_ERROR_CHECK(err_code);

    S140   SDK17   52840,  only one button that connect to P1.1.

    when no bootloader everything's fine.

    app+bootloader ,always automatic wakeup after entering SYSTEM OFF mode.

    Does anyone know how to solve it?

    Thanks for your help

  • Hi,

    There is a potential problem with the bootloader. If you built the bootloader with NRF_BL_DFU_ENTER_METHOD_BUTTON set to 1, then the pin you have specified with NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN is configured as an input with sense like this:

        nrf_gpio_cfg_sense_input(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN,
                                 BUTTON_PULL,
                                 NRF_GPIO_PIN_SENSE_LOW);

    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.

    If this is the problem you could fix this by modifying the bootloader either by simply setting NRF_BL_DFU_ENTER_METHOD_BUTTON  to 0 if it is not needed, or alternatively call nrf_gpio_cfg_default(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN); for instance in the end of dfu_enter_check() in components\libraries\bootloader\nrf_bootloader.c.

  • thank you very much,According to your guidance,The problem is solved。as follows:

    App:

    #define _BT_PIN_NUMBER NRF_GPIO_PIN_MAP(1,1)

    static void sleep_mode_enter(void)  
    {
       indication_set(BSP_INDICATE_IDLE);
       APP_ERROR_CHECK(err_code);
       nrf_gpio_cfg_sense_input(_BT_PIN_NUMBER,BUTTON_PULL,NRF_GPIO_PIN_SENSE_LOW);
       // nrf_gpio_cfg_sense_set(_BT_PIN_NUMBER, GPIO_PIN_CNF_SENSE_Low);
       err_code = sd_power_system_off();
       APP_ERROR_CHECK(err_code);
    }

    bootloader:

    #define NRF_BL_DFU_ENTER_METHOD_BUTTON 0

    Thanks for your help

Related