Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

WakeUp from sleep mode

Hi,

we try to get the NRF52840 to sleep and then wake up from an GPIO interrupt.

We try it in debug mode which should give a emulated sleep mode. So we stop all processing and at a while(1) loop after calling sd_power_system_off.

The wakeup pin is configured as followed:

	nrf_gpio_cfg_input(IMU_INT2, NRF_GPIO_PIN_NOPULL);
	nrf_gpio_cfg_sense_set(IMU_INT2, NRF_GPIO_PIN_SENSE_HIGH);

Prior to setting the nrf to sleep the interrupt is firing and working as expected. And I can see the interrupt going high and low again when the nrf should be in sleep

but it does not produce a reset. Some other information the device is running with USB powered and usb_handling enabled and debugger disconnected.

I've already tried to uncomment the USB stuff and run it without USB but still no progress.
Help is appreciated ;-).

Kind regards,

C.W.

PS: SDK is 17.0.0

  • Hi

    First off, I strongly recommend that you move your project to SDK v17.0.2, as the SDK v17.0.2 release is a bug fix release replacing version 17.0.0, which had quite a few issues. If that doesn't solve anything for you, please show me how you put the device to sleep, and how you prepare the device to sleep before that.

    Best regards,

    Simon

  • Sorry we already tried it but no success, here is the code snippet how we launche the sleep mode:

        // Prepare wakeup buttons.
    	nrf_gpio_cfg_input(IMU_INT2, NRF_GPIO_PIN_NOPULL);
    	nrf_gpio_cfg_sense_set(IMU_INT2, NRF_GPIO_PIN_SENSE_HIGH);
    
    	nrf_gpio_pin_set(LED_ERROR);
    	nrf_delay_ms(500);
    	nrf_gpio_pin_clear(LED_ERROR);
    
        // Go to system-off mode (this function will not return; wakeup will cause a reset).
    	#ifdef DEBUG
    	 (void) sd_power_system_off();
    	 while(1);
    	#else
    	  APP_ERROR_CHECK(sd_power_system_off());
    	#endif  // DEBUG_NRF

    Again the device is powered via USB and the usb+ nad usb- lines are connected to a PC. But we already tested with battery powered only. The Debugger was always disconnected.

    Kind regards,

    C.W.

  • Hi again

    Okay, what Pin are you using to wake up/trig the reset when the device is sleeping. The sleep and wake up works as expected in release mode, correct?

    Best regards,

    Simon

  • Hi Simon,

    in Debug and Release mode it does not work. I've tested the following pins:

            #define IMU_INT1            NRF_GPIO_PIN_MAP(1, 6)
            #define IMU_INT2             NRF_GPIO_PIN_MAP(1, 3)

    Both did not work.

    Best regards,

    Constantin

  • Hi again

    Okay, so it's not related to the debug mode specifically. I would suggest you check out some of our example projects that go to sleep using the sleep_mode_enter() function which prepares wakeup buttons and goes to system-off mode like this.

    /**@brief Function for putting the chip into sleep mode.
     *
     * @note This function will not return.
     */
    static void sleep_mode_enter(void)
    {
        ret_code_t err_code;
    
        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);
    }

    See, I.E. the ble_app_hrs example for more details.

    Best regards,

    Simon

Related