This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

The register RESETREAS not set after a nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF)

Hi,

My application goes to system off by using nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF). In the handler, I configure a sense to be woken up by a GPIO, as follows:

static bool app_shutdown_handler(nrf_pwr_mgmt_evt_t event)
{
    switch (event) {
        case NRF_PWR_MGMT_EVT_PREPARE_WAKEUP:
                NRF_LOG_INFO("NRF_PWR_MGMT_EVT_PREPARE_WAKEUP");

                nrf_gpio_cfg_sense_input(INT_BTN_USB,
                                         NRF_GPIO_PIN_NOPULL,
                                         NRF_GPIO_PIN_SENSE_LOW);

                return true;
                break;

        default:
            return true;
    }

    NRF_LOG_FLUSH();

    return true;
}

On reset, in the main, I want to read the reset reason to act differently when I come from a system off. For that, I thought to read the register RESETREAS, unfortunately, this one is set to 0.

Now, if I use the register NRF_POWER->SYSTEMOFF instead of nrf_pwr_mgmt_shutdown(), the RESETREAS is correctly set. I've seen this register must not be used when the SD is enabled, so I would prefer to use the pwr mgmt that deals with all cases.

Can you explain me why the RESETREAS does not contain any reason when using nrf_pwr_mgmt_shutdown() ?

Thanks in advance.

Parents
  • They should behave exactly the same with and without softdevice enabled, except one difference. With softdevice enabled nrf_pwr_mgmt_shutdown translates to sd_power_system_off which is one SVC call overhead when compared to softdevice being disabled. I do not see why your RESETREAS reads 0. Can you please attach a minimalistic project for me to test it out.

  • Hi,

    Sorry for the response time. I've attached the minimal project. On a pushed button event (be careful with the sense), it calls nrf_pwr_mgmt_shutdown(). On a second push, it restarts, but the reason is set to 0.

    The Makefile compiles useless files, but that's not so important. Note the flash command uses openocd and the sdk is missing. It should be extracted in the the folder sdk-nrf52/.

    Test conditions: NRF52832 (bl652 board), SDK15.2.

    Best regards.

    nrf52-dbg-reset.zip

  • I could not flash your merged hex file 

    so I  flashed your .build/nrf52832_xxaa.hex instead and excluded bootloader_settings.hex content.

    first powerup looks like below. RESETREAS is 0 as expected.

    Now I press the button twice (one for making the system go to system_off and the other to wake it up). The RESETREAS is set as expected on wakeup. See below.

    I am not sure what is in your bootloader_settings.hex file to give you this behavior.

Reply
  • I could not flash your merged hex file 

    so I  flashed your .build/nrf52832_xxaa.hex instead and excluded bootloader_settings.hex content.

    first powerup looks like below. RESETREAS is 0 as expected.

    Now I press the button twice (one for making the system go to system_off and the other to wake it up). The RESETREAS is set as expected on wakeup. See below.

    I am not sure what is in your bootloader_settings.hex file to give you this behavior.

Children
Related