Page 1 of 1

external 32khz crystal

Posted: Thu Mar 30, 2017 10:23 pm
by imtiaz
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

Re: external 32khz crystal

Posted: Fri Mar 31, 2017 2:52 am
by ESP_igrr
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.

Re: external 32khz crystal

Posted: Fri Jun 02, 2017 12:45 am
by supersat
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?

Re: external 32khz crystal

Posted: Fri Jun 02, 2017 12:55 am
by ESP_igrr
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.

Re: external 32khz crystal

Posted: Fri Jun 02, 2017 10:27 am
by nissim@TelnT.com
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 ...

Re: external 32khz crystal

Posted: Wed Nov 29, 2023 3:58 pm
by Snedig
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! :)