External 32kHz Crystal Calibration During Deep Sleep Wake Up?

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

External 32kHz Crystal Calibration During Deep Sleep Wake Up?

Postby vonnieda » Fri Aug 27, 2021 4:18 pm

Hi all,

I'm working on decreasing my deep sleep wakeup time. Currently the longest part of the process seems to be calibrating the 32kHz external crystal I'm using for RTC. With the recommended calibration cycles of 3000 it takes about 200ms.

I believe I understand all the menuconfig options for this. I know I can decrease it to lower startup time, but my question is: Why is calibration happening during deep sleep wakeup at all?

On cold boot it makes sense to calibrate the crystal, but when waking from deep sleep, presumably the crystal has been ticking along keeping time, so why recalibrate it when waking?

Here are the related sdkconfig options I'm using:

Code: Select all

RTC clock source: External 32kHz crystal
Number of cycle for RTC_SLOW_CLK calibration: 3000
And logs from my test app:

Code: Select all

W (568) clk: waiting for 32k oscillator to start up
W (631) clk: RTC_SLOW_CLK calibration value: 16000576
671
going to sleep
W (26) clk: waiting for 32k oscillator to start up
W (89) clk: RTC_SLOW_CLK calibration value: 16000589
129
waking up
going to sleep
W (26) clk: waiting for 32k oscillator to start up
W (89) clk: RTC_SLOW_CLK calibration value: 16000576
Note, I have changed the log level of the "waiting for 32k" line to warning so I can disable most other logging and still see it.

Thanks,
Jason

boarchuz
Posts: 605
Joined: Tue Aug 21, 2018 5:28 am

Re: External 32kHz Crystal Calibration During Deep Sleep Wake Up?

Postby boarchuz » Fri Aug 27, 2021 6:04 pm

The assumption is probably that most users prefer a more accurate clock over a faster wakeup, especially when using the internal oscillator.

You're better off skipping calibration in your case.

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

Re: External 32kHz Crystal Calibration During Deep Sleep Wake Up?

Postby vonnieda » Fri Aug 27, 2021 6:21 pm

boarchuz wrote:
Fri Aug 27, 2021 6:04 pm
The assumption is probably that most users prefer a more accurate clock over a faster wakeup, especially when using the internal oscillator.

You're better off skipping calibration in your case.
Thanks for your response, I don't think this applies. I'm not using the internal oscillator. I'm referring specifically to calibration happening during deep sleep wakeup. The question is: Why is calibration run during deep sleep wakeup when the calibration was already done during cold boot and the crystal has kept running while in deep sleep.

Thanks,
Jason

Who is online

Users browsing this forum: No registered users and 325 guests