Skip to content

Commit 4e3b4cb

Browse files
committed
Cherry pick fixes from ESP32 core upstream/master.
millis() rollover bug espressif/arduino-esp32#2438
1 parent 343f7df commit 4e3b4cb

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Diff for: cores/esp32/esp32-hal-misc.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ unsigned long IRAM_ATTR micros()
8282

8383
unsigned long IRAM_ATTR millis()
8484
{
85-
return xTaskGetTickCount() * portTICK_PERIOD_MS;
85+
//return xTaskGetTickCount() * portTICK_PERIOD_MS;
86+
87+
// https://github.com/espressif/arduino-esp32/issues/2430
88+
// https://github.com/espressif/arduino-esp32/pull/2438
89+
return (unsigned long) (esp_timer_get_time() / 1000ULL);
8690
}
8791

8892
void delay(uint32_t ms)

Diff for: cores/esp32/main.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ void loopTask(void *pvParameters)
1414
{
1515
setup();
1616
for(;;) {
17-
micros(); //update overflow
17+
// https://github.com/espressif/arduino-esp32/commit/93c45af25640435f78532cc621ea159f525e502a#diff-94536ff8ccf321f988ffa45f021f7137
18+
//micros(); //update overflow
1819
loop();
1920
}
2021
}
2122

2223
extern "C" void app_main()
2324
{
2425
initArduino();
25-
xTaskCreatePinnedToCore(loopTask, "loopTask", 8192, NULL, 1, NULL, ARDUINO_RUNNING_CORE);
26+
xTaskCreatePinnedToCore(loopTask, "loopTask", 12*1024, NULL, 1, NULL, ARDUINO_RUNNING_CORE);
2627
}
2728

2829
#endif

0 commit comments

Comments
 (0)