- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
As I have read some time ago (Re: Putting '20732S into sleep or deep sleep mode) it appears as if the RTC is reset during deep sleep. I have not been able to get it to work either, neither with the internal nor external oscillator. Now I'm wondering whether anybody has found a useable solution to solve this problem with the BCM20732(S) without attaching an external RTC to it.
While I could envision some benefits resulting from attaching an external RTC to the BCM20732S with regard to power consumption, the cost argument trumps it all for me. I hope you can help.
Regards,
Kilian
Solved! Go to Solution.
- Labels:
-
Clocks (InternalExternal)
-
Sleep Modes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, we have decided to go with the 20737S. This was my attempt to see whether we can get the RTC in the 20732S to work at all or whether we better switch. We switched to the 20737S. Beyond that there are many more reasons switch than just the RTC, i.e.
- stuck at SDK 1.x
- more missing features (central role, crypto aspects, ...)
- having to support multiple platforms
I'm sure one can use it for some applications, but for us it is too limiting.
Regards,
Kilian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Kilian,
Have you seen these posts?
Re: How to use real time tick clock?
Re: how to config RTC use external 32.768?
BCM20736S Sleep Example Firmware
Re: Internal vs. External Oscillator
Let me know if this helps
JT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you seen these posts?
Re: How to use real time tick clock?
Looks interesting, is the Bluetooth counter incremented during deep sleep?
Re: how to config RTC use external 32.768?
This has been very helpful to me in the past, however (Re: how to config RTC use external 32.768?😞
"Entering deep sleep. when it wake up,the RTC value will be reset!
But for you output info,you RTC is not reset! Is there a methor that when into sleep, the RTC be retain and not be close?
Is it because my RTC use the RTC_REF_CLOCK_SRC_128KHZ,so it will be reset when boot_up?"
I do get a strange behaviour with the example using the external crystal too. First it draws around 650µA and the rtc keeps running and later it stops or the whole system restarts. This needs some more experimenting, but so far I haven't gotten an rtc that runs during deep sleep.
BCM20736S Sleep Example Firmware
While this is generally interesting it doesn't address anything real time clock related.
Re: Internal vs. External Oscillator
I found this pretty interesting when figuring out whether the external crystal is necessary or not.
So lets focus on the code from Re: how to config RTC use external 32.768? . I don't have the function rtc_setReferenceTime() in SDK1.1.0 . Oh now that I had a close look at it the code says:
"// 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(¤t_time);"
While "The HW clock keeps running in deep sleep" is a hopeful statement I have to go without the set reference time. This is the 12:00:00 1.4.2014 but it doesn't really matter to me whether its april or january I just need time since POR in seconds. So lets ommit that.
The code above writes the following output:
------------------------------------------------
rtc_sample_create()
Not a timed wake.
02 01 06 04 09 fb a0 03 04 0d 00 00 00 03 03 03
00
02 0a a1
bd_addr: 20732a093e05
Time base is:
Jan 0 00:00:00 0000
Power-on reset, set current time to:
Apr 1 12:00:00 2014
Fine Timer(1024 ms, 1/sec, 80 tick)
Normal Timer(1 s, 80 tick)
Number of free bytes in RAM: 14512
Current date/time is:
Apr 1 12:01:40 2014
Its been 134049700 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x003273C1
Current date/time is:
Apr 1 12:03:35 2014
Its been 134049815 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x006BDA2C
Current date/time is:
Apr 1 12:05:33 2014
Its been 134049933 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x00A6F2FB
Current date/time is:
Apr 1 12:07:32 2014
Its been 134050052 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x00E27B45
Current date/time is:
Apr 1 12:09:32 2014
Its been 134050172 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x011E2092
Current date/time is:
Apr 1 12:11:31 2014
Its been 134050291 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x0159CD30
Current date/time is:
Apr 1 12:13:30 2014
Its been 134050410 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x01957B37
Current date/time is:
Apr 1 12:15:30 2014
Its been 134050530 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x01D1259E
Current date/time is:
Apr 1 12:17:29 2014
Its been 134050649 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x020CD0C8
Current date/time is:
Apr 1 12:19:28 2014
Its been 134050768 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x02487B89
Current date/time is:
Apr 1 12:21:28 2014
Its been 134050888 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x02842537
Entering deep sleep.
rtc_sample_create()
Not a timed wake.
02 01 06 04 09 fb a0 03 04 0d 00 00 00 03 03 03
00
02 0a a1
bd_addr: 20732a093e05
Time base is:
Jan 0 00:00:00 0000
Power-on reset, set current time to:
Apr 1 12:00:00 2014
Fine Timer(1024 ms, 1/sec, 80 tick)
Normal Timer(1 s, 80 tick)
Number of free bytes in RAM: 14512
Current date/time is:
Apr 1 12:00:25 2014
Its been 134049625 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x000CB2D2
Current date/time is:
Apr 1 12:00:54 2014
Its been 134049654 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x001B1E35
Current date/time is:
Apr 1 12:01:23 2014
Its been 134049683 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x0029F792
------------------------------------------------
I would think that the result doesn't show that the RTC doesn't work but that mia_isResetReasonPor() doesn't return
the correct result. In the next experiment I should get rid of the rtc_setRTCTime() stuff and see whether that might help.
To be continued...
Kilian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Getting rid of the rtc_setRTCTime() didn't do it either.
------------------------------------------------------------------------------------
Current date/time is:
Jan 1 00:04:53 2010
Its been 293 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x0092E7AD
Current date/time is:
Jan 1 00:05:23 2010
Its been 323 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x00A1E71F
Entering deep sleep.
rtc_sample_create()
Not a timed wake.
02 01 06 04 09 fb a0 03 04 0d 00 00 00 03 03 03
00
02 0a a1
bd_addr: 20732a093e05
Time base is:
Jan 0 00:00:00 0000
Fine Timer(1024 ms, 1/sec, 80 tick)
Normal Timer(1 s, 80 tick)
Number of free bytes in RAM: 14624
Current date/time is:
Jan 1 00:00:25 2010
Its been 25 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x000CB2DD
Current date/time is:
Jan 1 00:00:54 2010
Its been 54 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x001B1E3D
------------------------------------------------------------------------------------
My only way out of the problem would be to get rid of the rtc_init as well. So lets look at the result:
------------------------------------------------------------------------------------
rtc_sample_create()
Not a timed wake.
02 01 06 04 09 fb a0 03 04 0d 00 00 00 03 03 03
00
02 0a a1
bd_addr: 20732a093e05
Fine Timer(1024 ms, 1/sec, 80 tick)
Normal Timer(1 s, 80 tick)
Number of free bytes in RAM: 14736
Current date/time is:
Jan 1 00:00:00 2010
Its been 0 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x00000000
Current date/time is:
Jan 1 00:00:00 2010
Its been 0 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x00000000
------------------------------------------------------------------------------------
The functions can read the rtc but it hasn't been started. Very nice, in a past project I had to check I initialized the data structures involved and returned an error. I wouldn't stand a chance with that now.
Fortunately we have a temperature sensor on our hardware, There are some registers on it that I can misuse as storage lets see whether I can build a replacement for mia_isResetReasonPor(). Technically I should also be able to check the RTC whether its set to the default Jan 1 00:00:00 2010. Lets do that for now.
Soldering on now...
Kilian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfortunately it turns out that calling rtc_init() only once doesn't help at all:
------------------------------------------------------------------------------------
rtc_sample_create()
Upper and lower 32 bit values: 0x00000000, 0x00000000
02 01 06 04 09 fb a0 03 04 0d 00 00 00 03 03 03
00
02 0a a1
bd_addr: 20732a093e05
Calling rtc_init()
Fine Timer(1024 ms, 1/sec, 80 tick)
Normal Timer(1 s, 80 tick)
Number of free bytes in RAM: 14816
Current date/time is:
Jan 1 00:01:40 2010
Its been 100 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x00327CB1
Current date/time is:
Jan 1 00:03:35 2010
Its been 215 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x006BEB17
Current date/time is:
Jan 1 00:05:34 2010
Its been 334 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x00A70D0C
Entering deep sleep.
rtc_sample_create()
Upper and lower 32 bit values: 0x00000000, 0x0000071B
02 01 06 04 09 fb a0 03 04 0d 00 00 00 03 03 03
00
02 0a a1
bd_addr: 20732a093e05
Fine Timer(1024 ms, 1/sec, 80 tick)
Normal Timer(1 s, 80 tick)
Number of free bytes in RAM: 14816
Current date/time is:
Jan 1 00:00:06 2010
Its been 6 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x000CB2F7
Current date/time is:
Jan 1 00:00:13 2010
Its been 13 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x001B1E9D
Current date/time is:
Jan 1 00:00:20 2010
Its been 20 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x0029F81C
Entering deep sleep.
rtc_sample_create()
Upper and lower 32 bit values: 0x00000000, 0x0000073E
02 01 06 04 09 fb a0 03 04 0d 00 00 00 03 03 03
00
02 0a a1
bd_addr: 20732a093e05
Fine Timer(1024 ms, 1/sec, 80 tick)
Normal Timer(1 s, 80 tick)
Number of free bytes in RAM: 14816
------------------------------------------------------------------------------------
As can be seen, the rtc register seems to be reset when comming out of deep sleep:
Current date/time is:
Jan 1 00:05:34 2010
Its been 334 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x00A70D0C
Entering deep sleep.
rtc_sample_create()
Upper and lower 32 bit values: 0x00000000, 0x0000071B
My code looks like the following:
------------------------------------------------------------------------------------
// Create the RTC sample.
void rtc_sample_create(void) {
RtcTime current_time;
char buffer[64];
tRTC_REAL_TIME_CLOCK raw_clock;
ble_trace0("rtc_sample_create()\n");
rtc_getRTCRawClock(&raw_clock);
ble_trace2("Upper and lower 32 bit values: 0x%08X, 0x%08X\n", raw_clock.reg32map.rtc32[1],
raw_clock.reg32map.rtc32[0]);
blecm_configFlag |= BLECM_DBGUART_LOG;
bleprofile_Init(bleprofile_p_cfg);
#ifdef RTC_SAMPLE_USE_EXSTERNAL_32K_OSC_REFERENCE
#endif
rtc_getRTCRawClock(&raw_clock);
if (raw_clock.reg32map.rtc32[0] == 0x0){
ble_trace0("Calling rtc_init()\n");
// If we need to use the external 32K, then configure the reference
rtcConfig.oscillatorFrequencykHz = RTC_REF_CLOCK_SRC_32KHZ;
#ifdef RTC_SAMPLE_USE_EXSTERNAL_32K_OSC_REFERENCE
// Since the 32K external LPO is connected tp P10, P11, P12, P26 and P27,
// input and putput disable all 5 GPIOs.
gpio_configurePin(0, 10, GPIO_INPUT_DISABLE, 0);
gpio_configurePin(0, 11, GPIO_INPUT_DISABLE, 0);
gpio_configurePin(0, 12, GPIO_INPUT_DISABLE, 0);
gpio_configurePin(1, 10, GPIO_INPUT_DISABLE, 0);
gpio_configurePin(1, 11, GPIO_INPUT_DISABLE, 0);
#endif
rtc_init();
}
// Initialize the RTC.
//
bleprofile_regTimerCb(rtc_sample_fine_timeout, rtc_sample_timeout);
bleprofile_StartTimer();
#ifdef RTC_SAMPLE_USE_EXSTERNAL_32K_OSC_REFERENCE
// Since we have an external 32 KHz LPO, switch to using this during sleep
// because this will give us a more accurate sleep clock (lower drift than the
// internal LPO, so the uncertainty window during a receive will be narrower).
// In general, base sleep current will be lower too.
// Switching to the external 32K with bleapputils_changeLPOSource without having
// initialized the RTC, the bonded GPIOs and not having the 32KHz oscillator physically
// connected to the chip will invoke undefined behavior.
bleapputils_changeLPOSource(LPO_32KHZ_OSC, FALSE, 250);
#endif
// Trace out number of bytes free.
ble_trace1("Number of free bytes in RAM: %d", cfa_mm_MemFreeBytes());
}
------------------------------------------------------------------------------------
The rest is pretty much the same as in the original. I have run out of ideas for now I hope you can help.
Regards,
Kilian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Reading Re: how to config RTC use external 32.768? again I find that:
- You need the external 32K xtal hooked up to P26/P27 or comment out the use 32K #define to use the internal 128K instead – This is not very accurate so it will drift within minutes).
- Backup and replace Wiced-Smart/tier2 directory with the files in the attached .zip file.
- Create <SDK>/Apps/rtc_sample/ and place the rtc_sample.c and makefile.mk in it.
- Create a make target called rtc_sample-BCM92073xTAG_Q32, then build and download.
- Hook up P0 to GND
Needs more consideration from my side:
- Ok, can verify with a scope that the external oscillator works.
- Where is the attached zip file?
- Did that.
- Did that.
- Oops, we have an LED connected to it, let me check this again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Connecting P0 to GND didn't change the situation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Because I noticed that without bleapputils_changeLPOSource() the external oscillator doesn't start I decided to check the above idea with the 128kHz oscillator but it didn't change the fact that the RTC is reset:
------------------------------------------------------------------------------------
Current date/time is:
Jan 1 00:01:28 2010
Its been 88 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x00B1A1BD
Entering deep sleep.
rtc_sample_create()
Upper and lower 32 bit values: 0x00000000, 0x00005553
02 01 06 04 09 fb a0 03 04 0d 00 00 00 03 03 03
00
02 0a a1
bd_addr: 20732a093e05
Fine Timer(1024 ms, 1/sec, 80 tick)
Normal Timer(1 s, 80 tick)
Number of free bytes in RAM: 14912
Current date/time is:
Jan 1 00:00:29 2010
Its been 29 seconds since bigbang.
Upper and lower 32 bit values: 0x00000000, 0x003AB491
------------------------------------------------------------------------------------
So, I have run out of ideas. If the zip file you have been talking about exists, maybe it can help.
Regards,
Kilian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'll talk to the SW team to see if they have any ideas regarding next steps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Kilian,
Was this ever resolved?
Thanks
JT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This hasn't been resolved. My next experiment is with an 20737S in our hardware (so far porting efforts went great). If it doesn't work then we have to check our hardware.
EDIT:
I just checked with the 20737S based Hardware and the rtc_example from SDK 2.2.1 works fine.
09:43:10 - Current date/time is:
09:43:10 - Jul 15 12:04:13 2014
09:43:10 - Its been 143121853 seconds since bigbang.
09:43:10 - Upper and lower 32 bit values: 0x00000000, 0x007EC8CF
09:43:11 -
09:43:11 - Current date/time is:
09:43:11 - Jul 15 12:04:14 2014
09:43:11 - Its been 143121854 seconds since bigbang.
09:43:11 - Upper and lower 32 bit values: 0x00000000, 0x007F48C4
09:43:11 -
09:43:11 - Entering deep sleep.
09:43:16 - rtc_sample_create()
09:43:16 -
09:43:16 - Waking from deep sleep because the timer went off or a GPIO triggered while waiting for timer to expire.
09:43:16 - 020106030304000409bb8104
09:43:16 - 020a81
09:43:16 - Time base is:
09:43:16 - Jan 0 00:00:00 0000
09:43:16 - Number of free bytes in RAM: 27012
09:43:16 -
09:43:16 - blecm evt handler:
09:43:16 - 0e0401082000
09:43:16 -
09:43:16 - blecm evt handler:
09:43:16 - 0e0401092000
09:43:16 bd_addr[5:2] = 20 73 7A 1A
09:43:16 bd_addr[1:0] = B2DA 00
09:43:16 Fine Timer(1024 ms, 1/sec)
09:43:16 Fine TImer tick 80
09:43:16 Normal Timer(0 s, 0 tick)
09:43:17 - Current date/time is:
09:43:17 - Jul 15 12:04:20 2014
09:43:17 - Its been 143121860 seconds since bigbang.
09:43:17 - Upper and lower 32 bit values: 0x00000000, 0x00826928
09:43:18 -
09:43:18 - Current date/time is:
09:43:18 - Jul 15 12:04:21 2014
09:43:18 - Its been 143121861 seconds since bigbang.
09:43:18 - Upper and lower 32 bit values: 0x00000000, 0x0082E91E
If you think backporting features from SDK 2.2.1 or finding other solutions to resolve the issue is possible I would be glad to hear about it.
Regards,
Kilian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, we have decided to go with the 20737S. This was my attempt to see whether we can get the RTC in the 20732S to work at all or whether we better switch. We switched to the 20737S. Beyond that there are many more reasons switch than just the RTC, i.e.
- stuck at SDK 1.x
- more missing features (central role, crypto aspects, ...)
- having to support multiple platforms
I'm sure one can use it for some applications, but for us it is too limiting.
Regards,
Kilian