I would know the time elapsed from start and end of the deep sleep. After some search I found a function (below my implementation):
Code: Select all
RTC_IRAM_ATTR uint64_t pw_getTime(void) {
SET_PERI_REG_MASK(RTC_CNTL_TIME_UPDATE_REG, RTC_CNTL_TIME_UPDATE_M);
while (GET_PERI_REG_MASK(RTC_CNTL_TIME_UPDATE_REG, RTC_CNTL_TIME_VALID_M) == 0) { }
uint64_t now = READ_PERI_REG(RTC_CNTL_TIME0_REG);
now |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME1_REG)) << 32;
return now * 100 / (RTC_CTNL_SLOWCLK_FREQ / 10000); // scale RTC_CTNL_SLOWCLK_FREQ to avoid overflow;
}
The value that I found in the examples for RTC_CTNL_SLOWCLK_FREQ is 150000 and with this value the time provided diverges strongly from that provided by millis (and by esp_timer_get_time function) while with the value 160000 the clock delays about 10 seconds every hour.
To sum up:
- Why the function above crash when called outside the stub?
- What is the correct value for RTC_CTNL_SLOWCLK_FREQ?