ESP32 system time ocassionaly jumps back ~54 seconds

snoutmate
Posts: 1
Joined: Mon Oct 01, 2018 1:45 am

ESP32 system time ocassionaly jumps back ~54 seconds

Postby snoutmate » Mon Oct 01, 2018 2:13 am

Hello,

I noticed that the system clock (esp_timer_get_time()) on our app sometimes(1-2xhour) jumps back ~54 secs.
Looking through the esp-idf timer code, i see the rollover of the internal 32-bit usecs clock is around the same value, so it seems rollover happens without all the rollover-handling code firing, though at a glance i don't understand how that could be the case.
I'm running on ESP32 with Unicore, with multiple threads. NTP is disabled. Happens on both v3.1/v3.0.
My sdkconfig: https://pastebin.com/6L4DcMiH

Main thread code:

Code: Select all

  ...
  typedef int64_t timestamp_t;
  timestamp_t esp_timestamp = 0;
  timestamp_t esp_timestamp_lastframe = 0;

  for(;;) { // frame start
    esp_timestamp_lastframe = esp_timestamp;
    esp_timestamp = esp_timer_get_time();

    if (esp_timestamp < esp_timestamp_lastframe) {
      timestamp_t shift_us = esp_timestamp - esp_timestamp_lastframe;

      ESP_LOGE(TAG, "ESP system clock SHIFT: %lli usecs", shift_us);
    }

   ...

   vTaskDelay(20 / portTICK_PERIOD_MS);
  }
 /* not reached */
Output:
E (355905) Main: ESP system clock SHIFT: -53666211 usecs
...
E (815595) Main: ESP system clock SHIFT: -53666244 usecs

Thanks for any suggestions,
Jan Dvorak

Who is online

Users browsing this forum: Bing [Bot] and 93 guests