Back

CAN_FD

Loading views...

CAN FD

Overview

CAN FD (CAN with Flexible Data-Rate) is an extension of the classic CAN protocol that increases maximum payload from 8 to 64 bytes and allows the data phase to run at up to 8 Mbps while keeping the arbitration phase at classical CAN speeds. It is the primary successor to CAN 2.0 in modern automotive and industrial systems.

1. Theory & Fundamentals

  • Backward-compatible with CAN 2.0 arbitration phase
  • Two bit rates: Arbitration phase (up to 1 Mbps) + Data phase (up to 8 Mbps)
  • Payload: Up to 64 bytes (vs 8 in CAN 2.0)
  • CRC: Enhanced CRC-17 or CRC-21 depending on payload length
  • BRS (Bit Rate Switch): Flag bit that signals switch to faster data rate
  • ESI (Error Status Indicator): Signals if transmitting node is error-passive
  • ISO 11898-1:2015 defines CAN FD

2. Frame / Packet Structure

CAN FD Frame:
  SOF | Arbitration ID (11 or 29-bit) | RRS | IDE | EDL | r0 | BRS | ESI
  | DLC(4) | Data(0–64B) | CRC(17 or 21b) | CRC Del | ACK | ACK Del | EOF | IFS

DLC to data length mapping:
  DLC 0–8: 0–8 bytes (same as CAN 2.0)
  DLC 9:   12 bytes
  DLC 10:  16 bytes
  DLC 11:  20 bytes
  DLC 12:  24 bytes
  DLC 13:  32 bytes
  DLC 14:  48 bytes
  DLC 15:  64 bytes

EDL=1: Extended Data Length (identifies as CAN FD frame)
BRS=1: Switch to faster bit rate after this bit

3. Protocol Mechanics

  • Arbitration identical to CAN 2.0 (1 Mbps max)
  • After BRS bit: Transceiver switches to data phase bit rate
  • After CRC delimiter: Returns to arbitration bit rate
  • No remote frames in CAN FD (RTR replaced by RRS, always recessive)
  • Stuff bit rule: After 4 identical bits (not 5 as in CAN 2.0) — ISO CAN FD
  • Fixed stuff bits: Added at defined positions for CRC integrity

4. Hardware Implementation

  • Transceivers: TJA1044, TJA1462, TCAN1044, MCP2562FD
  • Signal integrity critical at 8 Mbps: Short stubs, proper termination
  • Split termination recommended: 2x 60Ω + capacitor
  • Bus length vs speed: 8 Mbps = max ~10m; 2 Mbps = ~25m
  • MCUs with CAN FD: STM32G4, STM32H7, NXP S32K, Renesas RH850

5. Register-Level / Configuration

// STM32 FDCAN configuration
FDCAN_HandleTypeDef hfdcan;
hfdcan.Instance = FDCAN1;
hfdcan.Init.NominalPrescaler = 1;
hfdcan.Init.NominalSyncJumpWidth = 1;
hfdcan.Init.NominalTimeSeg1 = 63;  // 1 Mbps arbitration
hfdcan.Init.NominalTimeSeg2 = 16;
hfdcan.Init.DataPrescaler = 1;
hfdcan.Init.DataSyncJumpWidth = 4;
hfdcan.Init.DataTimeSeg1 = 11;     // 5 Mbps data phase
hfdcan.Init.DataTimeSeg2 = 4;
hfdcan.Init.FrameFormat = FDCAN_FRAME_FD_BRS;
HAL_FDCAN_Init(&hfdcan);
HAL_FDCAN_Start(&hfdcan);

FDCAN_TxHeaderTypeDef txHdr = {
    .Identifier = 0x123,
    .IdType = FDCAN_STANDARD_ID,
    .TxFrameType = FDCAN_DATA_FRAME,
    .DataLength = FDCAN_DLC_BYTES_64,
    .FDFormat = FDCAN_FD_CAN,
    .BitRateSwitch = FDCAN_BRS_ON,
};
uint8_t data[64] = {0};
HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan, &txHdr, data);

6. Driver / Software Development

// Receive CAN FD frame
FDCAN_RxHeaderTypeDef rxHdr;
uint8_t rxData[64];
if(HAL_FDCAN_GetRxMessage(&hfdcan, FDCAN_RX_FIFO0, &rxHdr, rxData) == HAL_OK) {
    uint8_t len = FDCAN_DLC_to_bytes[rxHdr.DataLength];
    ProcessCANFD(rxHdr.Identifier, rxData, len);
}

7. Debugging & Testing

  • CAN FD analyzer: PEAK PCAN-USB FD, Kvaser Leaf Pro FD, Vector VN1630A
  • Oscilloscope: Verify bit rate switch after BRS bit
  • Common issues: Transceiver doesn't support FD (use CAN FD-specific device); stub length causing reflections at 8 Mbps
  • Start with BRS disabled to verify basic CAN FD, then enable BRS

8. Real-World Applications

  1. Automotive ECU high-bandwidth sensor data (radar, camera)
  2. Electric vehicle battery management systems
  3. AUTOSAR-based ECU networks
  4. Industrial motion control
  5. Off-highway vehicle control systems

9. Advanced Topics & Edge Cases

  • ISO vs non-ISO CAN FD: ISO adds stuff bit counter; non-ISO (Bosch original) doesn't
  • CAN XL: Next generation after CAN FD — 20 Mbps, 2048-byte payload
  • AUTOSAR: CAN FD driver standardized in AUTOSAR 4.x
  • CAN FD gateway: Bridge between CAN FD and CAN 2.0 networks

10. Standards & Variants

Standard Payload Data Speed Notes
CAN 2.0A 8B 1 Mbps 11-bit ID
CAN 2.0B 8B 1 Mbps 29-bit ID
CAN FD 64B 8 Mbps ISO 11898-1:2015
CAN XL 2048B 20 Mbps Draft standard

💡 Practical Examples

Example 1: Send 64-byte sensor frame

uint8_t sensorData[64]; // Fill with radar point cloud data
HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan, &txHdr, sensorData);

Example 2: CAN FD + BRS for max throughput

Configure data phase at 8 Mbps, transmit 64-byte frames back-to-back.

Example 3: CAN FD with filter

Set receive filter to only accept ID range 0x100–0x1FF for one ECU.

🧪 Practice Questions

Beginner

  1. What is the maximum payload of CAN FD?
  2. What does BRS stand for and what does it do?
  3. What is the maximum data phase bit rate?
  4. What is EDL bit used for?
  5. Is CAN FD backward compatible with CAN 2.0?

Intermediate

  1. Calculate CAN FD data phase timing registers for 5 Mbps.
  2. What is the difference between ISO CAN FD and non-ISO CAN FD?
  3. How does CAN FD handle larger CRC for longer frames?
  4. Why does bus length limit decrease at higher data rates?
  5. Implement CAN FD receive with DLC-to-byte-length mapping.

Advanced

  1. Design a CAN FD network for automotive ADAS sensor fusion.
  2. Implement a CAN FD to CAN 2.0 gateway with payload segmentation.
  3. Optimize CAN FD for minimum latency in a real-time control loop.
  4. Debug CAN FD CRC errors caused by PCB signal integrity issues.
  5. Implement AUTOSAR CAN FD driver with CanTrcv wakeup.

Hands-on Projects

  1. High-Speed CAN Logger: Log CAN FD frames at 8 Mbps to SD card.
  2. BMS Network: CAN FD backbone for battery cell data (64 bytes per frame).
  3. CAN FD Analyzer: Decode and display CAN FD frames with DLC mapping.

Checklist

  • [ ] Explain CAN FD frame structure vs CAN 2.0
  • [ ] Configure FDCAN peripheral for dual bit rate
  • [ ] Send and receive 64-byte CAN FD frames
  • [ ] Enable and verify BRS bit rate switching
  • [ ] Use acceptance filters for CAN FD
  • [ ] Debug with CAN FD-capable analyzer
  • [ ] Handle ISO vs non-ISO CAN FD modes
  • [ ] Design CAN FD PCB for 8 Mbps
  • [ ] Implement CAN FD gateway
  • [ ] Integrate with AUTOSAR ComStack