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

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

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

Postby kolban » Sun Oct 16, 2016 11:00 pm

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.
Last edited by kolban on Mon Nov 07, 2016 5:39 am, edited 1 time in total.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

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

Postby ESP_igrr » Mon Oct 17, 2016 1:28 am

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.

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

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

Postby ESP_igrr » Thu Nov 03, 2016 12:34 pm

You can now obtain time at microsecond precision using `gettimeofday` function. It works even when wifi is not enabled.

Who is online

Users browsing this forum: Google [Bot] and 240 guests