- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My application would like to enter a long timed sleep, and possibly wake up on an interrupt. This seems to work OK, but I am trying to figure out if there is a way to learn how much time I spent asleep, so I can adjust my local clock?
The RTC API seems to reset back to 0 when the sleep ends. Is there any way to get the elapsed time?
Solved! Go to Solution.
- Tags:
- rtc
- timed sleep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In regular sleep, all state is maintained. When connected or advertising, the device sleeps between RF activity as long as there is nothing to do (CPU is not actively processing something).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May I ask how you are doing the long timed sleep and waking up on interrupt?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure:
as i understand the power modes there are two sleep modes
(1) deep sleep with LPO off. entered from bleprofile_PrepareHidOff();
(2) deep sleep with LPO on and possibility to wake after a set time, performed by:
devLpmConfig.disconnectedLowPowerMode = LOW_POWER_MODE_POLL_TYPE_POWER_OFF;
devLpmConfig.wakeFromHidoffInMs = 20000; // set wake time
devLpmConfig.wakeFromHidoffRefClk = HID_OFF_TIMED_WAKE_CLK_SRC_128KHZ;
devlpm_enterLowPowerMode();
which can wake after a set time, or on a GPIO interrupt.
To wake from a GPIO interrupt the GPIO pin must first be configured to receive interrupts using gpio_configurepin() e.g.:
gpio_configurePin(port,pin,
GPIO_OUTPUT_DISABLE | GPIO_INPUT_ENABLE |
GPIO_EN_INT_RISING_EDGE, 0);
Both of these power save modes turn off the RAM and return as from a reset condition.
The question was whether in mode (2), in the event that the wakeup is from a gpio interrupt, if there is a way to measure the time spent sleeping, so that I can keep track of time (even approximately).
It occurred to me to do repeated timed sleeps (say for 10 minutes) which I could do a very approximate tracking of time spent in sleep. however, the cost to wake up is so high that this negates the value of going to sleep at all, unless the interval is at least 10 minutes, and at that point the timing gets pretty approximate.
Further questions.. : If it is the case that no sleep mode that shuts off the RAM can retain any timing information, then what is the lowest power way to do is do nothing waiting for an interrupt to occur? Is there anything I can do besides just do nothing and let the system take care of power management? Are there any configuration parameters I can set to minimize costs? In this state I would have advertisements off, no active connection, and no timers enabled (assuming that having timers off does not interfere with a timely interrupt response).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
gpio_configurePin(port,pin,
GPIO_OUTPUT_DISABLE | GPIO_INPUT_ENABLE |
GPIO_EN_INT_RISING_EDGE, 0);
this is just config a gpio PIN ,but BCM20732 how to kown Which pin that you used for wake up?
possible need to call devlpm_enableWakeFrom(DEV_LPM_WAKE_SOURCE_GPIO);But BCM20732 all don`t kown Which pin to used!!!!!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Any GPIO configured for an interrupt will automatically be wake source when devlpm_enableWakeFrom(DEV_LPM_WAKE_SOURCE_GPIO) is also enabled.
In this case, a rising edge on the configured GPIO (port and pin) will wake the device up. Of course, you can have multiple GPIOs configured as interrupt sources and any of these will wake from deep sleep.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for you answer! I see!
But when bcm20732 wake up from a deep sleep, what state it is?
1.RAM data may be loss?
2.When wake up bcm20732 will executive program from ATTRIBUTE((section(".app_init_code")))?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When the device wakes from deep sleep, it will still go through a reboot where the boot ROM reloads app code from NV into RAM, initializes it and calls the create function. No state will be maintained across deep sleep. So, yes, any data you may have had in RAM before entering deep sleep will be lost/reinitialized.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for you answer! what about the sleep,is there any different?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In regular sleep, all state is maintained. When connected or advertising, the device sleeps between RF activity as long as there is nothing to do (CPU is not actively processing something).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
About the devicelpm.c function,is there a Detailed documentation?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfortunately, the only documentation we provide for the API is located within the SDK at doc/API/index.html
Note that in order to open this file correctly, you may need to right click index.html and use the 'Open With' command to select the browser.