I use libraries from https://github.com/sandeepmistry/arduino-CAN .I want to use ESP32 + SN65HVD230 in my car. I can't find good parameters to set CAN bus bitrate to 95 kbps. I already did it for Arduino + MCP2515 and everything works fine, but not for ESP32. After i connect ESP32 to CAN bus then i got a lot of errors and weird things happen, because of wrong bit timing. I tried to use calculator https://www.kvaser.com/support/calculat ... alculator/ (80 Mhz frequency for SJA1000, 95kbps, 0,5 % allowed error. So i edited ESP32SJA1000.cpp:
This is original
Code: Select all
case (long)100E3:
modifyRegister(REG_BTR1, 0x0f, 0x0c);
modifyRegister(REG_BTR0, 0x3f, 24);
break;
Code: Select all
case (long)95E3:
modifyRegister(REG_BTR1, 0x0f, 0x7b);
modifyRegister(REG_BTR0, 0x3f, 13);
break;
Code: Select all
case (long)95E3:
modifyRegister(REG_BTR1, 0x0f, 0x0c);
modifyRegister(REG_BTR0, 0x3f, 25);
break;
Code: Select all
#define CAN_TIMING_CONFIG_95KBITS() {.brp = 42, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false}
Code: Select all
case (long)95E3:
modifyRegister(REG_BTR1, 0x0f, 0x3d);
modifyRegister(REG_BTR0, 0x3f, 95);
break;