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

Wake up from sleep in system ON mode

Hi Folks,

I am facing an issue while trying to perform a system On suspend procedure with a wake up on HITOLOW event.

No event is triggered when button pressed.

However, when I run nrf_pwr_mgmt_run() within a conditionnal loop (which exit from LP mode once port event interrupt is triggerred ), it works perfectly.

I don't understand the need for a while loop since in the first code i could check that the code is stuck in system ON mode (with No debug , just an output set to true before entering and reset once exited)

Thank you again for your explanations.

The best

Parents
  • Hi,

    If the chip wakes to check the conditional loop, it sounds like the event is at least waking the chip from System ON mode. This should be the same for both cases, however, there could be some issues with the triggering of the interrupt/event handler.

    Can you post the code snippets for the configuration of the GPIO(TE) and both the working and the non-working loop options?

    Best regards,
    Jørgen

  • #include "nrfx_gpiote.h"
    #include "nrf_pwr_mgmt.h"
    #include "nrf_delay.h"
    
    // Weak empty variant initialization function.
    // May be redefined by variant files.
    void initVariant() __attribute__((weak));
    void initVariant() { }
    
    volatile bool test = false;
    void in_pin_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
    	test = true;
    }
    
    int main( void )
    {
      //init();
       
      initVariant();
    
      nrf_delay_ms(100);
    
    #if CFG_SYSVIEW
      //SEGGER_SYSVIEW_Conf();
    #endif
    
    #ifdef USE_TINYUSB
      //Adafruit_TinyUSB_Core_init();
      //Serial.begin(115200);
    #endif
    
      //setup();
    
      nrf_pwr_mgmt_init();
      uint32_t err_code;
      err_code = nrfx_gpiote_init();
      APP_ERROR_CHECK(err_code);
    
      nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(false); // Set low_accu to true to use PORT_EVENT.
      //in_config.pull = NRF_GPIO_PIN_PULLUP; //I do have a pull up resistor on that pin
      err_code = nrfx_gpiote_in_init(g_ADigitalPinMap[PIN_nMAG_SNS], &in_config, in_pin_handler); // in_pin_handler = IN_EVENT
      nrfx_gpiote_in_event_enable(g_ADigitalPinMap[PIN_nMAG_SNS], true);
    
      //while(!test) {
    		nrf_pwr_mgmt_run();
      //}
    
      while(1); //Normal Run loop
    
      for (;;)
      {
        loop();
        tud_task(); // tinyusb device tasks
        if (serialEventRun) serialEventRun();
      }
    
      return 0;
    }

    Thank you Jorgen for your fast answer.

    The above code snippet does not work since I can reach directly the while(1) line meaning something might have caused an exit from system ON mode.

    When I uncomment the while(!test) brackets , it work perfectly and I only reach the while(1) line when a wake up port event is triggered.

    I must add I manually check that no Wake up event has happened (oscillo + IO for testing within interrupt handler) and I ran this code without debugging.

    Thanks

Reply
  • #include "nrfx_gpiote.h"
    #include "nrf_pwr_mgmt.h"
    #include "nrf_delay.h"
    
    // Weak empty variant initialization function.
    // May be redefined by variant files.
    void initVariant() __attribute__((weak));
    void initVariant() { }
    
    volatile bool test = false;
    void in_pin_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
    	test = true;
    }
    
    int main( void )
    {
      //init();
       
      initVariant();
    
      nrf_delay_ms(100);
    
    #if CFG_SYSVIEW
      //SEGGER_SYSVIEW_Conf();
    #endif
    
    #ifdef USE_TINYUSB
      //Adafruit_TinyUSB_Core_init();
      //Serial.begin(115200);
    #endif
    
      //setup();
    
      nrf_pwr_mgmt_init();
      uint32_t err_code;
      err_code = nrfx_gpiote_init();
      APP_ERROR_CHECK(err_code);
    
      nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(false); // Set low_accu to true to use PORT_EVENT.
      //in_config.pull = NRF_GPIO_PIN_PULLUP; //I do have a pull up resistor on that pin
      err_code = nrfx_gpiote_in_init(g_ADigitalPinMap[PIN_nMAG_SNS], &in_config, in_pin_handler); // in_pin_handler = IN_EVENT
      nrfx_gpiote_in_event_enable(g_ADigitalPinMap[PIN_nMAG_SNS], true);
    
      //while(!test) {
    		nrf_pwr_mgmt_run();
      //}
    
      while(1); //Normal Run loop
    
      for (;;)
      {
        loop();
        tud_task(); // tinyusb device tasks
        if (serialEventRun) serialEventRun();
      }
    
      return 0;
    }

    Thank you Jorgen for your fast answer.

    The above code snippet does not work since I can reach directly the while(1) line meaning something might have caused an exit from system ON mode.

    When I uncomment the while(!test) brackets , it work perfectly and I only reach the while(1) line when a wake up port event is triggered.

    I must add I manually check that no Wake up event has happened (oscillo + IO for testing within interrupt handler) and I ran this code without debugging.

    Thanks

Children
No Data
Related