GPIO wake up doesn't work on nRF52-DK

Hello, I am using nRF52-DK with Segger Embedded Studio and I'm running the following code that first blinks the LED1 on&off 5 times, and sets up BUTTON1 for wake up, and then enters system off mode.

    nrf_gpio_cfg_output(LED_1);
    for(int k = 0; k < 10; k++) {
      nrf_gpio_pin_toggle(LED_1);
      nrf_delay_ms(500);
    }
    
    nrf_gpio_cfg_sense_input(BUTTON_1, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);

    sd_power_system_off();
    nrf_gpio_pin_clear(LED_1);
    while(true) { }
    
    // (BLE code below)

If I run the example, it does seem to eventually enter system off mode because nrf_gpio_pin_clear(LED_1) doesn't get executed (light stays on after having blinked 5 times on&off).

But problem is that when i press BUTTON 1, it doesn't wake up the device (I would expect it to restart, and start blinking LED at start of the code).

What is happening? What can I do to test out this functionality on nRF52-DK?

Thank you for your answers in advance

Best regards

Parents
  • Hello,

    If I run the example, it does seem to eventually enter system off mode because nrf_gpio_pin_clear(LED_1) doesn't get executed (light stays on after having blinked 5 times on&off).

    Are you running this within a debugging session? If so, the deep sleep mode will not work correctly because the debugger will not let the device go into actual system_off.
    Furthermore, no LEDs or other peripherals may be on while the device is in SYSTEM_OFF, so this indicates that it has in fact not entered system off successfully.

    What can I do to test out this functionality on nRF52-DK?

    I would recommend going through the sleep_mode_enter function of the BLE peripheral examples from the nRF5 SDK to see how this can be implemented.
    For instance, you could see how SYSTEM_OFF sleep is entered in the advertising IDLE event of the ble_app_uart example.

    Best regards,
    Karl

Reply
  • Hello,

    If I run the example, it does seem to eventually enter system off mode because nrf_gpio_pin_clear(LED_1) doesn't get executed (light stays on after having blinked 5 times on&off).

    Are you running this within a debugging session? If so, the deep sleep mode will not work correctly because the debugger will not let the device go into actual system_off.
    Furthermore, no LEDs or other peripherals may be on while the device is in SYSTEM_OFF, so this indicates that it has in fact not entered system off successfully.

    What can I do to test out this functionality on nRF52-DK?

    I would recommend going through the sleep_mode_enter function of the BLE peripheral examples from the nRF5 SDK to see how this can be implemented.
    For instance, you could see how SYSTEM_OFF sleep is entered in the advertising IDLE event of the ble_app_uart example.

    Best regards,
    Karl

Children
  • I'm only running this using Segger Embedded Studio by pressing "Build and run", so I don't know how to make sure this runs outside debug mode?

    I looked at ble_app_uart and from what I see all it does can be distilled to something like this:

    nrf_gpio_cfg_sense_set(BUTTON_1, NRF_GPIO_PIN_SENSE_LOW);
    sd_power_system_off();

    Which uses sense_set instead of sense_input function. I tried it but I still cannot make it wake up by pressing BUTTON 1.
    Only hope I see right now is to try make sure I can run this outside debug mode if that's what's causing it not to work.

    Any suggestion appreciated,

    Best regards

  • Hello,

    Thank you for your patience with this.

    bko said:
    I'm only running this using Segger Embedded Studio by pressing "Build and run", so I don't know how to make sure this runs outside debug mode?

    Thank you for confirming this, this should then run outside of a debug session.
    Following the build and run option you should press the reset button or power cycle the board, to start the flashed application. Could you also confirm to have done this?

    bko said:
    Which uses sense_set instead of sense_input function. I tried it but I still cannot make it wake up by pressing BUTTON 1.

    Yes, it should be sufficient to set the sense on a button before going to sleep.
    Are you getting any errors, or otherwise unexpected behavior from your application, or is it just that nothing happens when you press button 1? For good measure, could you confirm for me which pin BUTTON_1 is defined to, and whether or not there has been made any hardware changes to the DK you are working with?

    Best regards,
    Karl

  • I changed sd_power_system_off() to nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF);

    Now it resets on button press! Although I'm not sure why the other way of going to sleep didn't function, but anyway :)

    Thank you and best regards

Related