ESP32 Exception when reseting CAN controller

cmeyer18
Posts: 1
Joined: Mon Jul 31, 2023 3:50 pm

ESP32 Exception when reseting CAN controller

Postby cmeyer18 » Mon Jul 31, 2023 3:59 pm

I am running the following code, and getting an exception randomly on line 17 below (line 136 in source).

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

Who is online

Users browsing this forum: Bing [Bot] and 91 guests