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

Thingy52 sleep_mode_enter() Runs Bootloader Instead of Restarting Program

Hi, when my program calls sleep_mode_enter(), it enters system off (deep sleep) as expected. However, when I press the button on the Thingy52 to wake up, the bootloader starts running instead of my program restarting.

Below is my sleep_mode_enter() function. Any advice on how to get my program to restart instead of running the bootloader upon a button press would be appreciated. Thanks in advance.

/**@brief Function for putting Thingy into sleep mode.
 *
 * @note This function will not return.
 */
static void sleep_mode_enter(void)
{
    uint32_t err_code;
    drv_ext_light_rgb_intensity_t color;

    NRF_LOG_INFO("Entering sleep mode \r\n");

    err_code = support_func_configure_io_shutdown();
    APP_ERROR_CHECK(err_code);

    // Enable wake on button press.
    nrf_gpio_cfg_sense_input(BUTTON, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);

    color.r = 128;
    color.g = 12
    color.b = conf_ui.data.mode_const.b;

    err_code = drv_ext_light_rgb_intensity_set(DRV_EXT_RGB_LED_LIGHTWELL, &color);

    // nrf_gpio_cfg_input(MIC_DOUT, NRF_GPIO_PIN_NOPULL);
    // err_code = drv_ext_gpio_pin_set(SX_MIC_PWR_CTRL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_FLUSH();
    nrf_delay_ms(5);
    // Go to system-off (sd_power_system_off() will not return; wakeup will cause a reset). When debugging, this function may return and code execution will continue.
    err_code = sd_power_system_off();
    NRF_LOG_WARNING("sd_power_system_off() returned. -Probably due to debugger being used. Instructions will still run. \r\n");
    NRF_LOG_FLUSH();

    #ifdef DEBUG
        if(!support_func_sys_halt_debug_enabled())
        {
            APP_ERROR_CHECK(err_code); // If not in debug mode, return the error and the system will reboot.
        }
        else
        {
            NRF_LOG_WARNING("Exec stopped, busy wait \r\n");
            NRF_LOG_FLUSH();

            while(true) // Only reachable when entering emulated system off.
            {
                // Infinte loop to ensure that code stops in debug mode.
            }
        }
    #else
        APP_ERROR_CHECK(err_code);
    #endif
}