A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By xorcz
#83419 Hi, I used the code https://techtutorialsx.com/2016/12/11/e ... nterrupts/
added ICACHE_RAM_ATTR, but I am still receiving errors. What more should I fix?
ESP-12F with 8MB, Arduino 1.8.9 and board library 2.5.2 installed.

Code:

Code: Select all#define ICACHE_RAM_ATTR
const byte interruptPin = 13;
volatile byte interruptCounter = 0;
int numberOfInterrupts = 0;
 
void setup() {
 
  Serial.begin(115200);
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, RISING);
 
}
 
void ICACHE_RAM_ATTR handleInterrupt() {
  interruptCounter++;
}
 
void loop() {
 
  if(interruptCounter>0){
 
      interruptCounter--;
      numberOfInterrupts++;
 
      Serial.print("An interrupt has occurred. Total: ");
      Serial.println(numberOfInterrupts);
  }
 
}

Error:
Code: Select all20:08:22.329 -> Abort called
20:08:22.329 ->
20:08:22.329 -> >>>stack>>>
20:08:22.329 ->
20:08:22.329 -> ctx: cont
20:08:22.329 -> sp: 3ffffdb0 end: 3fffffc0 offset: 01b0
20:08:22.329 -> 3fffff60:  feefeffe 00000001 3ffee26c 3ffee2c4 
20:08:22.329 -> 3fffff70:  3fffdad0 00000001 3ffee26c 3ffee2c4 
20:08:22.329 -> 3fffff80:  3fffdad0 00000000 3ffee294 401003da 
20:08:22.329 -> 3fffff90:  feefeffe 00000000 3ffee294 40201069 
20:08:22.329 -> 3fffffa0:  feefeffe feefeffe feefeffe 402018b4 
20:08:22.329 -> 3fffffb0:  feefeffe feefeffe 3ffe84f4 401006c5 
20:08:22.329 -> <<<stack<<<
20:08:22.373 ->
20:08:22.373 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
20:08:22.373 ->
20:08:22.373 -> load 0x4010f000, len 1384, room 16
20:08:22.373 -> tail 8
20:08:22.373 -> chksum 0x2d
20:08:22.373 -> csum 0x2d
20:08:22.373 -> v8b899c12
20:08:22.373 -> ~ld
20:08:22.431 -> ISR not in IRAM!


Thanks
User avatar
By xorcz
#83447 Because it does not compile without it. If the line "#define ICACHE_RAM_ATTR" is missing, the Arduino says the handleInterrupt is not declared.

I seems the same issue was answered here https://www.reddit.com/r/esp8266/commen ... nterrupts/

so I will remove #define and add
"void ICACHE_RAM_ATTR handleInterrupt();" at the very top.

Thank you