Page 1 of 1

[Solved] system_get_time() does not appear to tick until after esp_wifi_init() is called

Posted: Sun Oct 16, 2016 11:00 pm
by kolban
I was working on some play tests with GPIO and realized that in my tests, I didn't need networking so removed those calls. Now my code was no longer working. As I dug deeper, I found that the return from system_get_time() was now constantly returning 0. This call should return the number of microseconds since ESP32 startup. By trial and error, I seem to find that if one does NOT call esp_wifi_init() then the timer does not tick. Is this working as desired? I'm sure we will be fine if that is the case, but I'd like to try and capture those semantics in case someone else downstream has an issue.

Usual caveats apply in that I could easily have messed something up in my tests and this is environment specific to me ... etc etc.

Re: system_get_time() does not appear to tick until after esp_wifi_init() is called

Posted: Mon Oct 17, 2016 1:28 am
by ESP_igrr
Yes, logically it should work either after startup or after system_init. I think this function derives time from internal clock of wifi peripheral. We should change that to use either RTC or another timer.

Re: system_get_time() does not appear to tick until after esp_wifi_init() is called

Posted: Thu Nov 03, 2016 12:34 pm
by ESP_igrr
You can now obtain time at microsecond precision using `gettimeofday` function. It works even when wifi is not enabled.