I am running the following code, and getting an exception randomly on line 17 below (line 136 in source).
if (millis() >= nextCheck)
{
nextCheck = millis() + 1215;
CANEnabled = false;
CAN.end();
if (getChipRevision() <= 1)
{
Serial.println("Starting CAN for REV1 ESP32");
if (!CAN.begin(250E3))
{
Serial.println("Starting CAN failed!");
}
}
else
{
if (!CAN.begin(500E3))
{
Serial.println("Starting CAN failed!");
}
else
{
Serial.println("Restarted CAN!");
}
}
CANEnabled = true;
}
This is a CAN library code, and the line inside that is causing the exception is gpio_set_direction(_rxPin, GPIO_MODE_INPUT);
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x400f8fe0 PS : 0x00060130 A0 : 0x800f9921 A1 : 0x3ffbd020
A2 : 0xc00fffff A3 : 0x00000000 A4 : 0x00000001 A5 : 0x00060123
A6 : 0x00000000 A7 : 0x00000000 A8 : 0xffffffff A9 : 0x00000001
A10 : 0x00013ffc A11 : 0x00000000 A12 : 0x00000004 A13 : 0x3ffb21e4
A14 : 0x00000003 A15 : 0x00060023 SAR : 0x00000008 EXCCAUSE: 0x0000001c
EXCVADDR: 0xffffffff LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0xffffffff
Backtrace: 0x400f8fdd:0x3ffbd020 0x400f991e:0x3ffbd050 0x400e9ee1:0x3ffbd080 0x400d3fda:0x3ffbd0a0 0x4008d50d:0x3ffbd0d0
#0 0x400f8fdd:0x3ffbd020 in gpio_ll_input_enable at C:\Users\cmeyer\.platformio\packages\framework-espidf\components\hal\esp32\include/hal/gpio_ll.h:319
(inlined by) gpio_input_enable at C:\Users\cmeyer\.platformio\packages\framework-espidf\components\driver/gpio.c:191
#1 0x400f991e:0x3ffbd050 in gpio_set_direction at C:\Users\cmeyer\.platformio\packages\framework-espidf\components\driver/gpio.c:284
#2 0x400e9ee1:0x3ffbd080 in ESP32SJA1000Class::begin(long) at .pio/libdeps/esp32dev/CAN/src/ESP32SJA1000.cpp:59
#3 0x400d3fda:0x3ffbd0a0 in TaskCANloop(void*) at src/ACC_Comm/canbus.cpp:136
#4 0x4008d50d:0x3ffbd0d0 in vPortTaskWrapper at C:\Users\cmeyer\.platformio\packages\framework-espidf\components\freertos\port\xtensa/port.c:142
ELF file SHA256: 7a7d73fa1820f810
What can I do to prevent these random exceptions?