I disabled watchdogs but I still get a WDT timeout
Posted: Wed Jul 08, 2020 8:37 pm
Hello! I'm trying to disable all watchdogs from one core. I'm using an ESP32 MH-ET LIVE on Arduino IDE. I'm trying the following in setup() and making a new max priority task (with IRAM_ATTR) on cpu0:
However, when I try and use:
I get still get Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).
I'm looking to disable the watchdog so I can stay in portENTER_CRITICAL indefinitely on one core because I'm successfully bitbanging at decently fast speeds, but the FreeRTOS ticks and background stuff ends up throwing random 1-2us delays that wreck it. I realize this sacrifices the ability to use timers and extra tasks on that core, but I can accept that. I can't use interrupts in this case, as ESP32 takes +2us to handle the interrupt.
Here's some minimal example code, if I uncomment the portENTER/portEXIT code, it errors out.
Thanks for reading!
Code: Select all
rtc_wdt_protect_off();
rtc_wdt_disable();
disableCore0WDT();
disableLoopWDT();
Code: Select all
static portMUX_TYPE my_mutex; (below #includes)
vPortCPUInitializeMutex(&my_mutex); (in setup)
portENTER_CRITICAL(&my_mutex); (in task)
I'm looking to disable the watchdog so I can stay in portENTER_CRITICAL indefinitely on one core because I'm successfully bitbanging at decently fast speeds, but the FreeRTOS ticks and background stuff ends up throwing random 1-2us delays that wreck it. I realize this sacrifices the ability to use timers and extra tasks on that core, but I can accept that. I can't use interrupts in this case, as ESP32 takes +2us to handle the interrupt.
Here's some minimal example code, if I uncomment the portENTER/portEXIT code, it errors out.
Code: Select all
#include "soc/rtc_wdt.h"
#include "esp_int_wdt.h"
#include "esp_task_wdt.h"
static portMUX_TYPE my_mutex;
IRAM_ATTR void setup() {
rtc_wdt_protect_off();
rtc_wdt_disable();
disableCore0WDT();
disableLoopWDT();
vPortCPUInitializeMutex(&my_mutex);
Serial.begin(115200);
TaskHandle_t Task2;
xTaskCreatePinnedToCore(
Select, /* Function to implement the task */
"Select", /* Name of the task */
10000, /* Stack size in words */
NULL, /* Task input parameter */
configMAX_PRIORITIES, /* Priority of the task */
&Task2, /* Task handle. */
0); /* Core where the task should run */
}
IRAM_ATTR void Select( void * parameter) {
unsigned long sincePrint = millis();
portENTER_CRITICAL(&my_mutex);
for(int i = 0; i < 10000000; i++) {
digitalWrite(22, 1);
digitalWrite(22, 0);
esp_task_wdt_reset();
}
portEXIT_CRITICAL(&my_mutex);
Serial.print(millis() - sincePrint);
vTaskDelete(0);
}
void loop() {
vTaskDelay(portMAX_DELAY);
}