I'm programming a device using ESP32. The device uses SPI for control and raises interrupts on GPIO pins for feedback. (Actually there are two identical RF devices connected to HSPI and VSPI and pinned to one of the ESP32 cores - for debugging/development ease. Each device has 2 independent transceivers. So there are 4 concurrent devices controlled via SPI). I need to run SPI commands from the task context as well as the from ISR context. All SPI comm is wrapped into spi.beginTransaction / spi.endTransaction. In the task context SPI comm is additionally wrapped into noInterrupts / interrupts blocks. Once in a while a crash happens in spi.endTransaction as below. What can potentially cause this?
Also what are best practices for SPI programming when interrupts are involved that I'm not aware of?
Thanks!
Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).
Core 1 register dump:
PC : 0x4008c377 PS : 0x00060f35 A0 : 0x8008ba37 A1 : 0x3ffc7d10
A2 : 0x3ffbf338 A3 : 0xb33fffff A4 : 0x0000cdcd A5 : 0x00060f23
A6 : 0x00060f23 A7 : 0x0000abab A8 : 0x0000cdcd A9 : 0xffffffff
A10 : 0x3ffc25b4 A11 : 0x0000005a A12 : 0x3ffc7e40 A13 : 0x3ffc7e40
A14 : 0x007bf338 A15 : 0x003fffff SAR : 0x00000011 EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x400872d4 LEND : 0x400872ea LCOUNT : 0x00000000
Backtrace: 0x4008c374:0x3ffc7d10 0x4008ba34:0x3ffc7d50 0x40089a62:0x3ffc7d70 0x40089f3e:0x3ffc7d90 0x400d604d:0x3ffc7dd0 0x400d25c5:0x3ffc7df0 0x4008129e:0x3ffc7e10 0x40082002:0x3ffc7e40 0x40081ec2:0x3ffc7ef0 0x400d19c2:0x3ffc7f40
#0 0x4008c374:0x3ffc7d10 in compare_and_set_native at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_hw_support/include/soc/compare_set.h:25
(inlined by) spinlock_acquire at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_hw_support/include/soc/spinlock.h:103
(inlined by) xPortEnterCriticalTimeout at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/port.c:301
#1 0x4008ba34:0x3ffc7d50 in vPortEnterCritical at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/include/freertos/portmacro.h:578
(inlined by) xTaskPriorityDisinherit at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/tasks.c:4806
#2 0x40089a62:0x3ffc7d70 in prvCopyDataToQueue at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/queue.c:2245
#3 0x40089f3e:0x3ffc7d90 in xQueueGenericSend at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/queue.c:854
#4 0x400d604d:0x3ffc7dd0 in spiEndTransaction at /Users/anton/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-spi.c:1153
#5 0x400d25c5:0x3ffc7df0 in SPIClass::endTransaction() at /Users/anton/.platformio/packages/framework-arduinoespressif32/libraries/SPI/src/SPI.cpp:193
#6 0x4008129e:0x3ffc7e10 in AT86RF215Hal::spiTransactionUnlock() at lib/at86rf215/at86rf215_hal.h:34
(inlined by) AT86RF215Driver::Band::rx(unsigned char*, unsigned short) at lib/at86rf215/at86rf215_driver.cpp:116
#7 0x40082002:0x3ffc7e40 in Rx::update() at lib/modem/rx.cpp:37
#8 0x40081ec2:0x3ffc7ef0 in Modem::update() at lib/modem/modem.cpp:69
#9 0x400d19c2:0x3ffc7f40 in void loopModem<modemAir>(void*) at src/main.cpp:57 (discriminator 1)
Core 0 register dump:
PC : 0x4008c1de PS : 0x00060735 A0 : 0x8008b152 A1 : 0x3ffbe97c
A2 : 0x3ffb7e64 A3 : 0x3ffbca54 A4 : 0x00000000 A5 : 0x00060723
A6 : 0x00060723 A7 : 0x00000001 A8 : 0x3ffbca54 A9 : 0x00000019
A10 : 0x3ffbca54 A11 : 0x00000019 A12 : 0x3ffc50d0 A13 : 0x00060723
A14 : 0x007bf338 A15 : 0x003fffff SAR : 0x00000006 EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Backtrace: 0x4008c1db:0x3ffbe97c |<-CORRUPTED
#0 0x4008c1db:0x3ffbe97c in vListInsert at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/list.c:183