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

Restart after sd_power_system_off()

Hello,

I am trying to solve my issue for few days without success hence your help would be appreciated. I found a lot of related issues, but any of the solutions doesn't work in my case. I am using nrf52840, SES, nRF5 Software Development Kit v17.0.0.

I have one button on my board and want to implement power off / wakeup functionality when the button is pressed. Button is active high.

The issue is that CPU restarts immediately after sd_power_system_off() call, if I configure the button like:

nrf_gpio_cfg_sense_set(BUTTON_1, NRF_GPIO_PIN_SENSE_HIGH);

just before sd_power_system_off() call. If I do not configure sense of the button, then CPU goes to system off and (as expected) stays there.

Debugger is disconnected, project is compiled as Release. Power cycle after flashing. GPIOTE is not initialized. Button push detection in system on is implemented as:

if(nrf_gpio_pin_read(BUTTON_1) == 1)

{...}

Let me know if you need more information. Thank you in advance!

Parents
  • Hi,

     

    How are you configuring the button?

    If you do not have an external pull-down resistor, you can enable it in the GPIO itself:

    nrf_gpio_cfg_sense_input(BUTTON_1, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH);

     

    Could you try this and see if it works better?

     

    Kind regards,

    Håkon

  • Hello Håkon,

    Thank you for your replay.

    Unfortunately this didn't help. CPU just restarts.

    Let me provide more information.

    This processing is performed in main loop:

          sleep_flg = 0;
          if(nrf_gpio_pin_read(BUTTON_1) == 1) // If button is pressed
          {
            nrf_drv_gpiote_in_uninit(BUTTON_1);
            nrf_gpio_cfg_sense_input(BUTTON_1, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH);
    
            sleep_flg = 1;
          }
          
          if(m_new_command_received == APP_CMD_NOCOMMAND)
          {
              idle_state_handle();
          }

    idle_state_handle() function:

    static void idle_state_handle(void)
    {
      if (sleep_flg)
      {
        //sleep_mode_enter();
        uint32_t err_code = sd_power_system_off();
        APP_ERROR_CHECK(err_code);
      }
      else
      {
        while(NRF_LOG_PROCESS());
        sd_app_evt_wait();
      };
    }

Reply
  • Hello Håkon,

    Thank you for your replay.

    Unfortunately this didn't help. CPU just restarts.

    Let me provide more information.

    This processing is performed in main loop:

          sleep_flg = 0;
          if(nrf_gpio_pin_read(BUTTON_1) == 1) // If button is pressed
          {
            nrf_drv_gpiote_in_uninit(BUTTON_1);
            nrf_gpio_cfg_sense_input(BUTTON_1, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH);
    
            sleep_flg = 1;
          }
          
          if(m_new_command_received == APP_CMD_NOCOMMAND)
          {
              idle_state_handle();
          }

    idle_state_handle() function:

    static void idle_state_handle(void)
    {
      if (sleep_flg)
      {
        //sleep_mode_enter();
        uint32_t err_code = sd_power_system_off();
        APP_ERROR_CHECK(err_code);
      }
      else
      {
        while(NRF_LOG_PROCESS());
        sd_app_evt_wait();
      };
    }

Children
Related