Bit Timing & Synchronization

Module 2: CAN Physical Layer40 min

Bit Timing & Synchronization

Why Bit Timing Matters

CAN is an asynchronous protocol — there is no separate clock wire. Every node on the bus must independently sample each bit at the correct moment using its own local oscillator. If the sampling point drifts too far (due to oscillator inaccuracy, propagation delay, or temperature changes), the node will read the wrong bit value and generate errors.

The CAN Bit Structure

Each CAN bit is divided into four segments, measured in "time quanta" (TQ):

SegmentDurationPurpose
SYNC_SEG1 TQ (fixed)Synchronization — all nodes expect a bit edge here
PROP_SEG1–8 TQ (programmable)Compensates for physical propagation delay
PHASE_SEG11–8 TQ (programmable)Before the sample point — can be lengthened for resync
PHASE_SEG21–8 TQ (programmable)After the sample point — can be shortened for resync

The sample point is at the boundary between PHASE_SEG1 and PHASE_SEG2:

Sample point = (SYNC_SEG + PROP_SEG + PHASE_SEG1) / Total TQ per bit × 100%
Key Concept: Industry standard sample point positions: 75% for 1 Mbit/s CAN, 80% for 500 kbit/s CAN, 87.5% for 125–250 kbit/s CAN. Most automotive OEMs specify 80% as the default.

Calculating Bit Timing Parameters

Example: 80 MHz peripheral clock, target 500 kbit/s, 16 TQ per bit. Step 1: One bit = 1/500,000 = 2.0 µs. With 16 TQ: TQ = 2.0 µs / 16 = 125 ns. Step 2: Prescaler = (1/80 MHz) / 125 ns = 12.5 ns / 125 ns = 10. BRP = 10. Step 3: Target 80% sample point: 0.80 × 16 = 12.8, round to 13 TQ before sample. Step 4: Distribute segments:
  • SYNC_SEG = 1 TQ (fixed)
  • PROP_SEG = 7 TQ
  • PHASE_SEG1 = 5 TQ
  • PHASE_SEG2 = 3 TQ
  • SJW = min(4, PHASE_SEG1, PHASE_SEG2) = 3 TQ
ParameterValueRegister Value
Prescaler (BRP)10BRP = 9 (most controllers use n−1)
SYNC_SEG1 TQFixed, not configurable
PROP_SEG7 TQPROP = 6
PHASE_SEG15 TQTSEG1 = 4
PHASE_SEG23 TQTSEG2 = 2
SJW3 TQSJW = 2
Sample Point81.25%(1+7+5)/16 = 81.25%
Common Mistake: Most CAN controller registers use "n−1" encoding. If you calculate TSEG1 = 5 TQ, you write 4 to the register. Getting this wrong shifts the sample point and causes intermittent communication failures.

Oscillator Tolerance

CAN requires oscillator accuracy within ±1.58%. In practice:

  • Crystal oscillators: ±0.01% (50 ppm) — always sufficient
  • Ceramic resonators: ±0.3–0.5% — usually sufficient
  • Internal RC oscillators: ±1–5% — often too inaccurate, especially over temperature
Common Mistake: Never use the MCU's internal RC oscillator for CAN communication without verifying its accuracy over the full automotive temperature range (−40°C to +125°C). RC oscillators drift significantly with temperature, causing error frames at temperature extremes.
Exercise: Open the CAN initialization code for your current MCU project. Identify the prescaler, TSEG1, TSEG2, and SJW values. Calculate the sample point percentage. Does it match 75–87.5%?