mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
8ccb2a4990
Small changes to clock calibration value will cause increasing errors the longer the device runs. Consider the case of deep sleep, assuming that RTC counter is used for timekeeping: - before sleep: time_before = rtc_counter * calibration_val - after sleep: time_after = (rtc_counter + sleep_count) * (calibration_val + epsilon) where 'epsilon' is a small estimation error of 'calibration_val'. The apparent sleep duration thus will be: time_after - time_before = sleep_count * (calibration_val + epsilon) + rtc_counter * epsilon Second term on the right hand side is the error in time difference estimation, it is proportional to the total system runtime (rtc_counter). To avoid this issue, this change makes RTC_SLOW_CLK calibration value persistent across restarts. This allows the calibration value update to be preformed, while keeping time after update same as before the update.