ESP-IDF CAN driver with Arduino - error transmit as invalid_state

User avatar
Civilduino
Posts: 3
Joined: Thu Jun 27, 2019 9:33 am

ESP-IDF CAN driver with Arduino - error transmit as invalid_state

Postby Civilduino » Tue Apr 21, 2020 9:29 am

Hello,

I am trying to use the IDF CAN driver with the Arduino Framework in Platformio. Everything seems to work fine when receiving CAN frames. However, when I try to transmit a CAN data frame or RTR I get an error in the bus (see below). I made a post in the github for the esp32/arduino but thought that it would be good to have it here too as it is related to ESP-IDF.

I can't find the error in my code or simply I am using the API in the wrong way. It is also hard to debug with JTAG as the driver is already compiled in the Arduino implementation and can't track it Platformio.

Do I need to create a specific task for transmitting? or reset the CAN driver after each transmission?

See the complete code and hardware description here https://github.com/espressif/arduino-esp32/issues/3921

I found these two threads and I can see they implemented it in a similar way as I did. Nevertheless they only show the receiving part.
viewtopic.php?f=19&t=12606&hilit=can+co ... A8+can+bus
https://esp32.com/viewtopic.php?f=19&t=12607

Code: Select all

ESP_ERROR_CHECK_WITHOUT_ABORT failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x4008d8df
file: "src/main.cpp" line 122
func: void CAN_transmit_stdData(uint32_t, uint8_t, uint8_t*)
expression: can_transmit(&message, pdMS_TO_TICKS(100))
After this the CAN goes BUSS-OFF.

User avatar
Civilduino
Posts: 3
Joined: Thu Jun 27, 2019 9:33 am

Re: ESP-IDF CAN driver with Arduino - error transmit as invalid_state

Postby Civilduino » Sat May 02, 2020 12:56 pm

Following this thread https://esp32.com/viewtopic.php?t=380&start=170 I observed the same behaviour with the CJMCU-230 module of the SN65HVD230. The differential lines showed different voltages compared to the data sheet and a lot of spikes (forgot to take pictures with the oscilloscope). I changed the IC in the module with an original part (since I believe the CJMCU-230 is fake) and things worked perfectly.

See picture below. Hope it helps someone else to avoid headaches.
SN65HVD230.png
SN65HVD230.png (337.71 KiB) Viewed 3282 times

Who is online

Users browsing this forum: No registered users and 35 guests