12 Replies Latest reply on Jul 29, 2016 1:56 PM by clrac_2121416

    Switching between untimed DEEP SLEEP and timed DEEP SLEEP

      Based on various parameters in my application, I would like to switch between timed and untimed DEEP SLEEP.  I am always using an interrupt to wake up on, sometimes combined with a timer and other times without a timer.  The first DEEP SLEEP after a POWER ON RESET, always results in a DEEP SLEEP without a timer.  Afterwards, based on parameters set at connection, I attempt to use the DEEP SLEEP with a timer, but the CHIP never wakes up with the timer once I use it without the timer.   If i always set the timer (make sure secs < SLEEP_MAX), then the CHIP will wakeup with the timer without issue over and over again.  Can someone tell me what I should be doing different, after a DEEP SLEEP without a timer, that will allow the CHIP to wake up with the TIMER as expected?



      app_enter_deep_sleep_with_timer(int secs)


           ble_trace0("+Entering deep sleep");

           devLpmConfig.disconnectedLowPowerMode = DEV_LPM_DISC_LOW_POWER_MODES_HID_OFF;

           miaDriverConfig.delayAfterEnteringHidOffInUs= 30000000; // 700000;

           devLpmConfig.wakeFromHidoffRefClk = HID_OFF_TIMED_WAKE_CLK_SRC_128KHZ;

           if (secs < SLEEP_MAX){

             devLpmConfig.wakeFromHidoffInMs = secs * 1000;

             ble_trace1("LPM timer secs %d", secs);

           } else {

               devLpmConfig.wakeFromHidoffInMs = 0;



           gpio_configurePin(GPIO_PIN_P0 / 16, GPIO_PIN_P0 % 16, GPIO_INPUT_ENABLE | GPIO_PULL_UP, 0);


           gpio_configurePin(GPIO_CAP_BUTTON / 16, GPIO_CAP_BUTTON % 16, GPIO_INPUT_ENABLE | GPIO_EN_INT_BOTH_EDGE, 0);


           bleprofile_PrepareHidOff();  // Puts device into Deep Sleep ~1.33uA