clock reference/RTC during deep sleep?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi there,

following the discussion board and by testing the rtc_sample, I've been trying to figure out wether the BCM20737 does support any clock reference during deep sleep (HID off) without an external crystal. So far, I've found one success reports and several questions in the same direction. However (from my own experience also) there is no way to have a ticking clock during deep sleep. Can somebody confirm this? Or suggest a solution that does not require external components?

cheers,

-phil

0 Likes
1 Solution
Anonymous
Not applicable

Figured out what my problem/misunderstanding was. rtc_init() zeroes the RTC unconditionally, so removing this call and just using the rtc "un-initialiazed" works fine. The RTC also ticks in deep-sleep from the internal 128kHz resonator. Not sure what rtc_init()  is for, but problem solved. Thanks.

View solution in original post

0 Likes
12 Replies
MichaelF_56
Moderator
Moderator
Moderator
250 sign-ins 25 comments on blog 10 comments on blog

The part provides the ability to wake from Deep Sleep  (i.e. no state information is maintained) after a configured amount of time, both with the internal LPO or an external Xtal:

  • With internal clock, it can wake from Deep Sleep  anywhere from 64mS to ~36 Hrs
  • With external 32 KHz xtal, 128mS to ~144 Hrs

The rtc_sample application was created to demonstrate the use of an external 32K Xtal as it was assumed that the order of magnitude accuracy of the time maintained with the an external Xtal would be desired over the internal LPO for most applications.

In addition, the external clock equates to better sleep clock accuracy & lower sleep current of about 20% (internal LPO runs at 128KHz, so higher dynamic power).

Specificaly, the external clock is utilized when increased sleep clock accuracy (PPM) is needed.  As such, recall that as part of the connection event, the master and slave exchange sleep clock accuracy (PPM) and the accuracy is used to determine the uncertainty window of the slave device for the duration of the connection event. Essentially, this means that more accurate clocks can actually save power.

0 Likes
Anonymous
Not applicable

Thanks for the answer. To clarify, with external component I meant an additional RTC. As far as I understood there is no way to get the amount of time the part spent during deep sleep, right? A timed wakeup with the RTC is working for me. However getting the time spent in deep sleep when woken up via GPIO is not. The RTC always resets to zero after wakeup. Is there another clock source that ticks during deep sleep or an rtc sample, in which the BLE stack is enabled?

0 Likes

This thread posted by ldgirod addresses the same issue: Re: Is there any way to discover how much time has elapsed while asleep?

My understanding is that the internal LPO is still running during HIDOFF as it too can be used to wake from a timed wake-up (even though it has some drawbacks as already noted).

I will need to ask the developers if there is an example somewhere that shows how to wake from deep sleep using one of the two internal clocks.

santol

0 Likes

I stand corrected.

I spoke with the developers and confirmed that there are no clocks running when the part is in deep sleep.

The only thing we could think of to measure time spent in deep sleep would involve writing NVRAM before going to deep sleep and then read NVRAM in the _create function and calculate the difference.  This will obviously not work if you need to go into deep sleep often, but may be an option if your requirements for deep sleep are less frequent.

0 Likes
Anonymous
Not applicable

That's what my current work-around involves. Storing the time awake + the amount of wakeups by timed wakes. This is a very crude solution. Also the resolution of this "virtual" clock is then limited by the duration of the sleep cycle, as well as the resolution of the wake-up by GPIO time is fairly limited.

This is also makes me wonder about the usefulness of the RTC. Besides calling it an RTC, which implies that it runs even when the part is sleeping, it's just a small library that maps seconds since epoch to a calendar date then (rather than being an actual component of the µC)?!.  However the comment in the rtc_sample seems to contradict that:

              // Set up the original reference time instead of using 01/01/2010, 00:00:00 as the reference

              // because this is a wake from deep sleep. The HW clock keeps running in deep sleep so when

              // we wake up, the FW needs to know what was used as the original reference time.

              rtc_setReferenceTime(&current_time);

I guess, there was no follow-up on this thread: Re: Keeping the RTC running during Deep Sleep?. There the RTC seemed to be running during deep-sleep. To the best of my knowledge, i'm also using a 20737 (actually it's the ack.me AMS0002 module). So maybe that's why it's not working for me.

Thanks for your quick replies, very much appreciated.

0 Likes

Adding the ACKme team as one of them may know for certain: madmax and sheref.younan

I also sent a note to the original firmware engineer to confirm as well.  He is out this week on PTO, but should respond when he returns.

0 Likes
Anonymous
Not applicable

Figured out what my problem/misunderstanding was. rtc_init() zeroes the RTC unconditionally, so removing this call and just using the rtc "un-initialiazed" works fine. The RTC also ticks in deep-sleep from the internal 128kHz resonator. Not sure what rtc_init()  is for, but problem solved. Thanks.

0 Likes

Thanks for the update Philipp!

0 Likes
Anonymous
Not applicable

Have a question here.  I am using the rtc_sample.c as I have an issue with the RTC I am trying to fix.

When you run the RTC, and it goes to sleep and wakes up, it does seem to know that it has been asleep and has advanced the clock.  Are you saying this only works from a TIMED WAKE, and will not work properly from a GPIO INTERRUPT?

Based on the output here, and how we have been using the RTC in our firmware, there is some kind of accumulator running that is used to calculate the RTC, and it continues to run while in DEEP SLEEP.  Otherwise, how does it get the Current Date/Time is and the seconds since bigbang?

Here is some output from rtc_sample.c as an example:

08:56:57 - 08:56:57 -

08:56:57 - 08:56:57 - Entering deep sleep.

08:58:57 - 08:58:57 - rtc_sample_create()

08:58:57 - 08:58:57 -

08:58:57 - 08:58:57 - Waking from deep sleep because the timer went off or a GPIO triggered while waiting for timer to expire.

08:58:57 - 08:58:57 - 020106030304000409bb8104

08:58:57 - 08:58:57 - 020a81

08:58:57 - 08:58:57 - Time base is:

08:58:57 - 08:58:57 - Jan 0 00:00:00 0000

08:58:57 - 08:58:57 - Number of free bytes in RAM: 26548

08:58:57 - 08:58:57 -

08:58:57 - 08:58:57 - blecm evt handler:

08:58:57 - 08:58:57 - 0e0401082000

08:58:57 - 08:58:57 -

08:58:57 - 08:58:57 - blecm evt handler:

08:58:57 - 08:58:57 - 0e0401092000

08:58:57 - 08:58:57   bd_addr[5:2] = 20 73 6A 18

08:58:57 - 08:58:57   bd_addr[1:0] = B770 00

08:58:57 - 08:58:57   Fine Timer(1024 ms, 1/sec)

08:58:57 - 08:58:57   Fine TImer tick 80

08:58:57 - 08:58:57   Normal Timer(0 s, 0 tick)

08:58:58 - 08:58:58 - Current date/time is:

08:58:58 - 08:58:58 - Jul 15 12:04:17 2014

08:58:58 - 08:58:58 - Its been 143121857 seconds since bigbang.

0 Likes
Anonymous
Not applicable

cliff@rayman.com

Try calling rtc_init() only when mia_isResetReasonPor() returns true.

0 Likes
Anonymous
Not applicable

I am already referring to rtc_sample.  I am asking: how can I set it up using the INTERNAL 128kHz OSCILLATOR instead of the external oscilator?

Thanks,

       Aaron

0 Likes
Anonymous
Not applicable

This is working for me on the tag3 board and on my custom board (no external crystal):

$ diff rtc_sample_ORIG.c rtc_sample.c

115c115

<       rtcConfig.oscillatorFrequencykHz = RTC_REF_CLOCK_SRC_32KHZ;

---

>       //rtcConfig.oscillatorFrequencykHz = RTC_REF_CLOCK_SRC_32KHZ;

182c182

<     bleapputils_changeLPOSource(LPO_32KHZ_OSC, FALSE, 250);

---

>     //bleapputils_changeLPOSource(LPO_32KHZ_OSC, FALSE, 250);

235c235

<                       devLpmConfig.wakeFromHidoffRefClk = HID_OFF_TIMED_WAKE_CLK_SRC_32KHZ;

---

>                       devLpmConfig.wakeFromHidoffRefClk = HID_OFF_TIMED_WAKE_CLK_SRC_128KHZ;