Need guidelines: wiring and configuring an external 32Khz oscillator input in EDP-IDF

papaluna
Posts: 50
Joined: Tue Jan 30, 2018 11:27 am

Need guidelines: wiring and configuring an external 32Khz oscillator input in EDP-IDF

Postby papaluna » Mon May 20, 2019 8:30 am

Hi,
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).
But if I read the latest documentation about RTC clock sources in the esp32_hardware_design_guidelines.pdf and esp32-wroom-32_datasheet.pdf and esp32_technical_reference_manual.pdf and KConfig online help (section ESP32_RTC_CLOCK_SOURCE) then the instructions are significantly different from each other. So I do not know which one is correct and if my own setup is still supported. I'm probably not understanding things correctly.


The esp32_hardware_design_guidelines.pdf:
esp32_hardware_design_guidelines_en.jpg
esp32_hardware_design_guidelines_en.jpg (37.21 KiB) Viewed 18458 times

The esp32-wroom-32_datasheet.pdf:
esp32-wroom-32_datasheet_en.jpg
esp32-wroom-32_datasheet_en.jpg (103.23 KiB) Viewed 18458 times

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?
--
Paul.

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

Re: Need guidelines: wiring and configuring an external 32Khz oscillator input in EDP-IDF

Postby WiFive » Mon May 20, 2019 9:19 am

Amplitude should be <1.2V in case of sine wave signal, and <1V in case of square wave signal.
- Connect RTC pin "32K" => 10K pullup resistor => microcontroller pin VCC 3.3V (this is specific for the DS3231)

papaluna
Posts: 50
Joined: Tue Jan 30, 2018 11:27 am

Re: Need guidelines: wiring and configuring an external 32Khz oscillator input in EDP-IDF

Postby papaluna » Mon May 20, 2019 6:56 pm

Hi WIfive,
Thanks for the review!

I have created a 0.8V power rail and used that for the pullups in this test.

Test#1 (my production setup):
- Menuconfig: "(*) External 32kHz oscillator at 32K_XP pin"
- RTC board pin "32K" => 10K pullup resistor => Power rail 0.8V (this pullup 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: 16000000
Result: Ok (same result as before). 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 => Power rail 0.8V (this pullup is specific for the DS3231)
- MCU GPIO#33 32K_XN => RTC board pin "32K"
- MCU GPIO#33 32K_XP => 10nF/50nF cap => GND (each cap value was tested)

Code: Select all

D (454) clk: waiting for 32k oscillator to start up
D (521) clk: RTC_SLOW_CLK calibration value: 15999987
Result: Error (same as before). 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 => Power rail 0.8V (this pullup is specific for the DS3231)
- MCU GPIO#33 32K_XP => RTC board pin "32K"
- MCU GPIO#33 32K_XN => 10nF/50nF cap => GND (each cap value was tested)

Code: Select all

D (454) clk: waiting for 32k oscillator to start up
D (521) clk: RTC_SLOW_CLK calibration value: 16000000
Result: Ok (**now it works!**). The external signal is used. The ESP32 returns from deep sleep.


=> The Test#3 (the setup as described in the online help of KConfig ESP32_RTC_CLOCK_SOURCE) works correctly. The Test#2 (the setup of esp32_hardware_design_guidelines.pdf) fails.

The schematic "Figure 7: Schematic of External Oscillatorin" in esp32_hardware_design_guidelines.pdf is probably wrong or incomplete (pins swapped?).

I will change the PCB to what is described under Test#3. It means adding more external components (0.8V) but that is fine.
--
Paul.

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

Re: Need guidelines: wiring and configuring an external 32Khz oscillator input in EDP-IDF

Postby ESP_Sprite » Tue May 21, 2019 1:40 am

Moved to hardware subforum.

FrancisL
Posts: 21
Joined: Wed Jul 25, 2018 3:34 pm

Re: Need guidelines: wiring and configuring an external 32Khz oscillator input in EDP-IDF

Postby FrancisL » Wed Sep 11, 2019 9:17 am

Hello,

The situation looks quite confusing: do we have to connect an external 32,768 oscillator onto 32K_XN or 32K_XP?
The 'menuconfig' options still looks in conflict with the hardware guidelines document..

In this case (external oscillator connected to the right pin), is the other pin available as a GPIO.

Thanks,
Francis

jimparis
Posts: 7
Joined: Fri Jun 15, 2018 7:29 pm

Re: Need guidelines: wiring and configuring an external 32Khz oscillator input in EDP-IDF

Postby jimparis » Sat Jun 19, 2021 7:00 pm

FYI, the relevant comments in Kconfig were changed a couple weeks after your question, so it looks like the hardware guide and code now agree that you should connect it to 32K_XN.
https://github.com/espressif/esp-idf/co ... d550ef8769

edit: However, they still disagree on amplitude. Hardware guide says 0.6 < Vpp < VDD, code comments say Vpp < 1.0.

I have a 3.3V amplitude 32.768 kHz square wave going into 32K_XN, with a 1nF cap on 32K_XP, and it mostly works, but my boards are randomly freezing and crashing after a few days, so maybe the hardware guide is wrong.

ESP_LJH
Posts: 387
Joined: Tue May 18, 2021 9:21 am

Re: Need guidelines: wiring and configuring an external 32Khz oscillator input in EDP-IDF

Postby ESP_LJH » Tue Jun 22, 2021 4:12 am

Hello, we are testing about connecting to an external 32.768 khz oscillator and we will update hardware design guideline later, here are some results for you to refer, clock signal will be input to 32K_XN:
1. sinc wave, 0~3.3 V, with/without cap at 32K_XP, but it is suggested to add cap;
2. square wave, lowest value is about 200 mV, it is suggested to add cap at 32K_XP;
3. square wave, add a pullup ( e.g. 470 K ) at 32K_XP.
Please be noted that these results are not from mass quantity test.

Hugo_NV
Posts: 3
Joined: Thu Aug 19, 2021 6:03 am

Re: Need guidelines: wiring and configuring an external 32Khz oscillator input in EDP-IDF

Postby Hugo_NV » Thu Aug 19, 2021 6:06 am

ESP_LJH wrote:
Tue Jun 22, 2021 4:12 am
Hello, we are testing about connecting to an external 32.768 khz oscillator and we will update hardware design guideline later, here are some results for you to refer, clock signal will be input to 32K_XN:
1. sinc wave, 0~3.3 V, with/without cap at 32K_XP, but it is suggested to add cap;
2. square wave, lowest value is about 200 mV, it is suggested to add cap at 32K_XP;
3. square wave, add a pullup ( e.g. 470 K ) at 32K_XP.
Please be noted that these results are not from mass quantity test.
Hi ESP_LJH,

Can you provide more details on these results, specifically how the ESP32 performs when there is NOT a capacitor connected to 32K_XP. What is the effect of the capacitor and why is it suggested?

Has the hardware design guideline document been updated?

Thank you.
Last edited by Hugo_NV on Thu Aug 19, 2021 10:08 pm, edited 1 time in total.

Hugo_NV
Posts: 3
Joined: Thu Aug 19, 2021 6:03 am

Re: Need guidelines: wiring and configuring an external 32Khz oscillator input in EDP-IDF

Postby Hugo_NV » Thu Aug 19, 2021 6:08 am

Hi ESP_LJH,

Can you provide more details on the results of the testing, specifically the impact of NOT fitting the capacitor to 32K_XP? Have the hardaware design guidelines been updated to show the results of these tests?

Thank you.

ESP_LJH
Posts: 387
Joined: Tue May 18, 2021 9:21 am

Re: Need guidelines: wiring and configuring an external 32Khz oscillator input in EDP-IDF

Postby ESP_LJH » Thu Aug 19, 2021 9:34 am

Hello, cap is used for stability but from our test results, there is no difference with/-out cap.
As for hardware design guideline updating, recently we have no such plan.

Who is online

Users browsing this forum: pmi2410 and 100 guests