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

papaluna
Posts: 47
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 488 times

The esp32-wroom-32_datasheet.pdf:
esp32-wroom-32_datasheet_en.jpg
esp32-wroom-32_datasheet_en.jpg (103.23 KiB) Viewed 488 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: 2623
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: 47
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: 2813
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: 13
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

Who is online

Users browsing this forum: No registered users and 6 guests