Hello. I'm trying to use expressif "esp_task_wdt" hardware functions with ESP32 3.0.1 and Arduino IDE 2.3.2 but is impossible to add and manage current task WDT. This is an example:
#include "esp_task_wdt.h"
#define SDBG Serial
#define ESP_WDT_TIMEOUT 20 // Seconds
esp_task_wdt_config_t twdt_config;
time_t LoopVar = 0;
void setup() {
int ret;
SDBG.begin(115200,SERIAL_8N1);
SDBG.setDebugOutput(false);
delay(1000);
SDBG.println();
SDBG.println("-----------------------------------------------------------------");
// Initialize WATCHDOG
twdt_config.timeout_ms = 20000;
twdt_config.idle_core_mask = (1 << ESP.getChipCores()) - 1;
twdt_config.trigger_panic = true;
SDBG.printf("SETUP: timeout_ms(%d) idle_core_mask(0x%02X) trigger_panic(%d)\r\n", twdt_config.timeout_ms, twdt_config.idle_core_mask, twdt_config.trigger_panic);
// esp_task_wdt_init(ESP_WDT_TIMEOUT, true); //ERROR - working only with ESP32 2.0.17 and older
ret = esp_task_wdt_reconfigure(&twdt_config); // Working only with ESP32 3.0.1
SDBG.printf("SETUP: WDT Enabled - 0x%04X\r\n", ret);
ret = esp_task_wdt_add(NULL); //add current thread to WDT watch
delay(100);
SDBG.printf("SETUP: WDT Task Enabled - 0x%04X\r\n", ret);
// esp_task_wdt_deinit(); //ERROR - working only with ESP32 2.0.17 and older
// delay(100);
// SDBG.println(F("SETUP: WDT SERIAL Disabled"));
SDBG.println(F("SETUP: END"));
}
void loop() {
boolean result;
if (time(NULL) > LoopVar) {
LoopVar = time(NULL) + 2;
SDBG.printf("***LOOP*** (%u)\r\n", millis());
}
// *** WATCHDOG del dispositivo ------------------------------------------------
// if (esp_task_wdt_status(NULL) == ESP_OK); //ERROR - working only with ESP32 2.0.17 and older
esp_task_wdt_reset(); //ERROR - working only with ESP32 2.0.17 and older
}
The task resets after 20 seconds. Can someone help me?