Controller sleep mode and wake up

Dear Sirs!

I use SDK 12.2. I need without RTOS to put controller in sleep mode (but not OFF mode) and be able to wake it up by pressing button, connected to GPIO.

GPIO with interrupt. I am confused how to do it? Please explain how to set it in deep sleep?.

Will controller perform next instruction after wake up and interrupt processing?

Additional question.

In all examples I see code 

// Activate deep sleep mode
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;

But I cannot find in datasheet SCB register and its bits. Where is system control register in datasheet? Different name?

Best regards

Parents Reply
  • You can have the device wake-up from a GPIO input event in System OFF mode. The implementation may look something like this:

    #include "nrf_gpio.h"
    
    
    void enter_system_off(void) 
    {
        /* Configure wake-up pin */
        nrf_gpio_cfg_sense_input(BUTTON_1, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW);
    
        NRF_POWER->SYSTEMOFF = 1;
        while(1);
    }
    
    /**@brief Application main function.
     */
    int main(void)
    {
        /* Enter system OFF mode after POR/BOR reset and wait for button press to trigger wake-up */
        if (NRF_POWER->RESETREAS == 0)
        {
            enter_system_off();
        }
        ...

Children
Related