79123541

Date: 2024-10-24 20:39:46
Score: 2.5
Natty:
Report link

I also had the same problem today, but with an ESP32-C6 and the ESP-IDF 5.31. I'm using both TWAI controller and had the problem with both two times, because I first thought of using listen only (which will also give the same errorframe).

#define PIN_CAN0_RX     GPIO_NUM_23
#define PIN_CAN0_TX     GPIO_NUM_3
#define PIN_CAN1_RX     GPIO_NUM_21
#define PIN_CAN1_TX     GPIO_NUM_20

As you already said, there is a very small down-peak on the TX which will result in an error frame.

Through testing I played around in the library files and I might have an workaround, but I don't know why it is working. During playing I found out, that when the pin not even registered as an output but "de"activated as an output, it still works. So the workaround is to go to the "components/driver/twai/twai.c" and in the function "twai_configure_gpio" change the line:

//Set TX pin
gpio_conf.mode = GPIO_MODE_OUTPUT | (io_loop_back ? GPIO_MODE_INPUT : 0);

into

//Set TX pin
gpio_conf.mode = 0u | (io_loop_back ? GPIO_MODE_INPUT : 0);

I've NOT tested the io_loop_back mode, but this change will DEactivate the output mode for the selected pin and there is no error frame on init and TWAI I/O still works. Maybe the functionality of the following "esp_rom_gpio_connect_out_signal" will enable output mode for the pin shrug

Maybe this "fix"/workaround also works with you and maybe somebody with further insight into the esp-code could check why this works at least with the C6.

Best regards, Markus

Reasons:
  • Blacklisted phrase (0.5): Best regards
  • Blacklisted phrase (1): regards
  • Contains signature (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Markus