CAN 2.0B / CAN-FD

CAN & CAN-FD Bit Timing Calculator

Solve prescaler, TSEG1, TSEG2 and SJW for your peripheral clock, then copy the exact STM32 CAN_BTR or FDCAN_NBTP register word.

e.g. 42 MHz (STM32F4 APB1), 48 MHz, 80 MHz (FDCAN)
Standard CAN 2.0B up to 1 Mbps; CAN-FD data 2–5 Mbps
CiA 301 recommends 87.5% (75–80% for CAN-FD data)
Clamped to min(SJW, TSEG2) per ISO 11898-1
Quick presets:
Best Prescaler / TQ6 / 16 TQSYNC=1, TSEG1=13, TSEG2=2, SJW=1
Actual Sample Point87.5%Bitrate error: 0.000%
STM32 bxCAN BTR0x001C0005CAN_BTR register word
STM32 FDCAN NBTP0x00050C01FDCAN nominal timing word
PrescalerTotal TQTSEG1TSEG2SJWSample PointError %bxCAN BTRFDCAN NBTP
616132187.5%0.000%0x001C00050x00050C01
12861187.5%0.000%0x0005000B0x000B0500
812101191.7%0.000%0x000900070x00070900
16641183.3%0.000%0x0003000F0x000F0300
424167170.8%0.000%0x006F00030x00030F06

Bit-time formulas (ISO 11898-1)

ParameterFormulaPractical constraint
Time quantum (t_q)BRP / f_CANHigher TQ per bit gives finer sample-point placement.
Bit time(1 + TSEG1 + TSEG2) * t_q1 TQ is always fixed to SYNC_SEG.
Sample point(1 + TSEG1) / (1 + TSEG1 + TSEG2)CiA 301 targets 87.5% nominal; CAN-FD data phase typically uses 75–80%.
Oscillator tolerancedf ≤ SJW / (20 * N_TQ)Keep SJW as large as TSEG2 allows when using ceramic resonators.

STM32 register bit layout

STM32 bxCAN & FDCAN register encoding
/* bxCAN CAN_BTR (STM32F1/F4/F7): each field stores value - 1 */
CAN1->BTR = ((SJW - 1) << 24)
          | ((TSEG2 - 1) << 20)
          | ((TSEG1 - 1) << 16)
          | ((BRP - 1) & 0x3FF);

/* FDCAN_NBTP (STM32H7/G0/G4/U5): nominal bit timing */
FDCAN1->NBTP = ((NSJW - 1) << 25)
             | ((NBRP - 1) << 16)
             | ((NTSEG1 - 1) << 8)
             | ((NTSEG2 - 1) & 0x7F);

Multi-node CAN arbitration and fault testing

Single-node loopback misses bus-off recovery and mismatched sample points across nodes. CircuitTwin scenes wire multiple MCU binaries onto a shared CAN bus and inject bit errors, ACK failures, or dropped frames deterministically in CI.