mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
Power Management: fix the issue of sleeping time error beacause external 32kHz xtal does not exist
This commit is contained in:
@ -727,8 +727,15 @@ esp_err_t esp_light_sleep_start(void)
|
|||||||
|
|
||||||
// Re-calibrate the RTC Timer clock
|
// Re-calibrate the RTC Timer clock
|
||||||
#if defined(CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS) || defined(CONFIG_ESP32S2_RTC_CLK_SRC_EXT_CRYS) || defined(CONFIG_ESP32C3_RTC_CLK_SRC_EXT_CRYS)
|
#if defined(CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS) || defined(CONFIG_ESP32S2_RTC_CLK_SRC_EXT_CRYS) || defined(CONFIG_ESP32C3_RTC_CLK_SRC_EXT_CRYS)
|
||||||
uint64_t time_per_us = 1000000ULL;
|
if (rtc_clk_slow_freq_get() == RTC_SLOW_FREQ_32K_XTAL) {
|
||||||
s_config.rtc_clk_cal_period = (time_per_us << RTC_CLK_CAL_FRACT) / rtc_clk_slow_freq_get_hz();
|
uint64_t time_per_us = 1000000ULL;
|
||||||
|
s_config.rtc_clk_cal_period = (time_per_us << RTC_CLK_CAL_FRACT) / rtc_clk_slow_freq_get_hz();
|
||||||
|
} else {
|
||||||
|
// If the external 32 kHz XTAL does not exist, use the internal 150 kHz RC oscillator
|
||||||
|
// as the RTC slow clock source.
|
||||||
|
s_config.rtc_clk_cal_period = rtc_clk_cal(RTC_CAL_RTC_MUX, RTC_CLK_SRC_CAL_CYCLES);
|
||||||
|
esp_clk_slowclk_cal_set(s_config.rtc_clk_cal_period);
|
||||||
|
}
|
||||||
#elif defined(CONFIG_ESP32S2_RTC_CLK_SRC_INT_RC)
|
#elif defined(CONFIG_ESP32S2_RTC_CLK_SRC_INT_RC)
|
||||||
s_config.rtc_clk_cal_period = rtc_clk_cal_cycling(RTC_CAL_RTC_MUX, RTC_CLK_SRC_CAL_CYCLES);
|
s_config.rtc_clk_cal_period = rtc_clk_cal_cycling(RTC_CAL_RTC_MUX, RTC_CLK_SRC_CAL_CYCLES);
|
||||||
esp_clk_slowclk_cal_set(s_config.rtc_clk_cal_period);
|
esp_clk_slowclk_cal_set(s_config.rtc_clk_cal_period);
|
||||||
|
Reference in New Issue
Block a user