ESP32 External 32.768kHZ Crystal for RTC

dalbert
Posts: 7
Joined: Wed Nov 16, 2016 3:45 am

Re: ESP32 External 32.768kHZ Crystal for RTC

Postby dalbert » Fri Apr 12, 2024 4:54 am

Something to be aware of:
The ESP32 r1 and r3 require different loading for the crystal oscillator.
I use a 6pF 3.2x1.5mm 2-SMD crystal with two loading caps, all located close to the XO pins and following good layout practices.
My older boards built with ESP32 r1 require at least 10pF load capacitors to start reliably
My newer boards built with ESP32 r3 *require* a parallel R (2-10M) and won't start without it; they work best (closest to nominal freq) with 6pF or slightly lower load caps.

Support for an external 32kHz xtal is very important for many embedded applications; it would be great if Espressif would provide more documentation and design guidance for the low speed XO.

k3rnell
Posts: 2
Joined: Tue Aug 13, 2024 9:34 am

Re: ESP32 External 32.768kHZ Crystal for RTC

Postby k3rnell » Tue Aug 13, 2024 9:52 am

xerom32 wrote:
Tue Jan 02, 2024 7:02 pm
Otherwise it seems to work great.
dovov97815 wrote:
Thu Jan 12, 2023 7:25 am
This code is working fine for rtc external crystal selection, without building esp-idf library for arduino. Could you please confirm that it is working with your hardware setup, Or any mistake in this.
dalbert wrote:
Fri Apr 12, 2024 4:54 am
Something to be aware of: [...] My newer boards built with ESP32 r3 *require* a parallel R (2-10M) and won't start without it; they work best (closest to nominal freq) with 6pF or slightly lower load caps.

@xerom32, @dovov97815, @dalbert, could You please share also your IDE config with Arduino Core version used?

I've a esp32-wroom-32e with 32.768k 12.5pF crystal, two 22pF caps and parallel 10M resistor and can't get it running.
I'm using the 3.0.4 Arduino core so I need to slightly modify dovov97815 code by changing the include from #include "esp_deep_sleep.h" to #include "esp_sleep.h" and also the function esp_deep_sleep_pd_config to esp_sleep_pd_config but it should not influence the clock running.

I get the following logs:

Code: Select all

ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1448
load:0x40078000,len:14828
ho 0 tail 12 room 4
load:0x40080400,len:4
load:0x40080404,len:3356
entry 0x4008059c
Boot number: 1
Wakeup was not caused by deep sleep: 0
Slow clk source: Internal 150kHz
First boot, bootstrap and enable 32k XTAL
Fast Clk: 40MHz
RTC_CAL_32K_XTAL:
calibrate (0): inf kHz
calibrate (1): inf kHz
calibrate (2): inf kHz
calibrate (3): inf kHz
calibrate (4): inf kHz
Waiting for 32kHz clock to be stable: inf kHz

[..........................]
[several time as above and finally...]


OSC Not Enabled, using Internal 150KHz RC
Slow clk source: Internal 150kHz
Setup ESP32 to sleep for every 5 Seconds
Configured peripheral power
Going to sleep now, rtc ticks: 2633970
ets Jul 29 2019 12:21:46

rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1448
load:0x40078000,len:14828
ho 0 tail 12 room 4
load:0x40080400,len:4
load:0x40080404,len:3356
entry 0x4008059c
Boot number: 2
Wakeup caused by timer
Slow clk source: Internal 150kHz
Wake from deepsleep, not jumping XTAL.
rtc sleep reg0: 3422140
rtc sleep reg1: 0
Setup ESP32 to sleep for every 5 Seconds
Configured peripheral power
Going to sleep now, rtc ticks: 3519912
E (687) rtc_time: 32kHz xtal has been stopped
ets Jul 29 2019 12:21:46

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1448
load:0x40078000,len:14828
ho 0 tail 12 room 4
load:0x40080400,len:4
load:0x40080404,len:3356
entry 0x4008059c
ets Jul 29 2019 12:21:46
Can anyone give me some tips what's going on? Thanks in advance!

Who is online

Users browsing this forum: No registered users and 114 guests