Back to Blog
AutomotiveOctober 12, 202512 min read

Understanding CAN Bus Protocol in Automotive Embedded Systems

Deep dive into CAN bus architecture, message framing, arbitration, and error handling. Learn how CAN FD and CAN XL are shaping next-gen vehicles.

Understanding CAN Bus Protocol in Automotive Embedded Systems

Controller Area Network (CAN) is a robust, multi-master serial communication protocol originally developed by Bosch in 1986 that has become the backbone of automotive embedded systems, connecting Electronic Control Units (ECUs) for engine management, transmission, braking, airbags, and infotainment. CAN uses a message-based protocol with non-destructive bitwise arbitration, meaning multiple nodes can attempt to transmit simultaneously and the highest-priority message (lowest ID) wins without data loss. Classic CAN supports data rates up to 1 Mbps with 8-byte payloads, while CAN FD (Flexible Data-rate), introduced in 2012, increases the payload to 64 bytes and the data phase bit rate to 5-8 Mbps. A modern vehicle contains 70-150 ECUs communicating over multiple CAN buses segmented by domain (powertrain, chassis, body, infotainment). The protocol's built-in error detection mechanisms including CRC, bit stuffing, frame checks, and automatic retransmission provide the reliability required for safety-critical automotive applications conforming to ISO 11898 and AUTOSAR standards.

How Does CAN Bus Message Arbitration Work?

CAN uses Carrier Sense Multiple Access with Collision Detection and Arbitration on Message Priority (CSMA/CD+AMP). When a node wants to transmit, it waits for bus idle, then starts sending the message identifier bit by bit. The bus uses wired-AND logic: a dominant bit (0) overrides a recessive bit (1). If a node transmits a recessive bit but reads a dominant bit on the bus, it knows another node with a higher-priority message is transmitting and immediately backs off. This non-destructive arbitration means the highest-priority message always gets through without delay, while lower-priority messages are deferred. The 11-bit standard identifier (CAN 2.0A) allows 2,048 unique message IDs, while the 29-bit extended identifier (CAN 2.0B) supports over 500 million unique IDs.

What Is a CAN Frame Structure?

/* CAN Frame Structure (Standard 11-bit ID)
 * ┌─────┬──────────┬───┬────┬──────────┬─────┬─────┬─────┬───────┐
 * │ SOF │ Arb Field│RTR│ IDE│ DLC (4b) │Data │ CRC │ ACK │  EOF  │
 * │ 1b  │  11-bit  │1b │ 1b │  4 bits  │0-8B │ 15b │ 2b  │  7b   │
 * └─────┴──────────┴───┴────┴──────────┴─────┴─────┴─────┴───────┘
 */

// STM32 CAN Transmission Example (using HAL)
CAN_TxHeaderTypeDef txHeader;
uint8_t txData[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
uint32_t txMailbox;

txHeader.StdId = 0x321;           // 11-bit identifier
txHeader.ExtId = 0;
txHeader.RTR = CAN_RTR_DATA;      // Data frame
txHeader.IDE = CAN_ID_STD;        // Standard ID
txHeader.DLC = 8;                 // 8 bytes payload
txHeader.TransmitGlobalTime = DISABLE;

if (HAL_CAN_AddTxMessage(&hcan1, &txHeader, txData, &txMailbox) != HAL_OK) {
  Error_Handler();
}

What Are the Differences Between CAN, CAN FD, and CAN XL?

Evolution of CAN standards:

  • Classic CAN (ISO 11898-1): Up to 1 Mbps, 8-byte payload, 2,048 or 536M message IDs. The established standard in all vehicles.
  • CAN FD (ISO 11898-1:2015): Up to 8 Mbps data phase, 64-byte payload, backward compatible with classic CAN transceivers. Adopted in new vehicle platforms since 2020.
  • CAN XL (CiA 610): Up to 20 Mbps, 2,048-byte payload, bridging CAN and Ethernet domains. Designed for service-oriented architectures.
  • CAN FD provides 8x the payload and 8x the data rate of classic CAN, reducing bus load significantly for ECU reprogramming and diagnostic data.
  • CAN XL adds a content-type field, enabling native tunneling of TCP/IP, PDUs, and other protocols over the CAN physical layer.

How Does CAN Handle Errors and Fault Confinement?

CAN implements five error detection mechanisms: bit monitoring (comparing sent vs received bits), bit stuffing (after 5 same-polarity bits), CRC check (15-bit polynomial), frame format check (fixed-form fields), and ACK check (at least one receiver must acknowledge). When an error is detected, the detecting node transmits an error frame (6 dominant bits) that corrupts the current message, triggering retransmission. CAN's fault confinement mechanism uses two counters—Transmit Error Counter (TEC) and Receive Error Counter (REC)—to classify nodes as Error Active (normal), Error Passive (reduced priority), or Bus Off (disconnected). This mechanism prevents a faulty node from continuously disrupting the network, which is essential for vehicle safety.

Key takeaway: CAN bus is the foundational automotive network protocol, using non-destructive bitwise arbitration to guarantee highest-priority message delivery without data loss. Classic CAN supports 1 Mbps with 8-byte payloads, CAN FD extends to 8 Mbps with 64-byte payloads, and CAN XL bridges to Ethernet with 20 Mbps and 2048-byte payloads for next-generation vehicle architectures.

How Did We Debug a Complex CAN Bus Integration Issue?

In a recent EmbedCrest automotive project, we developed a CAN FD gateway ECU bridging the powertrain CAN FD bus (5 Mbps data phase) to a legacy classic CAN body network (500 kbps) for an electric vehicle conversion company. During integration testing, we encountered intermittent CRC errors on the CAN FD bus that occurred only under high bus load (above 60%). Using a Vector CANalyzer and a Saleae Logic Pro 16 analyzer, we traced the issue to impedance mismatches caused by incorrect CAN FD stub lengths exceeding the 30mm maximum recommended for 5 Mbps operation. Two ECU connectors had 45mm stub connections to the main bus line, creating signal reflections that corrupted the CAN FD data phase but not the slower arbitration phase. After shortening the stubs and adding 100-ohm termination resistors at both bus ends, the CRC errors disappeared completely. This experience reinforced that CAN FD physical layer design requires significantly tighter tolerances than classic CAN, particularly for stub lengths, bus topology, and termination.

What Are Best Practices for CAN Bus Network Design?

Reliable CAN bus operation requires careful attention to physical layer design. Use a linear bus topology (not star or ring) with 120-ohm termination resistors at both ends of the bus line. For CAN FD at 5 Mbps, keep stub lengths under 30mm and total bus length under 40 meters (compared to 500 meters for classic CAN at 125 kbps). Use twisted-pair cabling with characteristic impedance of 120 ohms and a propagation delay under 5 ns/m. Route CAN lines away from high-current power cables to minimize electromagnetic interference. Implement bus-off recovery in firmware: when a node reaches Bus Off state (TEC exceeds 255), wait for the 128x11 bit recovery sequence, then re-initialize the CAN peripheral with exponential backoff to prevent immediate re-entry into Bus Off. Monitor error counters (TEC/REC) in your telemetry and alert when they exceed 96 (Error Passive threshold), indicating developing physical layer or protocol issues before they cause Bus Off conditions.

How Does CAN Security Fit Into Modern Vehicle Architectures?

Classic CAN has no built-in authentication or encryption, making it vulnerable to message injection, replay attacks, and ECU spoofing. Any node on the bus can send any message ID, and legitimate ECUs cannot distinguish authentic messages from injected ones. Modern vehicle security addresses this through SecOC (Secure Onboard Communication), defined in AUTOSAR, which adds a Message Authentication Code (MAC) to CAN frames. SecOC truncates CMAC-AES-128 to fit within CAN payload constraints, providing message authenticity and freshness checking using a synchronized counter. CAN FD's larger 64-byte payload simplifies SecOC integration by providing sufficient space for both data and authentication fields without requiring multi-frame protocols. For new vehicle architectures, automotive Ethernet (100BASE-T1) with MACsec or IPsec handles high-bandwidth, security-critical domains like ADAS and V2X, while secured CAN FD remains the standard for body control, powertrain, and chassis domains where deterministic latency and cost-per-node matter.

CAN BusAutomotiveEmbedded SystemsCAN FDVehicle Networks

Rajdatt

Lead Embedded Systems Engineer at EmbedCrest Technology

Delivering enterprise grade embedded systems, IoT, and Edge AI engineering solutions.

FAQ

Frequently Asked Questions

How many ECUs can be connected to a single CAN bus?

The CAN standard allows up to 32 nodes per physical bus segment with standard transceivers. Using high-drive transceivers, this can be extended to 64 or more nodes. Larger systems use multiple CAN buses connected through gateways.

Is CAN bus being replaced by Ethernet in vehicles?

Automotive Ethernet (100BASE-T1, 1000BASE-T1) is being adopted for high-bandwidth domains like ADAS and infotainment, but CAN/CAN FD remains the standard for body control, powertrain, and chassis systems due to its simplicity, reliability, and cost.

What tools are used for CAN bus analysis and debugging?

Common tools include Vector CANalyzer/CANoe (industry standard), PEAK PCAN-USB adapters, Kvaser interfaces, and open-source tools like can-utils on Linux. For development, virtual CAN (vcan) on Linux enables software testing without hardware.

Ready to Build Your Embedded Solution?

From Edge AI to industrial IoT, our engineering team delivers end to end embedded systems solutions. Let us discuss your project requirements.

Get in Touch