Page 1 of 1

Power Management - Automatic Light Sleep - Issues

Posted: Mon Apr 06, 2020 3:47 pm
by chofsass
Hi,

I am using esp-idf v3.3.1. I have setup automatic light sleep and I have 2 issues. The first issue is that the tick counter is shifting by about 10 milliseconds of a one second period. The second is that the printf() function which is using the UART doesn't appear to be sleep safe (the UART is dropping characters).

Are there some configurations in menuconfig that I should be using or are these bugs that I should create on github?

Re: Power Management - Automatic Light Sleep - Issues

Posted: Mon Apr 06, 2020 7:40 pm
by ESP_igrr
Hi chofsass,

The tick count will indeed drift in the automatic light sleep scenario. Please use esp_timer or gettimeofday for time keeping. These might still drift, depending on the RTC clock source, but much slower (within 1%, https://github.com/espressif/esp-idf/issues/4856).

As for printf, UART output will stop when the chip enters light sleep. If you want to make sure the output gets printed (at the expense of lower sleep time) you may call fsync(fileno(stdout)) — this will block until the UART TX buffer is flushed.