9 Replies Latest reply on Jul 26, 2015 11:50 PM by leo_su

    How to awake from      LOW_POWER_MODES_SLEEP?

    leo_su

      ===

      SDK: 2.1.1

      Tag: 920737.

      app: hello-sensor.

      OTA firmware size ~ 11KB.

      ===

       

      Problem description:

      We implement device power-sleep mode (both for low-power and deep-sleep)

      we meet some problems that if enabling low-power mode, we dont know how to enable awake
      from sleep mode. Besides, if using Hid-off mode, devLpmConfig.wakeFromHidoffInMs = 0 is

      to disable timer awake? and GPIO is all off during Hid-off mode?

      if in low-power mode, can button interrupt be the awake-trigger for it?

       

      there are some questions summaries:

       

      [low-power mode:]

      - What's awake trigger?

      - Is any timer awake same as Hid-off like devLpmConfig.wakeFromHidoffInMs for use?

      - Can button interrupt be a trigger way?

      - GPIO is off or on?

      - When into sleep, do we need to kill timer if timer thread is existed before?

       

      [hidd-off]

      - What's awake trigger? Ans: use devLpmConfig.wakeFromHidoffInMs = 0 or some value?

      - Can button interrupt be a trigger way?

      - GPIO is off or on?

      - When into sleep, do we need to kill timer if timer thread is existed before?

      - it will be like reboot from init code execution?

        • 1. Re: How to awake from      LOW_POWER_MODES_SLEEP?
          kwang

          There are two ways to put the device into deep sleep, bleprofile_PrepareHidOff and also devlpm_enterLowPowerMode, both of which put the device into deep sleep, so I'm not quite sure what you are asking about for low-power mode.  If you are talking about regular sleep, I believe there is no way of actually calling sleep with a function, it is done behind the scenes like when advertising, the device will go to sleep in between advertisements. 

           

          So now for deep sleep. 

          There are two ways that I can think of right now to wake up from deep sleep.  First would be to set a time with the external crystal.  There is an example of this in the wiced sense firmware. (devLpmConfig.wakeFromHidoffInMs).  The other way is to set a GPIO interrupt, which is also in the wiced sense firmware. 

           

          this might be helpful too How to enter HIDOFF?  How to detect if the request is not honored?

           

          Below is the snippet of wiced sense firmware I was referring to, you may find it helpful in waking from deep sleep.

           

          void wiced_sense_advertisement_stopped(void)

          {

               // Stop all timers when adv stops.

               bleprofile_KillTimer();

           

               // Power down all sensors so we conserve battery.

               wiced_sense_power_down_sensors();

           

               // Stop LED1

               wiced_sense_stop_led1();

           

               // Wake on GPIO interrupt.

               gpio_configurePin(GPIO_PIN_P4 / 16, GPIO_PIN_P4 % 16, GPIO_EN_INT_RISING_EDGE,      GPIO_PIN_OUTPUT_LOW);

               {

                    // Configure the low power manager to enter deep sleep.

                    devLpmConfig.disconnectedLowPowerMode = DEV_LPM_DISC_LOW_POWER_MODES_HID_OFF;

           

                    // Configure the wake time in mS.

                    devLpmConfig.wakeFromHidoffInMs = 7200000;

           

                     // Wait for at most 700mS after entering deep sleep before giving up

                    // and aborting. If we do enter deep sleep, we will never get out of this wait loop.

                    miaDriverConfig.delayAfterEnteringHidOffInUs= 700000;

           

                    // Use the external 32k.

                    devLpmConfig.wakeFromHidoffRefClk = HID_OFF_TIMED_WAKE_CLK_SRC_128KHZ;

           

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

           

                    // Enter deep-sleep now. Will not return.

                    devlpm_enterLowPowerMode();

               }

          }

          • 2. Re: How to awake from      LOW_POWER_MODES_SLEEP?
            kwang

            Not quite sure how to answer your "low power mode" questions but for deep sleep

            1. devLpmConfig.wakeFromHidoffInMs = 0 I believe is no wake from clock, but yes devLpmConfig.wakeFromHidoffInMs = some value > 0 and or GPIO interrupt

            2. Yes, if you look at wiced sense schematic, P4 is the top button on the wiced sense kit and thats what they use to wake from deep sleep

            3. above

            4.  I believe you do need to if you call the enterlowpowermode function but don't need to if you call prepareHidOff

            5. yes, it goes through a power cycle


            Hope this helps!

            Kevin

            • 3. Re: How to awake from      LOW_POWER_MODES_SLEEP?
              leo_su

              Thanks, Kevin,

               

              BTW, we meet one problem now if we enable deep sleep and wake up IO is DEV_LPM_WAKE_SOURCE_GPIO
              for a interrupt pin, other GPIO will be reset and not-working during deep sleep mode. Is it correct?

              is GPIO off during deep sleep mode? Coz our system is powered-switch by a IO and we find
              once deep-sleep is enabled, this switch IO will be reset which cause our device power-off.

              • 4. Re: How to awake from      LOW_POWER_MODES_SLEEP?
                kwang

                Hi leo_su

                 

                If you configure that GPIO for interrupt it should keep your device from going to sleep.


                -Kevin

                • 5. Re: How to awake from      LOW_POWER_MODES_SLEEP?
                  leo_su

                  Hi, Kevin,

                   

                  I had tried this ticket but it still fails (GPIO state in deep sleep).

                  Now the problem we met with is, the wake up IO is ok to

                  start re-boot from deep sleep (it's configured as input/ISR pin).

                  However, the other GPIO is default high for our system power-up.

                  And we find once system is into deep sleep, all IO which are previously configured

                  as output pin will be reset to input pin (it seems only ISR pin workable).

                  If so, the next reboot will be failed due to power-loss by this IO switch.


                  So my question is can GPIO "output pin" can still be remain same after recovery from

                  deep sleep?






                  • 6. Re: How to awake from      LOW_POWER_MODES_SLEEP?
                    BoonT_56

                    Yes you can. Check out the fix here:

                     

                    GPIO state in deep sleep

                    • 7. Re: How to awake from      LOW_POWER_MODES_SLEEP?
                      kwang

                      Hi leo_su,

                      Sorry I edited out my original response and is probably causing some confusion. 

                       

                      Try configuring the GPIO pin like you would do for an interrupt,

                      gpio_configurePin(GPIO_PIN_P4 / 16, GPIO_PIN_P4 % 16, GPIO_EN_INT_RISING_EDGE,      GPIO_PIN_OUTPUT_LOW);

                       

                      Then try it WITH GPIO state in deep sleep.

                       

                      -Kevin

                      • 9. Re: How to awake from      LOW_POWER_MODES_SLEEP?
                        leo_su

                        Hi, Boont,

                         

                        It seems fine and we now tested on power consumption. TKS.