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

regarding waking up device from sleep mode

Hi,

We are using nordic nRF52832 in our project as per our requirement we have to implement sleep and wake up mode with the help of button interrupt.our use case is that after long press of 3 seconds device starts advertising(exit sleep mode). and again after long press of 3 sec device goes to sleep mode(ideal state).

Initially we have tried this functionality by make test code that if button is pressed for 5 seconds LEDs glows and aging pressing same button for 3 sec LEDs go off.

But when we are using same implementation to shut down device {sd_power_system_off()} the device goes to sleep but the device does not wakes up. are there any configuration setting which we need to do so that device exits sleep mode.

I am attaching the code functions which we are using to wake and sleep device.

static void bsp_event_handler(bsp_event_t event)
{
switch (event)
{

case BSP_EVENT_KEY_1:

if(long_pressed==1)
{
bsp_board_leds_off();
sleep_mode_enter();
}
else
{
bsp_board_leds_on();

}
break;

default:
break;
}
}

  • Hi,

    But when we are using same implementation to shut down device {sd_power_system_off()} the device goes to sleep but the device does not wakes up. are there any configuration setting which we need to do so that device exits sleep mode.

    When in System OFF mode, the device can be woken up through one of the following signals:

    1. The DETECT signal, optionally generated by the GPIO peripheral
    2. The ANADETECT signal, optionally generated by the LPCOMP module
    3. The SENSE signal, optionally generated by the NFC module to “wake-on-field”
    4. A reset

    Try to configure the pin you want to use to wake the chip up with like this:

    nrf_gpio_cfg_sense_input(PIN NUMBER, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);

    This will generate the DETECT signal when the pin goes from high to low.

    Note that in some examples in the SDK, we use the function bsp_btn_ble_sleep_mode_prepare() to do this. It will by defualt configure button 1 to wake the chip up when pressed.

    static void sleep_mode_enter(void)
    {
        uint32_t err_code = bsp_indication_set(BSP_INDICATE_IDLE);
        APP_ERROR_CHECK(err_code);
    
        // Prepare wakeup buttons.
        err_code = bsp_btn_ble_sleep_mode_prepare();
        APP_ERROR_CHECK(err_code);
    
        // Go to system-off mode (this function will not return; wakeup will cause a reset).
        err_code = sd_power_system_off();
        APP_ERROR_CHECK(err_code);
    }

Related