Open thefatmoop opened 1 month ago
In V3 of the ESP32 , Espressif added a bit in the interrupt register (Bit 4, 0x10), that actually doesn't control an Interrupt, but adds a "prescale by 2" factor to allow lower bitrates with the ESP32 CAN controller.
In line 135, we now have
writeRegister(REG_IER, 0xff); // enable all interrupts
which sets the prescale bit, thus dividing bitrates by 2. Replacing this with
writeRegister(REG_IER, 0xef); // enable all interrupts
resolves the issue.
I haven't taken a dig into why, but curious if someone can shed some light on this.
Hardware: ESP32 using the built in CAN transceiver. Using external can PHY chip. Monitoring the TX line straight out of the esp32.
Measurements: scope - Setting the baud rate as 500kbaud on esp32 results in a single bit width of 250khz. salae logic analyzer - Setting the baud rate as 500kbaud on esp32, have to set salae logic to 250kbaud to decode packets.
conclusion It looks like whatever baud is set in can.begin(baud) gets halved. Am I doing something wrong?