external 32KHz crystal calibration time

Seungwhan
Posts: 19
Joined: Mon Jul 29, 2019 11:23 pm

external 32KHz crystal calibration time

Postby Seungwhan » Wed Oct 30, 2019 5:59 am

This is duplicate of https://esp32.com/viewtopic.php?f=13&t=12893 that I posted on ESP32 IDF forum.
Copying here since I got 0 reply there and just wanted to make sure if I posted it on to the right forum.

So when you enable external 32KHz crystal, it will perform calibration during booting.
https://github.com/espressif/esp-idf/bl ... clk.c#L186

I modified rtc_clk_cal_internal()(which is a function that actually does the calibration) to measure how long does the calibration take.
And when SLOW_CLK_CAL_CYCLES was set to 3276, it was about ~100ms.

But when we run our app(both bootloader and app) it takes about 300ms ~ 500ms.

Hardware is ok.
Because when we run esp-idf's example app, everything is normal.

What could possibly affect the calibration time?

One more thing to note is that if I turn off CONFIG_TASK_WDT menuconfig option,
calibration time in our app comes back to normal.
But turning that option on or off in the example app didn't affect the calibration time.

Any comment would be appreciated.
Thank you.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: external 32KHz crystal calibration time

Postby WiFive » Wed Oct 30, 2019 6:11 am

Did you compare the sdkconfig? Where exactly does it get stuck for 500ms?

Seungwhan
Posts: 19
Joined: Mon Jul 29, 2019 11:23 pm

Re: external 32KHz crystal calibration time

Postby Seungwhan » Wed Oct 30, 2019 5:48 pm

Didn't do diff on sdkconfig, yet.
Good point. I'll do that sometime soon.

And this is where it takes longer.
https://github.com/espressif/esp-idf/bl ... time.c#L94
It's meant to timeout there, but I modified the code a little so that it doesn't timeout and measure the time instead.

Something is happening under the hood after you set TIMG_RTC_CALI_START bit.
So there's no way I can go deeper than this to figure out what's possibly causing this.

Any comments or recommendations are welcome.

Who is online

Users browsing this forum: No registered users and 39 guests