Page 1 of 1

ESP32 External RTC 32K

Posted: Tue Sep 26, 2017 1:11 am
by mrrosen
I have a board built by our team that is using an external clock source (not a crystal) for the external ESP32 RTC clock (32K). The source goes into XTAL32KP with XTAL32KN disconnected. However, whenever I set the CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL to y via menuconfig in sdkconfig and build our project which uses the 2nd stage bootloader and am getting this message:

clk: still waiting for 32k oscillator to start up

Two questions:
1) Can the ESP32 use a single ended clock source for the 32K external input?
2) Is there more I have to do (if the answer to #1 is yes) to enable using this clock source in the IDF? (I have a version of the IDF from June 2017; I would provide a commit but the repo we are using has had its history erased in transfer :( )

Re: ESP32 External RTC 32K

Posted: Fri Oct 06, 2017 8:43 pm
by mrrosen
Im still trying to get this to work, so I flashed the unit test application onto a few of our boards and scoped the signals. I tried running the rtc_clk unit tests and would get one of two possible outcomes from calibration:

Code: Select all

calibrate (0): 34.728 kHz
calibrate (1): 34.730 kHz
calibrate (2): 34.733 kHz
calibrate (3): 34.733 kHz
calibrate (4): 34.731 kHz
RTC_CAL_8MD256:
calibrate (0): 34.731 kHz
calibrate (1): 34.729 kHz
calibrate (2): 34.726 kHz
calibrate (3): 34.728 kHz
calibrate (4): 34.727 kHz
RTC_CAL_32K_XTAL:
calibrate (0): inf kHz
calibrate (1): inf kHz
calibrate (2): inf kHz
calibrate (3): inf kHz
calibrate (4): inf kHz
32K XTAL OSC has not started upswitching to RTC_SLOW_FREQ_8MD256: done
RTC_CAL_RTC_MUX:
calibrate (0): 34.725 kHz
calibrate (1): 34.726 kHz
calibrate (2): 34.729 kHz
calibrate (3): 34.729 kHz
calibrate (4): 34.725 kHz
RTC_CAL_8MD256:
calibrate (0): 34.728 kHz
calibrate (1): 34.727 kHz
calibrate (2): 34.729 kHz
calibrate (3): 34.731 kHz
calibrate (4): 34.732 kHz
RTC_CAL_32K_XTAL:
calibrate (0): inf kHz
calibrate (1): inf kHz
calibrate (2): inf kHz
calibrate (3): inf kHz
calibrate (4): inf kHz
Or:

Code: Select all

RTC_CAL_RTC_MUX:
calibrate (0): 34.728 kHz
calibrate (1): 34.727 kHz
calibrate (2): 34.726 kHz
calibrate (3): 34.727 kHz
calibrate (4): 34.726 kHz
RTC_CAL_8MD256:
calibrate (0): 34.728 kHz
calibrate (1): 34.730 kHz
calibrate (2): 34.730 kHz
calibrate (3): 34.728 kHz
calibrate (4): 34.731 kHz
RTC_CAL_32K_XTAL:
calibrate (0): 32.768 kHz
calibrate (1): 32.768 kHz
calibrate (2): 32.767 kHz
calibrate (3): 32.768 kHz
calibrate (4): 32.768 kHz
switching to RTC_SLOW_FREQ_32K_XTAL: done
RTC_CAL_RTC_MUX:
calibrate (0): 32.768 kHz
calibrate (1): 32.767 kHz
calibrate (2): 32.768 kHz
calibrate (3): 32.767 kHz
calibrate (4): 32.768 kHz
RTC_CAL_8MD256:
calibrate (0): 34.730 kHz
calibrate (1): 34.731 kHz
calibrate (2): 34.731 kHz
calibrate (3): 34.729 kHz
calibrate (4): 34.731 kHz
RTC_CAL_32K_XTAL:
calibrate (0): 32.767 kHz
calibrate (1): 32.768 kHz
calibrate (2): 32.768 kHz
calibrate (3): 32.768 kHz
calibrate (4): 32.768 kHz
switching to RTC_SLOW_FREQ_8MD256: done
RTC_CAL_RTC_MUX:
calibrate (0): 34.733 kHz
calibrate (1): 34.733 kHz
calibrate (2): 34.734 kHz
calibrate (3): 34.737 kHz
calibrate (4): 34.737 kHz
RTC_CAL_8MD256:
calibrate (0): 34.735 kHz
calibrate (1): 34.734 kHz
calibrate (2): 34.735 kHz
calibrate (3): 34.736 kHz
calibrate (4): 34.735 kHz
RTC_CAL_32K_XTAL:
calibrate (0): 32.767 kHz
calibrate (1): 32.768 kHz
calibrate (2): 32.767 kHz
calibrate (3): 32.768 kHz
calibrate (4): 32.768 kHz
In both cases, if I try to run the "Output 32k XTAL clock to GPIO25", I get a flat line while probing the XTAL_32KP line gets me the 32KHz clock as expected. Im maybe getting some noise one the 32K clock but I have to confirm with out hardware engineer if my setup is just a bit noisy. Other than that, even if it succeeds to calibrate, why am I getting a flat line on GPIO25?

Re: ESP32 External RTC 32K

Posted: Thu Oct 12, 2017 11:16 am
by Shcreasey
We also want to do this, any information regarding its viability would be appreciated.

If it is possible to use an externally generated clock to supply just XTAL_32k_P, can XTAL_32k_N be reused as a GPIO?

Thanks

Re: ESP32 External RTC 32K

Posted: Thu Dec 07, 2017 10:19 pm
by mrrosen
We contacting ESP32 support directly and the response we got back told us to connect the XTAL32KN line to the oscillator, not the XTAL32KP line. We are going to try a rework to see if this fixes the strange issues we are seeing, so no definitive answers on this yet; but just for others looking for answers, this is what we have for now :)

Re: ESP32 External RTC 32K

Posted: Fri Dec 08, 2017 4:31 am
by ESP_igrr

Re: ESP32 External RTC 32K

Posted: Tue Dec 12, 2017 6:05 pm
by mrrosen
As promised, a short update. We tried disconnecting our oscillator from the XTAL32KP and connected the XTAL32KN line to a function generator at 32.768KHz and it worked perfectly.

So, as with what ESP_iggr mentioned in the linked github issue; you must use the XTAL32KN line for the input of the oscillator if you arent using a crystal.