Go Down

Topic: Problem with ModeMCU ESP8266 compling sketch after adding "ICACHE_RAM_ATTR"  (Read 758 times) previous topic - next topic

Hgr1950

Hello!

Hardware: NodeMCU V3.2 Arduino ESP8266 (MarkerShop.DE)

Sketch: Client-server communication using ESP8266 (from IT HandyMan site)

Board setting: "NodeMCU 1.0 (ESP-12E Module)"

Library: ESP8266WiFi.h

Before done:

I uploaded (copy from the site and paste to Arduino IDE). All gone fine during compilation and writing to the board. Program started but after connecting to WIFI crashed generating next print:

Code: [Select]
Connecting to DNA-Mokkula-2G-Q8D8AT ...
1 2 3

Connection established!
IP address: 192.168.1.107
ISR not in IRAM!

Abort called

>>>stack>>>

ctx: cont
sp: 3ffffd90 end: 3fffffc0 offset: 01b0
3fffff40:  3ffe877f 3ffee5a4 3ffee5d8 3ffee644 
3fffff50:  00000003 3ffee5a4 3ffee5d8 3ffee644 
3fffff60:  00000003 3ffee5a4 3ffee5d8 401003da 
3fffff70:  3ffe84e4 3ffee5a4 3ffee5d8 40201172 
3fffff80:  40205af8 6b01a8c0 feefeffe feefeffe 
3fffff90:  feefeffe feefeffe feefeffe feefeffe 
3fffffa0:  3fffdad0 00000000 3ffee614 40203ac4 
3fffffb0:  feefeffe feefeffe 3ffe8514 401006c5 
<<<stack<<<

 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 noticed this message "ISR not in IRAM!". Envestigating info for to put ISR to IRAM. Answer was:
Add ICACHE_RAM_ATTR before funtion's name. Is my case "void ICACHE_RAM_ATTR handleInterrupt()".
After that compiler wasn't satisfied. Error occured:


Code: [Select]
Using library ESP8266WiFi at version 1.0 in folder: C:\Users\hannu\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi
exit status 1
'handleInterrupt' was not declared in this scope


Part of sketch code:

void setup() {
Serial.begin(115200); // Start the Serial communication to send messages to the computer
delay(10);
Serial.println('\n');
WiFi.hostname("ESPboard-counter");
WiFi.begin(ssid, password); // Connect to the network
Serial.print("Connecting to ");
Serial.print(ssid); Serial.println(" ...");
int i = 0;
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
delay(1000);
Serial.print(++i); Serial.print(' ');
}
Serial.println('\n');
Serial.println("Connection established!");
Serial.print("IP address:\t");
Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to the computer
// set interrupt handler
pinMode(interruptPin, INPUT_PULLUP);
Code: [Select]
Error occured on line 31:attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, FALLING);[[code]
// start HTTP server
server.begin();
Serial.printf("Web server started, open %s in a web browser\n", WiFi.localIP().toString().c_str());
}
// this one is handling GPIO interrupts
void ICACHE_RAM_ATTR handleInterrupt() {
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
// If interrupts come faster than 100ms, assume it's a bounce and ignore
if (interrupt_time - last_interrupt_time > 100)
{
interruptCounter++;
Serial.print("<<< Interrupt counter value:");
Serial.println(interruptCounter);
}
last_interrupt_time = interrupt_time;
}

I am using code tags. So I didn't manage quite good and the post is not completely clear.

Here is the link for see the original publication.

https://handyman.dulare.com/client-server-communication-using-esp8266/

Waiting for help.

Best regards HGR1950

Hgr1950

Good Morning! 08.21am in Hamina Finland!

After Good Sleeping Hole Night I resolved the problem.

It is: The command must be: "ICACHE_RAM-ATTR void handleInterrupt () {...." not void ICACHE_RAM-ATTR

Not difficult but took much time to find!

I hope that this could be help for many!

Best Regards HGR1950

Go Up