external 32khz crystal

imtiaz
Posts: 106
Joined: Wed Oct 26, 2016 1:34 am

external 32khz crystal

Postby imtiaz » Thu Mar 30, 2017 10:23 pm

Hi Espressiff @ESP_igrr @ESP_Angus,

Is there a way to test the 32Khz external crystal is working? We are getting modules made and at present the s/w doesnt seem to support using the external crystal rather than the internal 150Khz RC.

Thanks
Imtiaz

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: external 32khz crystal

Postby ESP_igrr » Fri Mar 31, 2017 2:52 am

I'll post a code snippet here, it will enable 32k xtal and connect the oscillator output to GPIO25. Then you can check the output and startup time on the scope.

Code: Select all

    #include "soc/rtc_io_reg.h"
    #include "soc/sens_reg.h"
    
    SET_PERI_REG_MASK(RTC_IO_XTAL_32K_PAD_REG, RTC_IO_X32N_MUX_SEL | RTC_IO_X32P_MUX_SEL);
    CLEAR_PERI_REG_MASK(RTC_IO_XTAL_32K_PAD_REG, RTC_IO_X32P_RDE | RTC_IO_X32P_RUE | RTC_IO_X32N_RUE | RTC_IO_X32N_RDE);
    CLEAR_PERI_REG_MASK(RTC_IO_XTAL_32K_PAD_REG, RTC_IO_X32N_MUX_SEL | RTC_IO_X32P_MUX_SEL);
    SET_PERI_REG_BITS(RTC_IO_XTAL_32K_PAD_REG, RTC_IO_DAC_XTAL_32K, 1, RTC_IO_DAC_XTAL_32K_S);
    SET_PERI_REG_BITS(RTC_IO_XTAL_32K_PAD_REG, RTC_IO_DRES_XTAL_32K, 3, RTC_IO_DRES_XTAL_32K_S);
    SET_PERI_REG_BITS(RTC_IO_XTAL_32K_PAD_REG, RTC_IO_DBIAS_XTAL_32K, 0, RTC_IO_DBIAS_XTAL_32K_S);
    SET_PERI_REG_MASK(RTC_IO_XTAL_32K_PAD_REG, RTC_IO_XPD_XTAL_32K);
    REG_SET_BIT(RTC_IO_PAD_DAC1_REG, RTC_IO_PDAC1_MUX_SEL_M);
    REG_CLR_BIT(RTC_IO_PAD_DAC1_REG, RTC_IO_PDAC1_RDE_M | RTC_IO_PDAC1_RUE_M);
    REG_SET_FIELD(RTC_IO_PAD_DAC1_REG, RTC_IO_PDAC1_FUN_SEL, 1);
    REG_SET_FIELD(SENS_SAR_DAC_CTRL1_REG, SENS_DEBUG_BIT_SEL, 0);
    const uint8_t sel = 4; /* sel = 4 : 32k XTAL; sel = 5 : internal 150k RC */
    REG_SET_FIELD(RTC_IO_RTC_DEBUG_SEL_REG, RTC_IO_DEBUG_SEL0, sel);
Note that we are observing issues on some boards with 32k xtal startup time... That's part of the reason why you don't see 32k xtal support in master yet. We are now working these issues.

User avatar
supersat
Posts: 10
Joined: Tue Apr 11, 2017 10:17 pm

Re: external 32khz crystal

Postby supersat » Fri Jun 02, 2017 12:45 am

Now that there's support for an external 32.768kHz crystal in the IDF, have the start-up issues been resolved? I've noticed my board will say "still waiting for 32k oscillator to start up," and eventually it will either boot or hang. However, using the above code snippet, I do see a 32kHz square wave on GPIO25. Is there a potential hardware change I need to make to get the external crystal to work reliably?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: external 32khz crystal

Postby ESP_igrr » Fri Jun 02, 2017 12:55 am

The issue we had was due to the fact that the 1st and 2nd revisions of ESP-WROVER-KIT boards had an incorrect value of capacitors connected to XTAL pins. This was fixed in the 3rd revision of the board. With a custom board, check the values you are using.

nissim@TelnT.com
Posts: 4
Joined: Fri Jun 02, 2017 10:19 am

Re: external 32khz crystal

Postby nissim@TelnT.com » Fri Jun 02, 2017 10:27 am

Since ESP-WROVER-KIT 3rd revision is not found, can you share the URL link to its documentation or the capacitors values of the 32.768KHz crystal?
It is not clear if they are 12P or 27P ...
Dr. Nissim Zur
Consultant design house for Artificial Intelligence
Internet of Things ("IoT") wireless devices.

http://www.TelnT.com
nissim@TelnT.com

Snedig
Posts: 24
Joined: Sat Apr 04, 2020 3:18 pm

Re: external 32khz crystal

Postby Snedig » Wed Nov 29, 2023 3:58 pm

Sorry for necroing this thread, but I was wondering whether it is possible to generate such a crystal output to GPIO to another pin?

We are having some crystal troubles, but our units are fully potted, so GPIO25 is not available. I could ideally use pin 16, 17 or 23, but I also have access to pins 0-4 which can be used while disabling some peripherals.

Anny help would be greatly appreciated! :)

Who is online

Users browsing this forum: No registered users and 100 guests