EE Design Calc

CAN Bus Bit Timing Calculator

Generate register-ready bit timing parameters for STM32, ESP32, and NXP S32K. Select your MCU, enter the APB clock, choose the target baud rate, and get copy-paste C code.

Prescaler4.000
TSEG1 (BS1)16.00TQ
TSEG2 (BS2)4.000TQ
SJW4.000TQ
Total TQ per bit21.00
Actual Baud Rate500.0kbps
Sample Point81.00%
Baud Rate Error0.000%

Register Code Snippet

CAN_InitTypeDef hcan;
hcan.Prescaler = 4;
hcan.TimeSeg1  = CAN_BS1_16TQ;
hcan.TimeSeg2  = CAN_BS2_4TQ;
hcan.SyncJumpWidth = CAN_SJW_4TQ;

CAN Bus Bit Timing Explained

CAN bus timing is divided into discrete units called Time Quanta (TQ). Each bit is composed of multiple TQ segments: the Sync segment (always 1 TQ), the propagation and phase segment 1 (TSEG1/BS1), and the phase segment 2 (TSEG2/BS2).

Baud Rate Formula

Baud Rate = f_clk / (Prescaler × (1 + TSEG1 + TSEG2))

The total TQ per bit = 1 (sync) + TSEG1 + TSEG2. The calculator searches over valid prescaler and TQ combinations to find the setting closest to your target baud rate.

Sample Point

Sample Point = (1 + TSEG1) / (1 + TSEG1 + TSEG2) × 100%

The sample point is where the CAN controller reads the bus state within each bit. CiA 601 recommends 75–87.5%. A sample point too early may sample before the signal settles (propagation delay); too late leaves insufficient time for resynchronization.

MCU-Specific Clock Notes

MCUCAN Clock SourceTypical Value
STM32F4APB1 (PCLK1)42 MHz (at 168MHz sysclk)
STM32H7APB1 or FDCAN kernel clock80–100 MHz
ESP32APB clock (80MHz)80 MHz
NXP S32KFlexCAN source clock40–80 MHz

Frequently Asked Questions

What clock frequency should I use for STM32F4 CAN?
STM32F4 CAN is clocked from APB1. At the standard 168MHz system clock (AHB/2 = 84MHz, APB1/2 = 42MHz), use 42MHz. Check your RCC configuration in CubeMX or your startup code to confirm the actual APB1 frequency.

What is the recommended sample point?
CiA 601 recommends 75–87.5%. Most automotive designs use 80%. The calculator automatically targets this range. If you need a specific sample point, adjust TSEG1 and TSEG2 manually using the formula above.

What is SJW?
SJW (Synchronization Jump Width) is the maximum number of TQ by which the bit timing may be shortened or lengthened during resynchronization to stay in sync with a transmitting node. Larger SJW improves noise immunity but reduces the maximum allowable oscillator tolerance. Values of 1–4 TQ are typical.

My baud rate error is more than 1% — is that a problem?
CAN specification allows up to ±1.5% baud rate error for the bus as a whole. If two nodes each have 1% error in opposite directions, the total difference is 2% — potentially causing bit errors. Try a different clock frequency or use a PLL configuration that gives a more compatible CAN clock.