Hi everyone.
I'm using a NodeMCU ESP8266 with the Arduino IDE, and for the code I'm writing I need an interrupt, but I can't make it work.
This is the general code that I'm using to test the interrupt behaviour/problems in the ESP8266:
#define ICACHE_RAM_ATTR
const int interruptPin = 14;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(interruptPin, INPUT_PULLUP);
ICACHE_RAM_ATTR;
attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, CHANGE);
Serial.begin(115200);
}
void ICACHE_RAM_ATTR handleInterrupt() {
Serial.println("Interrupt Detected");
}
void loop() {
digitalWrite(LED_BUILTIN, LOW);
delay(500);
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
Serial.println("..."); //Just for testing purposes.
}
At first, I was having the issue "ISR not in IRAM", I've corrected it with the "ICACHE_RAM_ATTR".
Now my problem is that, apparently, the ESP8266 is resetting continiously with code 2 (reset pin), and output this:
"
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld
"
I've tried all the things suggested in forums, datasheets, blogs...nothing seems to work, maybe I am doing something wrong.
I have tried the following things:
- Changing library version;
- Changing interrupt pins;
- Changing ICACHE_RAM_ATTR position in the code;
- Changing USB cable;
- Changing USB port on my computer, 2.0 or 3.0 (yeah I know it's pointless but you never know...);
- Changing Interrupt method (CHANGE, RISING, FALLING);
- Crying ON the ESP8266 and praying that it will work one day (joking...kind of);
Any suggestion on how I can solve this frustrating problem?