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.

CAN peripheral clock (MHz)e.g. 42 MHz (STM32F4 APB1), 48 MHz, 80 MHz (FDCAN)

Target bitrate (kbps)125 kbps250 kbps500 kbps1 Mbps2 Mbps (CAN-FD data)5 Mbps (CAN-FD data)Standard CAN 2.0B up to 1 Mbps; CAN-FD data 2–5 Mbps

Target sample point (%)CiA 301 recommends 87.5% (75–80% for CAN-FD data)

Sync Jump Width (SJW, TQ)Clamped to min(SJW, TSEG2) per ISO 11898-1

Quick presets:

Best Prescaler / TQ 6 / 16 TQ SYNC=1, TSEG1=13, TSEG2=2, SJW=1

Actual Sample Point 87.5% Bitrate error: 0.000%

STM32 bxCAN BTR 0x001C0005 CAN\_BTR register word

STM32 FDCAN NBTP 0x00050C01 FDCAN nominal timing word

| Prescaler | Total TQ | TSEG1 | TSEG2 | SJW | Sample Point | Error % | bxCAN BTR  | FDCAN NBTP |
| --------- | -------- | ----- | ----- | --- | ------------ | ------- | ---------- | ---------- |
| 6         | 16       | 13    | 2     | 1   | 87.5%        | 0.000%  | 0x001C0005 | 0x00050C01 |
| 12        | 8        | 6     | 1     | 1   | 87.5%        | 0.000%  | 0x0005000B | 0x000B0500 |
| 8         | 12       | 10    | 1     | 1   | 91.7%        | 0.000%  | 0x00090007 | 0x00070900 |
| 16        | 6        | 4     | 1     | 1   | 83.3%        | 0.000%  | 0x0003000F | 0x000F0300 |
| 4         | 24       | 16    | 7     | 1   | 70.8%        | 0.000%  | 0x006F0003 | 0x00030F06 |

## Bit-time formulas (ISO 11898-1)

| Parameter            | Formula                           | Practical constraint                                                    |
| -------------------- | --------------------------------- | ----------------------------------------------------------------------- |
| Time quantum (t\_q)  | BRP / f\_CAN                      | Higher TQ per bit gives finer sample-point placement.                   |
| Bit time             | (1 + TSEG1 + TSEG2) \* t\_q       | 1 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 tolerance | df ≤ 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.

[Guide: Multi-node CANopen testing](https://circuittwin.ai/guides/canopen-multi-node-testing) [Board: NUCLEO-H743ZI2 (FDCAN)](https://circuittwin.ai/boards/nucleo-h743zi2) [Board: NUCLEO-F767ZI (bxCAN)](https://circuittwin.ai/boards/nucleo-f767zi) [Docs: Multi-board CAN scenes](https://circuittwin.ai/docs/scenes)

> ## Test multi-node CAN bus-off recovery in CI
>
> Wire two or more compiled ECUs onto a virtual CAN bus in CircuitTwin and inject ACK errors or bit faults deterministically.
>
> [Start now](https://app.circuittwin.ai/try) [CANopen testing guide](https://circuittwin.ai/guides/canopen-multi-node-testing) [Connect a coding agent](https://circuittwin.ai/docs/agents)
