Esp32 can bus work only on some boards

Fmiglior
Posts: 2
Joined: Thu Jun 20, 2024 8:52 am

Esp32 can bus work only on some boards

Postby Fmiglior » Thu Jun 20, 2024 9:10 am

I have a lot of esp32 dev boards, of some different makers, but all with the same esp32-wroom.
I’m try to read some can bus informations of my car.
I can make the sn65hdv work in 2 boards but not in the others the same code is not working, I try different can modules. Vp230…vp232.. different can libraries. Different pins…. Arduino ide.. platformio…
And the always the same result =\
The rest of the code work in all the boards. The oled display, buttons and leds. But only in 2 boards the can module works.
I try to upload the firmware. And the results was the same.
The only difference I noted is one of the boards that the can module work, I have to hold the boot button to upload the code.
Any one have a idea why the same code and the same can module works in one dev board but not in the other?

keesza
Posts: 7
Joined: Mon Jun 17, 2024 5:47 pm

Re: Esp32 can bus work only on some boards

Postby keesza » Thu Jun 20, 2024 9:46 am

I guess it is the same issue as I posted a few days ago. In the mean time I updated this issue however it is not publiced yet.
In the datasheet of ESP32 (https://www.espressif.com/sites/default ... eet_en.pdf) you can read on page 38 that there is a difference in CAN (or TWAI) in the old and the new versions. In the old versions they used the standard 80 MHz frequency for the CANcontroller (in fact the SJA1000). In the new one they used 40 MHz, which means that they can reach a bitrate which is factor 2 lower. However this means that using a CAN library which is written based on the old version the bitrate on the new version is always divided by 2. So if you set it to 1 Mbit/sec it will be actually operating on 500 kbit/sec. I don't know which CAN library you are using, but probably anywhere in that library there will be a CAN init routine which sets the bitrate parameters. Probably the constant APB_CLK_FREQ will be used in this library as the basic frequency. This is always 80000. If you replace this constant by 40000, it will be probably also working on the new units. Getting the version of the chip can be determined by the ESPTOOL.

Fmiglior
Posts: 2
Joined: Thu Jun 20, 2024 8:52 am

Re: Esp32 can bus work only on some boards

Postby Fmiglior » Fri Jun 21, 2024 10:36 pm

Thanks! This solve the problem I multiply x2 the can speed and work!

Who is online

Users browsing this forum: No registered users and 69 guests