
The stuffed bit
After five equal bits the sender adds one of the opposite value, so the rail always has edges to keep the devices in step. The receiver takes the extra bits out again.
No clock wire, so edges are the clock
CAN has no clock line. Each device runs its own oscillator and corrects it against the edges it sees on the pair, which are the changes between dominant and recessive. A message with a long run of equal bits has no edges for the length of that run, and the clocks drift while they wait.
The rule
The sender watches its own bits. After five equal bits in a row it adds one bit of the opposite value, whatever the message says next. The added bit is the stuffed bit, and it counts as the first bit of the next run, so a stuffed bit can itself begin a run that is stuffed again. A receiver knows the rule, drops the bit that follows five equal bits, and has the original message back. The stuffed bit carries no data; it is only an edge.
Where it applies
Stuffing covers the message from the start of frame to the end of the check sequence: the identifier, the control bits, the data and the check. It stops there. The delimiter that closes the check, the acknowledge slot and the end of frame are fixed patterns and are not stuffed.
Six in a row is an error
Inside the stuffed part, six equal bits cannot occur in a good message. A receiver that sees them has found a stuff error, and the frame is thrown away. The active error flag from lesson nine is built to break the rule on purpose, so every device notices it at once.
What it costs
Stuffing makes a message longer by an amount that depends on its contents. A standard message with eight bytes of data is 108 bits without stuffing. In the worst case, the stuffed part gains one bit for every four after the first five, which adds up to 24 bits, so 132. Most messages gain far fewer, but a bus has to be planned for the long ones.
Common mistakes
- Counting the stuffed bits as data. They carry nothing. The receiver removes them before it reads anything, and the check is calculated without them.
- Thinking the whole frame is stuffed. Stuffing stops at the end of the check sequence; the acknowledge slot and the end of frame are not stuffed.
- Using the 108-bit figure for timing. That is the length without stuffing. Budget the bus with the stuffed length, up to 132 bits for eight bytes of data.
Edit this page — content/fundamentals/can/the-stuffed-bit.mdx
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.