ESP8266-07 craches on interrupt handling (FIXED)
Posted: Sat Oct 14, 2017 5:00 pm
I have written a counter for my ESP8266-07 that uses interrupts, but sometimes it craches. The code is quite simple.
Sometimes it works for several "completions" - other times it craches when the counter is e.g. 600 or 900.
I have tried with two different ESP modules and its running stable if I disable the "attachInterrupt" code.
Any input is appreciated.
Sometimes it works for several "completions" - other times it craches when the counter is e.g. 600 or 900.
I have tried with two different ESP modules and its running stable if I disable the "attachInterrupt" code.
Any input is appreciated.
Code: Select all
const int pinFlowmeter = 13;
volatile unsigned int intCounter=0;
void setup() {
}
void loop() {
if (intCounter >= 1000) {
detachInterrupt(digitalPinToInterrupt(pinFlowmeter));
Serial.println("Complete");
intCounter = 0;
buttonPressed = false;
}
// ... other stuff
}
void pressButton() {
if (!buttonPressed) { // prevent calling this several times
attachInterrupt(digitalPinToInterrupt(pinFlowmeter), getcount, CHANGE);
buttonPressed = true;
}
}
void getcount() {
intCounter++;
}