-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
analogRead seems to speed up system clock #120
Comments
I've made a simple program to test this. I observe that after 30 seconds according to my laptop's clock, about 50 seconds have passed according to the ESP32's clock. When I comment out the for loop, the ESP32's clock runs just fine. What can we do to fix this? #include <time.h>
time_t lcd_time;
void setup()
{
Serial.begin(115200);
}
void loop()
{
int i;
for (i = 0; i < 100000; i++) {
analogRead(36);
}
time(&lcd_time);
Serial.println(lcd_time);
delay(1000);
} |
Thanks for the example. I don't have a workaround for you, need to investigate this. The issue is in the esp-idf, not in the Arduino libraries. |
We were able to reproduce this, and this looks like a hardware bug, i.e. a write to For now, the workaround is to add a write to some random memory address into the
It can go before or after We'll update ESP-IDF with this workaround while we are trying to narrow down the root cause. |
This workaround does seem to work using the esp-idf with arduino as component. |
The fix is staged for merging into the ESP-IDF. Once it is merged, @me-no-dev can update libraries in this repository to make the fix available in Arduino IDE. |
Fix issues with time syscalls - fix compilation error when no time source is selected (#238) - work around a bug that time speeds up when RTC registers are read on the APP CPU (espressif/arduino-esp32#120) See merge request !427
Hello @igrr and @me-no-dev .. I am really loving the ESP32 devices and community :) Does anyone know if this 'time warp' was ever addressed or made it through to the Arduino side of things? I'm doing some ADC related work and noticed that time seems to accelerate for the ESP32 vs the rest of the world. I followed the full installation instructions as of the github page about 1 month ago, and it seems that this bug is still present. Looking forward to info on how I can address this in my Apps :) Cheers from Canada ! |
I'm building an energy monitor using EmonLib and I've got most things working now. Since I'll need to add a time stamp to the measurements I send to my web application, I'd like to sync the ESP32's system clock to an NTP server. Sync to NTP doesn't seem to be my problem so far, but keeping time is. I've observed that the system clock on my device seems to go faster when doing a lot of analogRead's, which is necessary for monitoring energy usage.
After a measurement that takes a second, I print the time to serial. I've seen 3 to 4 seconds jumps and sometimes it's just the one second like I'd expect it to. When I comment out the measurement function and put
delay(1000);
in it's place, time runs normal.Do you have any clue where this behavior comes from and how we could fix this?
The text was updated successfully, but these errors were encountered: