OVMS3-idf/components/soc/esp32
Ivan Grokhotkov 07543dfec4 soc/rtc: wait for SLOW_CLK cycle when switching CPU clock
Previous implementation waited for 20us after setting
RTC_CNTL_SOC_CLK_SEL_XTL register, using ets_delay_us, assuming that
the CPU was running at XTAL frequency. In reality, clock switch happened
on the next RTC_SLOW_CLK cycle, and CPU could be running at the previous
frequency (for example, 240 MHz) until then.
ets_delay_us would wait for 20 us * 40 cycles per us = 800 CPU cycles
(assuming 40 MHz XTAL; even less with a 26 MHz XTAL).
But if CPU was running at 240 MHz, 800 cycles would pass in just 3.3us,
while SLOW_CLK cycle could happen as much as 1/150kHz = 6.7us after
RTC_CNTL_SOC_CLK_SEL_XTL was set. So the software would not actually wait
long enough for the clock switch to happen, and would disable the PLL
while CPU was still clocked from PLL, leading to a halt.

This implementation uses rtc_clk_wait_for_slow_cycle() function to wait
until the clock switch, removing the need to wait for a fixed number of
CPU cycles.
2017-11-09 15:51:14 +08:00
..
include soc/rtc: add a function to wait for slow clock cycle 2017-11-09 15:48:25 +08:00
test soc: implement XTAL frequency detection 2017-04-24 15:29:30 +08:00
brownout.c soc: add source code of rtc_clk, rtc_pm 2017-04-11 15:45:54 +08:00
cpu_util.c soc: add source code of rtc_clk, rtc_pm 2017-04-11 15:45:54 +08:00
i2c_apll.h soc: add source code of rtc_clk, rtc_pm 2017-04-11 15:45:54 +08:00
i2c_bbpll.h soc: add source code of rtc_clk, rtc_pm 2017-04-11 15:45:54 +08:00
i2c_rtc_clk.h soc: add source code of rtc_clk, rtc_pm 2017-04-11 15:45:54 +08:00
rtc_clk.c soc/rtc: wait for SLOW_CLK cycle when switching CPU clock 2017-11-09 15:51:14 +08:00
rtc_init.c bugfix(80m flash): cherry pick from idf3.0, add gpio config and vddsdio config 2017-11-08 12:50:08 +08:00
rtc_pm.c soc: add source code of rtc_clk, rtc_pm 2017-04-11 15:45:54 +08:00
rtc_sleep.c soc/rtc: power down VDDSDIO in deep sleep 2017-11-08 21:45:10 +08:00
rtc_time.c soc/rtc: add a function to wait for slow clock cycle 2017-11-09 15:48:25 +08:00
soc_log.h soc: add source code of rtc_clk, rtc_pm 2017-04-11 15:45:54 +08:00