Skip to content

SAE bus timing changes #1102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vehicle/OVMS.V3/components/esp32can/src/esp32can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ esp_err_t esp32can::InitController()
/* Set sampling
* 1 -> triple; the bus is sampled three times; recommended for low/medium speed buses (class A and B) where filtering spikes on the bus line is beneficial
* 0 -> single; the bus is sampled once; recommended for high speed buses (SAE class C)*/
MODULE_ESP32CAN->BTR1.B.SAM=0x1;
MODULE_ESP32CAN->BTR1.B.SAM = (MyESP32can->m_speed < CAN_SPEED_125KBPS) ? 1 : 0;

// Enable all interrupts except arbitration loss (can be ignored):
uint32_t ier = 0xff & ~__CAN_IRQ_ARB_LOST;
Expand Down
8 changes: 7 additions & 1 deletion vehicle/OVMS.V3/components/mcp2515/src/mcp2515.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,13 @@ esp_err_t mcp2515::Start(CAN_mode_t mode, CAN_speed_t speed)
cnf1=0x41; cnf2=0xf1; cnf3=0x85;
break;
case CAN_SPEED_500KBPS:
cnf1=0x00; cnf2=0xf0; cnf3=0x86;
// cnf1=0x00; cnf2=0xf0; cnf3=0x86; original code
// SAE/CiA recommendation
// PROP=5, PS1=8, PS2=2, SJW=2, Sample 1x @87.5%
cnf1=0x40; cnf2=0xbc; cnf3=0x81;
// Arduino MCP_CAN lib
// PROP=6, PS1=5, PS2=4, SJW=2, Sample 3x @75%
// cnf1=0x40; cnf2=0xe5; cnf3=0x83;
break;
case CAN_SPEED_1000KBPS:
cnf1=0x00; cnf2=0xca; cnf3=0x81;
Expand Down