Been trying all day to figure out what could be causing the problem but to no avail. Every time I try to call an attachInterrupt, even if the ISR function is completely empty I get this:
05:32:40.700 -> Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).
05:32:40.765 ->
05:32:40.765 -> Core 1 register dump:
05:32:40.797 -> PC : 0x4008e2d2 PS : 0x00060c35 A0 : 0x8008d246 A1 : 0x3ffb20a0
05:32:40.893 -> A2 : 0x3ffb7618 A3 : 0x3ffb81a4 A4 : 0x00000004 A5 : 0x00060c23
05:32:40.990 -> A6 : 0x00060c23 A7 : 0x00000001 A8 : 0x3ffb81a4 A9 : 0x00000018
05:32:41.085 -> A10 : 0x3ffb81a4 A11 : 0x00000018 A12 : 0x3ffc2bdc A13 : 0x00060c23
05:32:41.181 -> A14 : 0x007bf3d8 A15 : 0x003fffff SAR : 0x00000019 EXCCAUSE: 0x00000006
05:32:41.277 -> EXCVADDR: 0x00000000 LBEG : 0x40088f10 LEND : 0x40088f1b LCOUNT : 0x00000000
05:32:41.374 ->
05:32:41.374 -> Backtrace: 0x4008e2cf:0x3ffb20a0 0x4008d243:0x3ffb20c0 0x4008c5d6:0x3ffb20e0 0x400e2216:0x3ffb2120 0x400e2315:0x3ffb2150 0x400d5d01:0x3ffb2170 0x400d5da9:0x3ffb21c0 0x400d3c3e:0x3ffb21f0 0x400d3c91:0x3ffb2220 0x400d21c9:0x3ffb2240 0x400d1a2e:0x3ffb2260 0x400d4e26:0x3ffb2290
05:32:41.662 ->
05:32:41.662 ->
05:32:41.662 -> Core 0 register dump:
05:32:41.709 -> PC : 0�
Couldn't find any solution to anything similar unfortunately.
void setup() {
Serial.begin(9600);
display.begin();
display.setFont(u8g2_font_profont29_tr);
display.firstPage();
do {
display.setCursor(0, 16);
display.println(F("not your"));
display.setCursor(0, 16 + 23);
display.println(F(" average"));
display.setCursor(0, 16 + 46);
display.println(F(" scale"));
} while (display.nextPage());
long splashStartMillis = millis();
// Serial.println(F("Starting scale..."));
hx711.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
watchDigitalPin(COFFEE_BUTTON_PIN);
Serial.println("test");
// Prime the scale and then zero while splash screen is up.
long delayUntilMillis = splashStartMillis + 1000;
while (millis() < delayUntilMillis) {
ascale.readRaw();
}
ascale.zero( /*sampleCount=*/ 5);
}
void IRAM_ATTR handleButtonPress() {
const unsigned long isr_millis = millis();
int events = 0;
int myBounces = 0;
for (PinStatus * ps = pinStatuses; ps != nullptr; ps = ps - > nextPinStatus) {
uint8_t state = digitalRead(ps - > pin);
// Warning: overflow after 50 days.
if (isr_millis >= ps - > nextStateMillis) {
if (state != ps - > state) {
// Lock in a button press for 200ms.
ps - > newEvent = true;
ps - > nextStateMillis = isr_millis + debounceDelayMs;
}
if (state != ps - > state || state != ps - > nextState) {
events++;
}
ps - > state = ps - > nextState = state;
} else {
if (state != ps - > state) {
myBounces++;
}
// Bounce!
ps - > nextState = state;
}
}
if (events == 0 && myBounces == 0) {
phantoms++;
}
bounces += myBounces;
}
void watchDigitalPin(uint8_t pin) {
noInterrupts();
pinMode(pin, INPUT_PULLUP);
PinStatus * ps = new PinStatus();
ps - > pin = pin;
ps - > state = digitalRead(pin);
ps - > nextState = ps - > state;
ps - > nextPinStatus = pinStatuses;
pinStatuses = ps;
// watched_digital_pins |= (1 << pin);
#if defined(__AVR__)
*digitalPinToPCMSK(pin) |= bit(digitalPinToPCMSKbit(pin)); // enable pin
PCIFR |= bit(digitalPinToPCICRbit(pin)); // clear any outstanding interrupt
PCICR |= bit(digitalPinToPCICRbit(pin)); // enable interrupt for the group
#else
attachInterrupt(digitalPinToInterrupt(pin), handleButtonPress, CHANGE);
#endif
interrupts();
}
I do not do any arduino programming if it was not obvious.
I tried to even call an empty ISR but same issue, all problems go away when I remove the attachInterrupt.