For ESP-IDF v3.2 in combination with Adafruit HUZZAH32 (ESP32-WROOM-32 module).
This question is about the technical documentation and configuring an external 32Khz oscillator in EDP-IDF.
I'm searching for instructions on how to use an external 32Khz oscillator output signal as input for the ESP32_RTC_CLOCK_SOURCE. I have found instructions in various places but they are different from each other.
Let's first explain my current setup which is working fine; I think I created this setup a year ago. I'm using a DS3231 RTC and an ESP32 dev board and other parts. The RTC is primarily used to keep the current datetime for datalogger projects, but it also has an accurate 32Khz output signal which I use as input signal for the ESP32_RTC_CLOCK_SOURCE which is used during deep sleep. The documentation can be found here: https://github.com/pantaluna/esp32_ds32 ... 20ESP32.md In summary:
Code: Select all
- Connect RTC pin VCC => microcontroller pin VCC 3.3V
- Connect RTC pin GND => microcontroller pin GND
- Connect RTC pin "32K" => 10K pullup resistor => microcontroller pin VCC 3.3V (this is specific for the DS3231)
- Connect RTC pin "32K" => microcontroller pin GPIO#33 (ESP32 pin 32K_XN)
- ESP32 pin 32K_XP GPIO#32 is not connected.
- Menuconfig: "(*) External 32kHz oscillator at 32K_XP pin" (yes, I'm not using the 32K_XP pin).
The esp32_hardware_design_guidelines.pdf:
The esp32-wroom-32_datasheet.pdf:
The Menuconfig: "(*) External 32kHz oscillator at 32K_XP pin":
Code: Select all
help
- "External 32kHz oscillator" allows using 32kHz clock generated by an
external circuit. In this case, external clock signal must be connected
to 32K_XP pin. Amplitude should be <1.2V in case of sine wave signal,
and <1V in case of square wave signal. Common mode voltage should be
0.1 < Vcm < 0.5Vamp, where Vamp is the signal amplitude.
Additionally, 1nF capacitor must be connected between 32K_XN pin and
ground. 32K_XN pin can not be used as a GPIO in this case.
So I have conducted some tests to see which ones are working in combination with the DS3231. The tests were performed on a breadboard.
Test#1 (my setup):
- Menuconfig: "(*) External 32kHz oscillator at 32K_XP pin"
- RTC board pin "32K" => 10K pullup resistor => MCU VCC 3.3V (this is specific for the DS3231)
- MCU GPIO#33 32K_XN => RTC board pin "32K"
- MCU GPIO#32 32K_XP not connected.
```
Code: Select all
D (454) clk: waiting for 32k oscillator to start up
D (521) clk: RTC_SLOW_CLK calibration value: 15999987
Result: Ok. The external signal is used. The ESP32 returns from deep sleep.
Test#2 (the setup of esp32_hardware_design_guidelines.pdf):
- Menuconfig: "(*) External 32kHz oscillator at 32K_XP pin"
- RTC board pin "32K" => 10K pullup resistor => MCU VCC 3.3V (this is specific for the DS3231)
- MCU GPIO#33 32K_XN => RTC board pin "32K"
- MCU GPIO#33 32K_XP => 10nF/50nF cap => GND (all cap values were tested)
```
Code: Select all
D (453) clk: waiting for 32k oscillator to start up
D (521) clk: RTC_SLOW_CLK calibration value: 15999989
Result: Error. The external signal is used. But the ESP32 never returns from deep sleep.
Test#3 (the setup as described in the online help of KConfig ESP32_RTC_CLOCK_SOURCE):
- Menuconfig: "(*) External 32kHz oscillator at 32K_XP pin"
- RTC board pin "32K" => 10K pullup resistor => MCU VCC 3.3V (this is specific for the DS3231)
- MCU GPIO#33 32K_XP => RTC board pin "32K"
- MCU GPIO#33 32K_XN => 10nF/50nF cap => GND (all cap values were tested)
```
Code: Select all
D (454) clk: waiting for 32k oscillator to start up
W (539) clk: 32 kHz XTAL not found, switching to internal 150 kHz oscillator
D (547) clk: RTC_SLOW_CLK calibration value: 3133542
Result: Error. The external signal is not used; it reverts back to the internal 150 kHz oscillator. The ESP32 returns from deep sleep but it used the internal 150 kHz oscillator.
=> To conclude, can you please help me out?
- What is the correct hardware setup for an external 32Khz oscillator signal?
- Should MCU GPIO#33 32K_XP be left not-connected when wiring an external oscillator to MCU GPIO#33 32K_XN? So the pin cannot be used for other purposes in this case?
- Is it possible that the DS32131 RTC is not suitable for this task?
- Should I upgrade to ESP-IDF v3.3?