ISR not in IRAM error with Wemos mini d1

I have written a simple sketch for the Wemos mini d1. It works until I try to add an interrupt. The sketch compiles and uploads without error, but when it tries to run, I get the following:

ISR not in IRAM!
User exception (panic/abort/assert)
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Abort called

stack>>>

ctx: cont
sp: 3ffffea0 end: 3fffffc0 offset: 0000
3ffffea0: feefeffe feefeffe feefeffe 3fff0074
3ffffeb0: 000000fe 00000000 00000000 00000000
3ffffec0: 00000000 00000000 00000000 00ff0000
3ffffed0: 5ffffe00 5ffffe00 00002580 3ffeef48
3ffffee0: 00000000 00000003 00000002 4020a0f6
3ffffef0: 40100721 00000001 3ffeeee0 4020a108
3fffff00: 00000000 00000001 00000002 4020ad11
3fffff10: 00000000 feefeffe feefeffe feefeffe
3fffff20: 3fffdad0 00000000 3ffeeee0 4020adb0
3fffff30: 3fffdad0 00000000 3ffeeee0 40203431
3fffff40: feefeffe feefeffe feefeffe feefeffe
3fffff50: feefeffe feefeffe feefeffe feefeffe
3fffff60: feefeffe feefeffe feefeffe feefeffe
3fffff70: feefeffe feefeffe feefeffe feefeffe
3fffff80: feefeffe feefeffe feefeffe feefeffe
3fffff90: feefeffe feefeffe feefeffe 3ffeef48
3fffffa0: 3fffdad0 00000000 3ffeef34 40209a1c
3fffffb0: feefeffe feefeffe 3ffe8648 401010b9
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

This message is repeated at about 1 sec intervals.
Here is all the code related to the interrupt:

const byte interruptPin = D0;
// interrupt pin normally INPUT_PULLUP and CHANGE works best for
IR beam breaker
pinMode(interruptPin,INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin), beam_break_ISR, CHANGE);

void beam_break_ISR()
{
I = I+1;
flag = 1;
}

The sketch, with interrupt, works (with changes in pin nomenclature) if I use an Arduino Nano Every.

I am using Arduino IDE 1.8.9, Python 3.0, and updated boards info.

I tried the sketch on another computer that has IDE 1.8.16, python 3.0, and updated boards and I get the message "cannot locate drivers for device on USB2" as soon as I plug in the board.

I notice this topic has come up before, but since the responses are in German, they are not much help to me.

I have used the Wemos mini d1, with interrupts, successfully in the past. My problems seem to have started after I "updated" the boards information.

Any helps is appreciated.

Try

void IRAM_ATTR beam_break_ISR()
{
I = I+1;
flag = 1;
}

Arduino and Esp32 Interrupts (ISR) – MAlabdali

It solved my problem. Many thanks for your help.

1 Like