esp8266: Fix ticks_ms to correctly handle wraparound of system counter.
Fixes issue #4795.
diff --git a/ports/esp8266/esp_mphal.c b/ports/esp8266/esp_mphal.c
index df97a73..351bf52 100644
--- a/ports/esp8266/esp_mphal.c
+++ b/ports/esp8266/esp_mphal.c
@@ -120,7 +120,9 @@
}
uint32_t mp_hal_ticks_ms(void) {
- return ((uint64_t)system_time_high_word << 32 | (uint64_t)system_get_time()) / 1000;
+ // Compute milliseconds from 64-bit microsecond counter
+ system_time_update();
+ return ((uint64_t)system_time_high_word << 32 | (uint64_t)system_time_low_word) / 1000;
}
uint32_t mp_hal_ticks_us(void) {