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

waking from sleep

Hi,

I am having some trouble getting the nrf51422 (running the s130 soft device) to wake up after entering sleep mode. I have successfully entered sleep mode using NRF_POWER->SYSTEMOFF = 1, and sd_power_system_off() (both seem to be effective). However, when I attempt to wake up on a pin change, the chip appears to enter an unresponsive state where it consumes excessive current.

initialize input pin:

ret_code_t err_code;

    //init gpiote module if not already initialized
    if (!nrf_drv_gpiote_is_init())
    {
        err_code = nrf_drv_gpiote_init();
        APP_ERROR_CHECK(err_code);
    }
    
    //uint32_t out_pin_initial_state = 0; //for the 3v3 enable
    
    /********** HALL INPUT PIN  *******/
    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
    in_config.pull = NRF_GPIO_PIN_PULLDOWN;

    err_code = nrf_drv_gpiote_in_init(SCOPE_HALL_PIN, &in_config, in_pin_handler); //set pin and event handler
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(SCOPE_HALL_PIN, true); //enable event handling

sleep:

NRF_POWER->SYSTEMOFF = 1;  

pin change handler:

void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    SEGGER_RTT_printf(0, "pin change \n");

    sd_nvic_SystemReset();
}

If I do not enter sleep mode, the pin handler works normally (resulting in a restart). However, it doesn't perform as expected when the device is sleeping. I can't tell if the code in the pin change handler actually runs, as the chip becomes unresponsive and nothing is printed. It definitely stops sleeping on pin change though (and consumes much more current than it does in normal operation). Any suggestions on how to properly wake the device would be greatly appreciated. Thanks!

Parents
  • Any wakeup from systemoff mode will automatically cause a chip reset. So your in_pin_handler will not be called. It will be called if you use WFE or WFI or sd_app_evt_wait instead of systemoff.

  • Just as a check, I have been trying to run code on the PCA10028 board. Running the systemoff example with no soft device, I get low current consumption. However, running the ble_app_beacon example, I cannot get the current below 1 mA. The code is configured for an external crystal. I have modified main.c so that it consists entirely of a single "sd_power_system_off();" call. Here is all of main.c:

    #include <stdbool.h>
    #include <stdint.h>
    //#include "ble_advdata.h"
    #include "nordic_common.h"
    #include "softdevice_handler.h"
    #include "bsp.h"
    //#include "app_timer.h"
    
    int main(void)
    {
      sd_power_system_off();  // enter systemoff 
      for (;; )
      {
      }
    }
    

    I have restarted the chip to get out of debug mode, I am using the PCA10028 board, I am not using the GPIOTE module. Am I missing a setting somewhere? Thanks!

Reply
  • Just as a check, I have been trying to run code on the PCA10028 board. Running the systemoff example with no soft device, I get low current consumption. However, running the ble_app_beacon example, I cannot get the current below 1 mA. The code is configured for an external crystal. I have modified main.c so that it consists entirely of a single "sd_power_system_off();" call. Here is all of main.c:

    #include <stdbool.h>
    #include <stdint.h>
    //#include "ble_advdata.h"
    #include "nordic_common.h"
    #include "softdevice_handler.h"
    #include "bsp.h"
    //#include "app_timer.h"
    
    int main(void)
    {
      sd_power_system_off();  // enter systemoff 
      for (;; )
      {
      }
    }
    

    I have restarted the chip to get out of debug mode, I am using the PCA10028 board, I am not using the GPIOTE module. Am I missing a setting somewhere? Thanks!

Children
No Data
Related