Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1)

I am implementing I2C communication between two ESP's. The Slave needs to send a trigger pulse via Interrupt to the Master. But whenever I try and run the below code. It throws a Guru Meditation error with a reboot. Could anyone Please help me? I dont understand whats happening since I am very new to Arduino.

void buttonPressed ()
{
digitalWrite(tempINT, HIGH);
delay(2);
digitalWrite(tempINT, LOW);
}

void setup()
{
pinMode (tempINT, OUTPUT);
pinMode (BUTTON, INPUT_PULLDOWN);

Serial.begin(115200);

attachInterrupt (digitalPinToInterrupt (BUTTON), buttonPressed, CHANGE);

bool res = WireSlave.begin(SDA_PIN, SCL_PIN, I2C_SLAVE_ADDR);
if (!res) {
    Serial.println("I2C slave init failed");
    while(1) delay(100);
}

WireSlave.onRequest(requestEvent);
Serial.printf("Slave joined I2C bus with addr #%d\n", I2C_SLAVE_ADDR);

}

Please edit your previous post and post the full sketch in code tags (use the </> button).
Also post the exact error message and if you get a stack trace/dump, decode it using the ESP exception decoder.

You probably want to move your ISR into RAM using the IRAM_ATTR section attribute.

Never call delay from an ISR, you want them to be as fast as possible, and I'm not even sure if FreeRTOS allows vTaskDelay to be called in an interrupt context.

1 Like

Also, the code is incomplete. Post something that actually compiles.

Also, the standard question ... why do you think it's necessary to use an interrupt to detect a button press? Now, on ESP32 / FreeRTOS, I suppose you could have the ISR to send a notification for a pending task to wake up and handle the event. But, I see no use of FreeRTOS's task scheduling capability here. In the standard Arduino single-task / single-processor paradigm, there's no need for an interrupt to detect a button.

1 Like

ESP is NOT an Arduino, using the Arduino coding approach on ESP is often not the right way to get things done. For your error, get the exception decoder and find out what causes the error.

1 Like

Thank you for all your suggestions. It worked for me, I removed the delay and instead used millis(). But I still dont understand what was the problem with delay().

On an ESP32 delay() is blocking but vTaskDelay() is not. A blocking delay in the ISR can cause a Guru.

1 Like

Thank you @Idahowalker. Strange but interesting (;

That's not true, they're the same thing:

vTaskDelay invokes the scheduler, you cannot do that from within an interrupt context. FreeRTOS has special functions that can be used from an ISR, but there is no vTaskDelayFromISR, because using delay in an interrupt handler is a very bad idea.

When using freeRTOS and vTaskDelay() in a task it is nonblocking.

OP when does this delay stop delaying? When does 1 stop being a 1?
An infinite delay loop which is a bunch of DoNothings will cause a WDT and or Guru.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.