ESP32 crash on reading ADS1115 on interrupt

smah80
Posts: 1
Joined: Sun May 02, 2021 10:22 am

ESP32 crash on reading ADS1115 on interrupt

Postby smah80 » Sun May 02, 2021 10:26 am

Hi,
I am using ADS1115 and reading its trying to read its value based on interrupt.
but it get crashed when trying to read the following line.

Code: Select all

void ICACHE_RAM_ATTR encoder_isr() {
adc0 = ads.readADC_SingleEnded(0); // Crashed here.[adc0 is volatile int16_t];
voltage = ads.computeVolts(adc0);
}
here is the exception what serial monitor shows

Code: Select all

Guru Meditation Error: Core 1 panic’ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC : 0x400d18ac PS : 0x00060a34 A0 : 0x800d1e21 A1 : 0x3ffbe660
A2 : 0x3ffbebe8 A3 : 0x00000000 A4 : 0x00000190 A5 : 0x00000064
A6 : 0x000000c8 A7 : 0x60013000 A8 : 0xffffc000 A9 : 0x0155409f
A10 : 0x0e4e1c00 A11 : 0x00000001 A12 : 0x00000000 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000001d EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
Core 1 was running in ISR context:
EPC1 : 0x400d295e EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x400d18ac
Backtrace: 0x400d18ac:0x3ffbe660 0x400d1e1e:0x3ffbe680 0x400d1f4c:0x3ffbe6b0 0x400d1245:0x3ffbe6d0 0x400d1299:0x3ffbe6f0 0x400d10a1:0x3ffbe710 0x400d0f0e:0x3ffbe730 0x400d0f69:0x3ffbe750 0x400d0fc0:0x3ffbe770 0x40080f17:0x3ffbe790 0x40080fd9:0x3ffbe7b0 0x40084e99:0x3ffbe7d0 0x40081ddb:0x3ffb1f30 0x40082963:0x3ffb1f50 0x40081a33:0x3ffb1f70 0x400d0d96:0x3ffb1f90 0x400d27d1:0x3ffb1fb0 0x40088ac1:0x3ffb1fd0
Core 0 register dump:
PC : 0x400ea46e PS : 0x00060134 A0 : 0x800d5196 A1 : 0x3ffbbff0
A2 : 0x00000000 A3 : 0x00000001 A4 : 0x00000000 A5 : 0x00000001
A6 : 0x00060120 A7 : 0x00000000 A8 : 0x800d4d5e A9 : 0x3ffbbfc0
A10 : 0x00000000 A11 : 0x40085624 A12 : 0x00060120 A13 : 0x3ffbb690
A14 : 0x00000000 A15 : 0x3ffbbce0 SAR : 0x00000000 EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Backtrace: 0x400ea46e:0x3ffbbff0 0x400d5193:0x3ffbc010 0x4008a262:0x3ffbc030 0x40088ac1:0x3ffbc050
Any idea why this is happening?

ESP_Sprite
Posts: 4658
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 crash on reading ADS1115 on interrupt

Postby ESP_Sprite » Thu May 06, 2021 3:11 am

Likely ads.readADC_SingleEnded is not safe to call from an ISR. Suggest you use e.g. a FreeRTOS semaphore to communicate the fact that an interrupt happened to a task, then do the read in that task instead.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 41 guests