Task delay without resetting the watchdog timer?
Posted: Thu Mar 12, 2020 6:19 pm
Hi all,
I am new to ESP32 programming, coming from Arduino, and I am struggling with the task watchdog timer.
The function below is a task handler, I am trying to init subsystems (SPIFFS, Wire...).
I want to try the inits in a loop, with a short delay between attempts, and I want the watchdog to reset the ESP after say 5 seconds.
Because vTaskDelay feeds the watchdog, I am using a busy loop below, which is kind of ugly: is there any way to replace my busy loop with a
delay_but_don't_reset_watchdog(100) ?
In other terms I'd like the task to yield to other tasks, but still get the watchdog to trigger after 5s.
Any suggestion?
Thanks!
Franck
I am new to ESP32 programming, coming from Arduino, and I am struggling with the task watchdog timer.
The function below is a task handler, I am trying to init subsystems (SPIFFS, Wire...).
I want to try the inits in a loop, with a short delay between attempts, and I want the watchdog to reset the ESP after say 5 seconds.
Because vTaskDelay feeds the watchdog, I am using a busy loop below, which is kind of ugly: is there any way to replace my busy loop with a
delay_but_don't_reset_watchdog(100) ?
In other terms I'd like the task to yield to other tasks, but still get the watchdog to trigger after 5s.
Any suggestion?
Thanks!
Franck
Code: Select all
void setup()
{
esp_task_wdt_init(5, true);
xTaskCreatePinnedToCore(initSystems, "Init Systems", 10000, NULL, 3, &InitSystemsTask, 1);
}
Code: Select all
void initSystems(void *param)
{
esp_task_wdt_add(NULL);
// SPIFFS
unsigned long now = millis();
while (!SPIFFS.begin(true)) {
while (millis() - now < 100u);
}
esp_task_wdt_reset();
now = millis();
while (!Wire.begin()) {
debug("Failed to start Wire");
while (millis() - now < 100u);
}
esp_task_wdt_reset();
...
}