Excuse the learner question but I haven't developed SPI interfaces before and learning as I go.
I am trying to connect a MRF24J40 to a Wemos D1 Mini ESP32 to send and retrieve 802.15.4 style messages. The code itself seems to work ok but I am getting periodic segfaults and I think it is related to how I handle (or don't) the interrupt handler. I have modified the GitHub - karlp/Mrf24j40-arduino-library: arduino driver for the mrf24j40 802.15.4 modules library to meet my needs but still keep on getting the segfaults.
My full code can be found at: pethublocal/WemosPetHub at main · plambrechtsen/pethublocal · GitHub
Previously I wasn't having the SPI.beginTransaction(mySettings); / SPI.endTransaction(); around all the digitalRead/Write.
As I am using the ESP32 rather than an 8266 I can't add SPI.usingInterrupt as it isn't supported.
But the segfaults persist.
I think this is because either I am writing to the SPI when another frame turns up and even though I have set noInterrupts it still causes an interrupt.
Should I just remove the interrupt handler and periodically just read the device to see if any messages are waiting as I can't seem to see how else I could fix this.
The segfault I am getting is.
Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC : 0x4008c1c8 PS : 0x00060934 A0 : 0x8008b3db A1 : 0x3ffc0050
A2 : 0x3ffba5a4 A3 : 0x3ffb8074 A4 : 0x00000001 A5 : 0x00000001
A6 : 0x00060923 A7 : 0x00000000 A8 : 0x3ffb8074 A9 : 0x3ffb8074
A10 : 0x00000018 A11 : 0x00000018 A12 : 0x00000001 A13 : 0x00000001
A14 : 0x00060921 A15 : 0x00000000 SAR : 0x0000001a EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffd
Core 1 was running in ISR context:
EPC1 : 0x4008a8be EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x4008c1c8
ELF file SHA256: 0000000000000000
Backtrace: 0x4008c1c8:0x3ffc0050 0x4008b3d8:0x3ffc0070 0x4008970f:0x3ffc0090 0x400d5bd9:0x3ffc00d0 0x400d36b1:0x3ffc00f0 0x400d26d1:0x3ffc0120 0x400d2bb5:0x3ffc0140 0x400d1162:0x3ffc0170 0x40080fe5:0x3ffc0190 0x400855ed:0x3ffc01b0 0x400d5cc4:0x3ffb1bb0 0x400d36e2:0x3ffb1bd0 0x400d27e6:0x3ffb1bf0 0x400d28b6:0x3ffb1c10 0x400d1ae9:0x3ffb1c30 0x400d2afd:0x3ffb1f70 0x400d1c48:0x3ffb1f90 0x400d6869:0x3ffb1fb0 0x400898d2:0x3ffb1fd0
#0 0x4008c1c8:0x3ffc0050 in vListInsert at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/list.c:188 (discriminator 1)
#1 0x4008b3d8:0x3ffc0070 in vTaskPlaceOnEventList at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c:3507
#2 0x4008970f:0x3ffc0090 in xQueueGenericReceive at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:2038
#3 0x400d5bd9:0x3ffc00d0 in spiTransaction at C:\users\user\.platformio\packages\framework-arduinoespressif32\cores\esp32/esp32-hal-spi.c:283
#4 0x400d36b1:0x3ffc00f0 in SPIClass::beginTransaction(SPISettings) at C:\users\user\.platformio\packages\framework-arduinoespressif32\libraries\SPI\src/SPI.cpp:262
#5 0x400d26d1:0x3ffc0120 in Mrf24j::read_short(unsigned char) at src/mrf24j.cpp:484
#6 0x400d2bb5:0x3ffc0140 in Mrf24j::interrupt_handler() at src/mrf24j.cpp:331
#7 0x400d1162:0x3ffc0170 in interrupt_routine() at .pio\libdeps\WemosPetHub\ArduinoJson\src/ArduinoJson/Deserialization/DeserializationError.hpp:20
#8 0x40080fe5:0x3ffc0190 in __onPinInterrupt at C:\users\user\.platformio\packages\framework-arduinoespressif32\cores\esp32/esp32-hal-gpio.c:274
#9 0x400855ed:0x3ffc01b0 in _xt_lowint1 at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/xtensa_vectors.S:1154
#10 0x400d5cc4:0x3ffb1bb0 in spiTransferByteNL at C:\users\user\.platformio\packages\framework-arduinoespressif32\cores\esp32/esp32-hal-spi.c:283
#11 0x400d36e2:0x3ffb1bd0 in SPIClass::transfer(unsigned char) at C:\users\user\.platformio\packages\framework-arduinoespressif32\libraries\SPI\src/SPI.cpp:262
#12 0x400d27e6:0x3ffb1bf0 in Mrf24j::write_long(unsigned int, unsigned char) at src/mrf24j.cpp:484
#13 0x400d28b6:0x3ffb1c10 in Mrf24j::sendframe(_tx_info_t) at src/mrf24j.cpp:484
#14 0x400d1ae9:0x3ffb1c30 in handle_rx() at .pio\libdeps\WemosPetHub\ArduinoJson\src/ArduinoJson/Deserialization/DeserializationError.hpp:20
#15 0x400d2afd:0x3ffb1f70 in Mrf24j::check_flags(void (*)(), void (*)()) at src/mrf24j.cpp:484
#16 0x400d1c48:0x3ffb1f90 in loop() at .pio\libdeps\WemosPetHub\ArduinoJson\src/ArduinoJson/Deserialization/DeserializationError.hpp:20
#17 0x400d6869:0x3ffb1fb0 in loopTask(void*) at C:\users\user\.platformio\packages\framework-arduinoespressif32\cores\esp32/main.cpp:37
#18 0x400898d2:0x3ffb1fd0 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)
Core 0 register dump:
PC : 0x4008a8be PS : 0x00060034 A0 : 0x8008b0a1 A1 : 0x3ffbfb30
A2 : 0x3ffbf17c A3 : 0x0000cdcd A4 : 0xb33fffff A5 : 0x00000001
A6 : 0x00060021 A7 : 0x0000abab A8 : 0x0000abab A9 : 0x3ffc1db0
A10 : 0x00000003 A11 : 0x00060023 A12 : 0x00060021 A13 : 0x00000001
A14 : 0x0000002a A15 : 0x3ffb3e00 SAR : 0x00000018 EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000
Backtrace: 0x4008a8be:0x3ffbfb30 0x4008b09e:0x3ffbfb60 0x400899bf:0x3ffbfb80 0x4008c045:0x3ffbfba0 0x400855f6:0x3ffbfbb0 0x4014310f:0x3ffbc2d0 0x400e84b7:0x3ffbc2f0 0x4008b069:0x3ffbc310 0x400898d2:0x3ffbc330
#0 0x4008a8be:0x3ffbfb30 in uxPortCompareSet at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c:3507
(inlined by) vPortCPUAcquireMutexIntsDisabledInternal at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/portmux_impl.inc.h:86
(inlined by) vPortCPUAcquireMutexIntsDisabled at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/portmux_impl.h:98
(inlined by) vTaskEnterCritical at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c:4201
#1 0x4008b09e:0x3ffbfb60 in xTaskIncrementTick at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c:3507
#2 0x400899bf:0x3ffbfb80 in xPortSysTickHandler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)
#3 0x4008c045:0x3ffbfba0 in _frxt_timer_int at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/portasm.S:303
#4 0x400855f6:0x3ffbfbb0 in _xt_lowint1 at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/xtensa_vectors.S:1154
#5 0x4014310f:0x3ffbc2d0 in esp_pm_impl_waiti at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/pm_esp32.c:492
#6 0x400e84b7:0x3ffbc2f0 in esp_vApplicationIdleHook at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/freertos_hooks.c:86
#7 0x4008b069:0x3ffbc310 in prvIdleTask at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c:3507
#8 0x400898d2:0x3ffbc330 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)
Rebooting...
This doesn't happen if I don't send any SPI frames, so would appreciate any pointers as to where I am going wrong.