{"action":"created","issue":{"url":"https://api.github.com/repos/espressif/arduino-esp32/issues/120","repository_url":"https://api.github.com/repos/espressif/arduino-esp32","labels_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/120/labels{/name}","comments_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/120/comments","events_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/120/events","html_url":"https://github.com/espressif/arduino-esp32/issues/120","id":199430854,"number":120,"title":"analogRead seems to speed up system clock","user":{"login":"JeroenVanOort","id":5616838,"avatar_url":"https://avatars.githubusercontent.com/u/5616838?v=3","gravatar_id":"","url":"https://api.github.com/users/JeroenVanOort","html_url":"https://github.com/JeroenVanOort","followers_url":"https://api.github.com/users/JeroenVanOort/followers","following_url":"https://api.github.com/users/JeroenVanOort/following{/other_user}","gists_url":"https://api.github.com/users/JeroenVanOort/gists{/gist_id}","starred_url":"https://api.github.com/users/JeroenVanOort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeroenVanOort/subscriptions","organizations_url":"https://api.github.com/users/JeroenVanOort/orgs","repos_url":"https://api.github.com/users/JeroenVanOort/repos","events_url":"https://api.github.com/users/JeroenVanOort/events{/privacy}","received_events_url":"https://api.github.com/users/JeroenVanOort/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-01-08T16:28:44Z","updated_at":"2017-01-16T10:23:09Z","closed_at":null,"body":"I'm building an energy monitor using [EmonLib](https://github.com/openenergymonitor/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.\r\n\r\nAfter 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.\r\n\r\nDo you have any clue where this behavior comes from and how we could fix this?"},"comment":{"url":"https://api.github.com/repos/espressif/arduino-esp32/issues/comments/272823867","html_url":"https://github.com/espressif/arduino-esp32/issues/120#issuecomment-272823867","issue_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/120","id":272823867,"user":{"login":"igrr","id":4349050,"avatar_url":"https://avatars.githubusercontent.com/u/4349050?v=3","gravatar_id":"","url":"https://api.github.com/users/igrr","html_url":"https://github.com/igrr","followers_url":"https://api.github.com/users/igrr/followers","following_url":"https://api.github.com/users/igrr/following{/other_user}","gists_url":"https://api.github.com/users/igrr/gists{/gist_id}","starred_url":"https://api.github.com/users/igrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igrr/subscriptions","organizations_url":"https://api.github.com/users/igrr/orgs","repos_url":"https://api.github.com/users/igrr/repos","events_url":"https://api.github.com/users/igrr/events{/privacy}","received_events_url":"https://api.github.com/users/igrr/received_events","type":"User","site_admin":false},"created_at":"2017-01-16T10:23:09Z","updated_at":"2017-01-16T10:23:09Z","body":"We were able to reproduce this, and this looks like a hardware bug, i.e. a write to `FRC_TIMER_INT_REG(0)` gets lost, so the timer interrupt doesn't get cleared... and for some reason this happens when ADC is in use. We will try to reproduce this in the simulation environment.\r\n\r\nFor now, the workaround is to add a write to some random memory address into the `frc_timer_isr` function (components/newlib/time.c:85), for example\r\n```\r\nWRITE_PERI_REG(DR_REG_FRC_TIMER_BASE + 0x60, 0xabababab);\r\n```\r\n\r\nIt can go before or after `WRITE_PERI_REG(FRC_TIMER_INT_REG(0), FRC_TIMER_INT_CLR);` (both ways seem to fix the problem).\r\n\r\nWe'll update ESP-IDF with this workaround while we are trying to narrow down the root cause."}}
{"actor":{"display_login":"igrr"}}