1choice RTC_CLK_SRC
2    prompt "RTC clock source"
3    default RTC_CLK_SRC_INT_RC
4    help
5        Choose which clock is used as RTC clock source.
6
7        - "Internal 90kHz oscillator" option provides lowest deep sleep current
8            consumption, and does not require extra external components. However
9            frequency stability with respect to temperature is poor, so time may
10            drift in deep/light sleep modes.
11        - "External 32kHz crystal" provides better frequency stability, at the
12            expense of slightly higher (1uA) deep sleep current consumption.
13        - "External 32kHz oscillator" allows using 32kHz clock generated by an
14            external circuit. In this case, external clock signal must be connected
15            to 32K_XP pin. Amplitude should be <1.2V in case of sine wave signal,
16            and <1V in case of square wave signal. Common mode voltage should be
17            0.1 < Vcm < 0.5Vamp, where Vamp is the signal amplitude.
18        - "Internal 8MHz oscillator divided by 256" option results in higher
19            deep sleep current (by 5uA) but has better frequency stability than
20            the internal 90kHz oscillator. It does not require external components.
21
22    config RTC_CLK_SRC_INT_RC
23        bool "Internal 90kHz RC oscillator"
24    config RTC_CLK_SRC_EXT_CRYS
25        bool "External 32kHz crystal"
26        select ESP_SYSTEM_RTC_EXT_XTAL
27    config RTC_CLK_SRC_EXT_OSC
28        bool "External 32kHz oscillator at 32K_XN pin"
29        select ESP_SYSTEM_RTC_EXT_OSC
30    config RTC_CLK_SRC_INT_8MD256
31        bool "Internal 8MHz oscillator, divided by 256 (~32kHz)"
32endchoice
33
34config RTC_CLK_CAL_CYCLES
35    int "Number of cycles for RTC_SLOW_CLK calibration"
36    default 3000 if RTC_CLK_SRC_EXT_CRYS || RTC_CLK_SRC_EXT_OSC || RTC_CLK_SRC_INT_8MD256
37    default 576 if RTC_CLK_SRC_INT_RC
38    range 0 8190 if RTC_CLK_SRC_EXT_CRYS || RTC_CLK_SRC_EXT_OSC || RTC_CLK_SRC_INT_8MD256
39    range 0 32766 if RTC_CLK_SRC_INT_RC
40    help
41        When the startup code initializes RTC_SLOW_CLK, it can perform
42        calibration by comparing the RTC_SLOW_CLK frequency with main XTAL
43        frequency. This option sets the number of RTC_SLOW_CLK cycles measured
44        by the calibration routine. Higher numbers increase calibration
45        precision, which may be important for applications which spend a lot of
46        time in deep sleep. Lower numbers reduce startup time.
47
48        When this option is set to 0, clock calibration will not be performed at
49        startup, and approximate clock frequencies will be assumed:
50
51        - 90000 Hz if internal RC oscillator is used as clock source. For this use value 1024.
52        - 32768 Hz if the 32k crystal oscillator is used. For this use value 3000 or more.
53            In case more value will help improve the definition of the launch of the crystal.
54            If the crystal could not start, it will be switched to internal RC.
55
56config RTC_XTAL_CAL_RETRY
57    int "Number of attempts to repeat 32k XTAL calibration"
58    default 3
59    depends on RTC_CLK_SRC_EXT_CRYS
60    help
61        Number of attempts to repeat 32k XTAL calibration
62        before giving up and switching to the internal RC.
63        Increase this option if the 32k crystal oscillator
64        does not start and switches to internal RC.
65