Topics A–Z

MCU

CAN Protocol Explained: Differential Wiring, Arbitration, and Real-Time Reliability

How Controller Area Network runs dozens of ECUs over one twisted pair without collisions — covering differential signaling, 60 Ω termination, priority arbitration, bit stuffing, error states, and CAN FD.

LVL 63 min read

For Readers familiar with microcontroller serial buses and basic circuit concepts who want to understand industrial and automotive networking.

LVL 5

A simpler explanation with fewer formulas.

Inside a car, EV, or factory robot, dozens of microcontrollers exchange brake pressures and motor torques centimeters away from noisy high-current inverters. Single-ended buses like UART, I2C, and SPI drown in interference within a meter. CAN (Controller Area Network, ISO 11898) solves this with one twisted pair, lossless priority arbitration, and hardware fault isolation.

Designed by Robert Bosch GmbH in the 1980s, CAN replaced heavy point-to-point vehicle wire harnesses with a shared two-wire trunk (CAN_H and CAN_L). Every node plugs into the same pair, broadcasts short labeled packets (“engine RPM = 2,400”), and filters out IDs it does not need.

Standardized under ISO 11898-1 (data link) and ISO 11898-2 (high-speed physical), CAN is a multi-master, broadcast serial bus for deterministic real-time control. Frames carry priority-ordered message IDs instead of node addresses; wired-AND arbitration resolves simultaneous sends bit by bit with zero throughput loss, while hardware fault confinement automatically disconnects misbehaving nodes.

Differential signaling and the 60 Ω bus

CAN encodes bits as the voltage difference between two twisted wires, CAN_H and CAN_L. In recessive (1), both rest near 2.5 V (0 V difference). In dominant (0), the driver pushes CAN_H to ~3.5 V and CAN_L to ~1.5 V (~2.0 V difference). Because electromagnetic noise shifts both twisted wires equally, subtracting CAN_H − CAN_L cancels it out.

High-Speed CAN terminates both physical ends of the trunk with 120 Ω resistors matching the pair’s impedance (Z_0 ≈ 120 Ω):

Vdiff=VCANH−VCANLRbus=120 Ω∥120 Ω=60 ΩV_{\text{diff}} = V_{\text{CANH}} - V_{\text{CANL}} \qquad R_{\text{bus}} = 120\ \Omega \parallel 120\ \Omega = 60\ \Omega

With power off, a multimeter across CAN_H–CAN_L diagnoses the trunk instantly: 60 Ω = healthy, 120 Ω = one terminator missing, open = none, ≤ 40 Ω = extra mid-bus terminators. Keep drop stubs under 0.3 m at 1 Mbps to prevent reflections.

Non-destructive bitwise arbitration

Unlike Ethernet’s collision-and-retry, CAN’s physical layer makes dominant (0) beat recessive (1). Every frame starts with a priority ID (0x000–0x7FF in 11-bit CAN). If brakes (0x080) and climate control (0x420) start transmitting at the same microsecond, both send MSB-first while listening. On the first disagreeing bit, brakes drive 0 while climate releases 1; climate sees 0, backs off to receive mode, and brakes finish with zero lost bits. Lower ID = higher priority.

Differential wired-AND gives CAN CSMA/CR (Collision Resolution). Any transmitter sending recessive 1 while sampling dominant 0 during the arbitration field (11-bit CAN 2.0A or 29-bit CAN 2.0B) immediately switches to receive mode; the winner suffers zero backoff delay. Because RTR and IDE follow the base ID, data frames (RTR = 0) beat remote requests (RTR = 1), and 11-bit frames (IDE = 0) beat 29-bit frames sharing the same upper 11 bits.

Frame anatomy, bit stuffing, and bus length

A Classic CAN frame packs 0–8 bytes with full protection: SOF (1 dominant bit to sync) → 11-bit ID → DLC length → Data → 15-bit CRC → ACK (any valid receiver pulls this slot dominant 0, so a lone bench node with no listener loops on ACK errors) → 7-bit EOF.

With no clock wire, CAN uses NRZ bit stuffing from SOF through CRC: after 5 identical consecutive bits, the transmitter inserts 1 opposite stuff bit (stripped by receivers). Six identical bits is deliberately illegal and triggers an immediate bus-wide Error Frame.

Field (CAN 2.0A)BitsRole
SOF1Hard sync on idle→dominant edge
ID + RTR11 + 1Bitwise priority arbitration
IDE + r0 + DLC1 + 1 + 4Frame format & length (0–8 bytes)
Data0–64Payload (MSB first per byte)
CRC + Delim15 + 1x¹⁵ + x¹⁴ + x¹⁰ + x⁸ + x⁷ + x⁴ + x³ + 1 (HD 6)
ACK + Delim1 + 1Physical in-frame confirmation
EOF + IFS7 + 3Fixed end & interframe space (unstuffed)

Because arbitration requires round-trip propagation within one bit time (sampling at 75%–87.5% between Phase_Seg1 and Phase_Seg2), higher bit rates shorten max trunk length: 1 Mbps → ~40 m, 500 kbps → ~100 m, 250 kbps → ~250 m, 125 kbps → ~500 m.

Fault confinement, CAN FD, and real-time guarantees

Every CAN controller tracks its own error count: a faulty node restricts itself and eventually disconnects (Bus-Off) so it cannot jam the vehicle. Modern systems also use CAN FD, keeping classic arbitration then switching up to 5 Mbps and 64-byte payloads for the data phase.

ISO 11898-1 enforces a three-state hardware machine using TEC (Transmit Error Counter) and REC: Error Active (TEC, REC < 128, sends 6 dominant error bits), Error Passive (128 ≤ TEC ≤ 255 or REC ≥ 128, sends only 6 recessive bits + 8-bit suspend), and Bus-Off (TEC ≥ 256, hard disconnect until 128 × 11 consecutive recessive bits). CAN FD asserts BRS (Bit Rate Switch) after arbitration to accelerate data/CRC up to 5–8 Mbps and 64 bytes, upgrading to CRC-17/21 plus a Gray-coded stuff count.

ISO 11898-1 isolates faults deterministically via TEC (+8 on TX error, −1 on success) and REC (Error Active < 128 → Error Passive 128–255 → Bus-Off ≥ 256), while CAN FD pairs nominal arbitration with BRS acceleration (5–8 Mbps · 64 B, CRC-17/21 + stuff count), and CAN XL pushes to 2,048 B / 10+ Mbps.

Because resynchronization occurs only on recessive→dominant edges (up to 10 bits between edges), oscillator tolerance df must satisfy:

df≤SJW20 NBTanddf≤min⁡(Phase_Seg1, Phase_Seg2)2 (13 NBT−Phase_Seg2)df \le \frac{\text{SJW}}{20\,\text{NBT}} \qquad \text{and} \qquad df \le \frac{\min(\text{Phase\_Seg1},\,\text{Phase\_Seg2})}{2\,(13\,\text{NBT} - \text{Phase\_Seg2})}

At NBT = 16 T_q and SJW = 2 T_q, df ≤ 0.625% — making ±50 ppm quartz crystals essential for 5 Mbps CAN FD. Finally, because arbitration acts as a global fixed-priority non-preemptive scheduler, Tindell–Burns / Davis response-time analysis proves hard real-time deadlines R_m ≤ D_m:

Rm=Jm+wm+Cm,wm=Bm+∑k∈hp(m)⌈wm+Jk+τbitTk⌉CkR_m = J_m + w_m + C_m, \qquad w_m = B_m + \sum_{k \in \text{hp}(m)} \left\lceil \frac{w_m + J_k + \tau_{\text{bit}}}{T_k} \right\rceil C_k