Esp8266 wemos d1 interupt not working and crashing. The same code works fine in esp32 and arduino nano. why does esp8266 crash

volatile int sayici = 0;
unsigned long rpm = 0;
unsigned long simdiki_zaman = 0;
unsigned long onceki_zaman = 0;
#define rpmPin D2

unsigned long yenilemehizi = 250;
void setup() {

Serial.begin(115200);

pinMode(rpmPin, INPUT);

attachInterrupt(digitalPinToInterrupt(rpmPin), rpm_motor, FALLING);
}
void loop() {
simdiki_zaman = millis();

if (simdiki_zaman - onceki_zaman >= yenilemehizi) {

detachInterrupt(digitalPinToInterrupt(rpmPin));

rpm = sayici * 120 / (yenilemehizi / 250);
onceki_zaman = simdiki_zaman;
delay(1);
sayici = 0;
Serial.println(rpm);
Serial.flush();
attachInterrupt(digitalPinToInterrupt(rpmPin), rpm_motor, FALLING);

}
}
void rpm_motor() {
sayici++;

}

12:36:11.428 -> ctx: cont
12:36:11.428 -> sp: 3fffff00 end: 3fffffc0 offset: 0000
12:36:11.428 -> 3fffff00: feefeffe feefeffe feefeffe 3ffef2fc
12:36:11.428 -> 3fffff10: 000000fe 00000000 00000000 00000000
12:36:11.475 -> 3fffff20: 00000000 00000000 00000000 00ff0000
12:36:11.475 -> 3fffff30: 5ffffe00 5ffffe00 0001c200 3ffee570
12:36:11.475 -> 3fffff40: 00000000 00000002 0000000f 40201e72
12:36:11.475 -> 3fffff50: 4010049d 00000001 3ffee508 40201e84
12:36:11.475 -> 3fffff60: 00000000 00000001 0000000f 40202385
12:36:11.475 -> 3fffff70: 00000000 feefeffe feefeffe feefeffe
12:36:11.475 -> 3fffff80: 3fffdad0 00000000 3ffee55c 40202424
12:36:11.475 -> 3fffff90: 3fffdad0 00000000 3ffee55c 40201069
12:36:11.475 -> 3fffffa0: feefeffe feefeffe feefeffe 40201a00
12:36:11.475 -> 3fffffb0: feefeffe feefeffe 3ffe85dc 40100d59
12:36:11.522 -> <<<stack<<<
12:36:11.522 ->
12:36:11.522 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
12:36:11.522 ->
12:36:11.522 -> ets Jan 8 2013,rst cause:2, boot mode:(3,0)
12:36:11.522 ->
12:36:11.522 -> load 0x4010f000, len 3460, room 16
12:36:11.522 -> tail 4
12:36:11.522 -> chksum 0xcc
12:36:11.522 -> load 0x3fff20b8, len 40, room 4
12:36:11.522 -> tail 4
12:36:11.522 -> chksum 0xc9
12:36:11.522 -> csum 0xc9
12:36:11.522 -> v000420c0
12:36:11.522 -> ~ld
12:36:11.616 -> ISR not in IRAM!
12:36:11.616 ->
12:36:11.616 -> User exception (panic/abort/assert)

What does the exception decoder say?

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