]> granicus.if.org Git - esp-idf/commitdiff
soc/rtc: wait for frequency switch to complete
authorIvan Grokhotkov <ivan@espressif.com>
Tue, 20 Mar 2018 10:27:32 +0000 (18:27 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Tue, 20 Mar 2018 10:27:32 +0000 (18:27 +0800)
The fast path of CPU frequency switch function, used in DFS, was not
waiting for the frequency switch to complete when switching from XTAL
to PLL. This resulted in incorrect reads from peripherals on APB,
where two consecutive reads could return the same value. For example,
in esp_timer, read of FRC_COUNT_REG would return same value as the
preceding read of FRC_ALARM_REG, causing time to jump by the value of
FRC_ALARM_REG / apb_freq_mhz.

components/soc/esp32/rtc_clk.c

index 54dea84c51d4ed3a9764c9571192cd01dab55ae3..eb72da2cebfab458fcb4a37c201d0d53d9ce9866 100644 (file)
@@ -402,6 +402,7 @@ void rtc_clk_cpu_freq_set_fast(rtc_cpu_freq_t cpu_freq)
         rtc_clk_cpu_freq_to_xtal();
     } else if (cpu_freq > RTC_CPU_FREQ_XTAL) {
         rtc_clk_cpu_freq_to_pll(cpu_freq);
+        rtc_clk_wait_for_slow_cycle();
     }
 }