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

System "always" wakes up from SYSTEM OFF Mode due to GPIO no matter what setting it is?

Dear Nordic,

I am using nRF52832-XXAB, SDK 15

I am aware that in order to enter SYSTEM OFF Mode and woke up by an GPIO event,

I have to set "nrf_gpio_cfg_sense_input(PIN_NUMBER, PULL_STATUS, SENSE_STATUS)" before calling NRF_POWER->SYSTEMOFF = 1

In my case, I want my system enters SYSTEM OFF due to a button being pressed for 10 seconds.

That button is at low level when being pressed and at high level in other times.

I expect users will keep pressing the button even the system already enters SYSTEM OFF Mode, so I am trying to deal with this situation.

However I discovered no matter what settings I set, the system always instantly wake up and starting to boot from my boot-loader(except one),

which really confused me.

Here are the combination I tried:

1. nrf_gpio_cfg_sense_input(BTN_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW)-->Instantly boot

2. nrf_gpio_cfg_sense_input(BTN_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH)-->Instantly boot

3. nrf_gpio_cfg_sense_input(BTN_PIN, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_LOW)-->Instantly boot

4. nrf_gpio_cfg_sense_input(BTN_PIN, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH)-->Cannot boot, no matter how hard I press the button

5. nrf_gpio_cfg_sense_input(BTN_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW)-->Instantly boot

6. nrf_gpio_cfg_sense_input(BTN_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_HIGH)-->Instantly boot

If I wish to implement a mechanism that allows the system to wake up by that button GPIO only if users release that button AFTER entering SYSTEM OFF Mode,

How would you suggest I achieve it?

Thanks.

  • Hello,

     

    In my case, I want my system enters SYSTEM OFF due to a button being pressed for 10 seconds.

    That button is at low level when being pressed and at high level in other times.

     Based on this, you should set pullup and NRF_GPIO_PIN_SENSE_LOW.

    Do you configure this pin to be anything else in your application as well? Perhaps you set it to be NRF_GPIO_SENSE_HIGH somewhere else in your application, which then wakes up the chip when the button is released? Or perhaps another pin is set to sense something, and this pin receives a pulse that wakes the chip up?

     

    4. nrf_gpio_cfg_sense_input(BTN_PIN, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH)-->Cannot boot, no matter how hard I press the button

     That is because the button is pulled low (so it is low when the button is not pressed), and you press the button, which will set it even harder low (the same really). There is no physical change on the pin.

    Check your other pins, if they receive any pulses that may wake it up. E.g. if you use UART or any other peripheral using any input pins, if these pins are not disconnected before you go to system off, they may wake the chip as well.

    Best regards,

    Edvin

  • Dear Edvin,

    I am sure that this button pin only being configured as a GPIOTE when system boot up, and is uninitialized with 

    nrf_drv_gpiote_in_uninit(BTN_PIN)
     before executing the pre-system off function.

    I followed your instructions using 

    nrf_gpio_cfg_sense_input(BTN_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW)

    Other than that, I set default all the pins from 2 to 31 using 

    nrf_gpio_cfg_default(PIN)
     before entering SYSTEM OFF Mode, except P0.00 and P0.01 are for 32.768kHz crystal and I keep four LED pins as output and turn them off using 
    nrf_gpio_pin_clear(PIN)

    I do have a pair of UART TX/RX set when system boot up, but it wasn't physically connect to any device.

    Besides, I tried set them with 

    nrf_gpio_cfg_input(TX, NRF_GPIO_PIN_PULLUP)
    nrf_gpio_cfg_input(RX, NRF_GPIO_PIN_PULLUP)
     and 
    nrf_gpio_cfg_default(TX)
    nrf_gpio_cfg_default(RX)
    respectively before entering SYSTEM OFF Mode, but doesn't seem to have any impact to the question.

    Another phenomenon that kind of tells only the BTN_PIN is causing the system to instantly boot up is that if I remove 

    nrf_gpio_cfg_sense_input(BTN_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW)
    , then the system won't wake up anymore after entering SYSTEM OFF Mode.

  • Is it possible for me to reproduce this on a DK? If so, can you zip a project folder containing a project that I can compile in an unmodified SDK and reproduce the issue?

    BR,
    Edvin

Related