CAN Frame Format Explained: SOF, ID, DLC, CRC, ACK, EOF and Bit Stuffing

Key takeaways

  • A CAN standard frame runs SOF, ID, control bits, up to 8 data bytes, CRC, ACK and EOF.
  • A smaller message ID has higher priority, and one dominant ACK bit is enough for the sender.
  • After 5 identical bits the sender adds an opposite stuff bit, so 11 recessive bits always mean an idle bus.
Traffic light trails on a curving highway at night under the words CAN Frame & Format
Traffic light trails on a curving highway at night. Image: Techqio

The CAN frame format packs a message’s ID, up to 8 bytes of data and an error check into one fixed sequence of bits. A protocol is the set of forms and rules agreed on in advance so that messages can be exchanged smoothly, and CAN is one. The CAN standard frame, the typical CAN frame, shows that structure and those rules one field at a time.

Bar divided into the fields of a CAN standard frame in sending order: SOF (1 bit), arbitration (11-bit ID and RTR), control (IDE, r, 4-bit DLC), data (up to 8 bytes), CRC and ACK with their delimiters, and EOF (7 bits)
A bar split into six labeled CAN frame fields. Image: Techqio

SOF, the start of frame

A CAN frame always starts by changing the physical value currently on the bus. The start-of-frame (SOF) bit puts a dominant value, logical 0, on the CAN bus while no message occupies it.

The falling edge at the start of the SOF bit, from 1 to 0, is the reference for every other node on the bus. They all begin counting bit lengths from it at the same moment and read the bits that follow. This is called hard synchronization, which Kvaser’s tutorial places on the recessive-to-dominant transition of the start bit.

Bit layout of a CAN standard frame with the SOF bit at the far left marked by a falling red arrow, followed by the 11-bit ID, RTR, IDE, r, 4-bit DLC, data field, 15-bit CRC, ACK and 7-bit EOF
Standard frame layout with the SOF bit marked. Image: Techqio

Arbitration field

The message ID has several important properties in bus communication. During bus arbitration the ID acts as the priority, so the message with the higher priority takes the bus. A smaller message ID means a higher priority. TI’s CAN primer says the same of the 11-bit identifier, the lower the binary value, the higher its priority.

Receiving nodes compare the ID of a received message with their acceptance filters. That decides whether the message is passed to the application or left alone. The application then reads the ID to learn what the message contains and how its data is structured.

Bit layout of a CAN standard frame with the arbitration field, the 11-bit ID and the RTR bit, highlighted in green
Standard frame layout with the ID and RTR bits in green. Image: Techqio

Control field and data field

A data field of flexible length saves communication bandwidth. For that to work, the frame has to say in its own bits how long the data field is. The DLC is 4 bits and covers 0 to 15. In a CAN standard frame, a DLC above 8 still means a data field of 8 bytes.

The IDE bit shows whether the frame uses the standard frame format or the extended frame format, which lengthens the message ID. The r bit is a reserved bit, set aside in advance so a next-generation protocol can use it.

Two bit layouts of a CAN standard frame: the control field with IDE, r and the 4-bit DLC highlighted in blue, and the data field of 0 to 8 bytes (64 bits) highlighted in pink
Two frame layouts with the IDE, r, DLC bits and the data field shaded. Image: Techqio

CAN FD, a protocol with a longer data field than CAN, uses that r bit to tell nodes a frame is CAN FD. CiA calls it the FDF bit. A recessive value marks a CAN FD frame and a dominant one a classical frame, and the data field grows to as much as 64 bytes. Both protocols now share one standard, ISO 11898-1:2024.

Check field

CRC, the cyclic redundancy check, is a standard way to detect errors in digital communication. The transmitting node calculates a CRC and sends it inside the message. Each receiving node runs the same algorithm and judges whether the message contains bit errors.

The CRC can detect up to 5 bit errors in a frame. CiA, the CAN industry association, traces that number to the 15-bit CAN polynomial and its Hamming distance of six. I wouldn’t stretch the 5-bit figure beyond what that Hamming distance guarantees.

Bit layout of a CAN standard frame with the check field, the 15-bit CRC and its delimiter, highlighted in green
Standard frame layout with the CRC bits in green. Image: Techqio

ACK field

The transmitting node sends the ACK bit as a recessive value, logical 1. It does so expecting a receiving node to answer in that same bit with a dominant value, logical 0.

A receiver that finds the CRC correct sends a dominant 0 in the ACK bit. A receiver that finds it wrong sends a recessive 1, and it then sends an error frame after the ACK delimiter.

Only one node has to receive the message correctly. Its dominant value lands on the bus, and the transmitting node concludes that the message went out properly. I’d read an ACK only as proof that some node heard the frame, because it doesn’t say which node that was.

Bit layout of a CAN standard frame with the ACK field, the ACK bit and its delimiter, highlighted in yellow
Standard frame layout with the ACK bits in yellow. Image: Techqio

End of frame (EOF) and intermission

The EOF bits announce that the frame is over. Every node on the bus treats the bus as idle once it sees 11 recessive bits, logical 1, in a row. From then on any node may access the bus.

So even after a message ends normally, 3 more recessive bits have to appear before the next message can take the bus. The count is DEL (1 bit) + EOF (7 bits) + ITM (3 bits) = 11 bits. ITM, the intermission, stands for those 3 bits. CiA describes the 3-bit intermission field as the minimum gap between consecutive frames.

Bit layout of a complete CAN frame from SOF to the end, with the 7-bit EOF box and the 3-bit ITM intermission box after it both shaded gray
Frame layout ending in the 7-bit EOF and 3-bit ITM boxes. Image: Techqio

The whole CAN frame format in one successful reception

The blue line in the figure below traces the bits of a message received correctly in the standard CAN frame format. The ID, DLC, data and CRC change from message to message.

Color-coded CAN standard frame with a blue line tracing the bit levels of a correctly received message: low at SOF, RTR, IDE, r and ACK, high at the delimiters, EOF and ITM
Color-coded frame with a blue line tracing the bit levels. Image: Techqio

Bit stuffing

The idle rule leaves one case open. Every node treats 11 recessive bits in a row as an idle bus, and an ID or a data field could produce 11 recessive values by chance.

To prevent that, the transmitting node puts a bit of the opposite value on the bus after 5 bits of the same value. That opposite bit is the stuff bit. A receiving node discards the bit that follows 5 identical bits. CiA gives the same rule and adds that the edges created by bit stuffing keep the nodes synchronized.

Two bit waveforms that each stay low for five numbered bits: the upper one then rises on its own, the lower one has a red stuff bit of the opposite level inserted after the fifth bit
Two waveforms, the lower one with a red stuff bit after bit 5. Image: Techqio

When more than five identical bits do show up, the nodes signal a stuff error, Kvaser’s tutorial notes.

What the frame fields tell a node

Read in order, the fields of the CAN frame format answer what a receiver needs to know. SOF marks the start, and the ID decides who gets the bus and what the message is. The DLC gives the data length, and the CRC and ACK settle whether the data arrived intact.

The 11 recessive bits are the rule to remember. The end of a frame, the gap before the next one and bit stuffing all exist to keep that idle signal unmistakable. If a reader keeps one thing from the frame, I’d make it that 11-bit idle rule.

Related reading

Sources

Share this article

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *