Cyclic redundancy check in CAN CC frames

CAN data frames and remote frames contain a safeguard based on a cyclic redundancy check (CRC) polynomial: The transmitter calculates a check sum from the transmitted bits and provides the result within the frame in the CRC field. The receivers use the same polynomial to calculate the check sum from the bits as seen on the bus lines. The self-calculated check sum is compared with the received one. If it matches, the frame is regarded as correctly received and the receiving node transmits a dominant state in the ACK slot bit, overwriting the recessive state of the transmitter. In case of a mismatch, the receiving node sends an error frame after the ACK delimiter.

In CAN CC, the following polynomial is used:

  • a 15-bit polynomial x15 + x14 + x10 + x8 + x7 +x4 +x3 + x0 in case of the frame with the payload of up to 8 bytes. 

The polynomial is used to construct Bose–Chaudhuri–Hocquenghem (BCH) code that belongs to a class of cyclic error-correcting codes. This BCH code with the error correction capability t = 1 is known as a Hamming code. The CRC-15-CAN is selected because it provides a Hamming distance of six. This means that five randomly distributed bit failures are detectable. The polynomial is also able to detect burst-errors up to 15 bit. However, this is only true for a fixed data length. However, the number of transmitted bits in the CAN frames varies depending on the automatically introduced stuff-bits. This leads to a cut of the Hamming distance to two for some dedicated bit patterns. Still, any single bit-error is detected, and the probability of undetected multiple bit-errors is very low.

Cyclic redundancy check in CAN FD frames — fixed stuff-bits and stuff-bit counter

To improve the error detection capability, the CAN FD protocol has introduced fixed stuff-bits in the CRC field because there are no such fixed stuff-bits in CAN CC. 

Due to the longer frames (more than 8-byte payload) higher order CRC polynomial are required so in CAN FD the following polynomials are used:

  • a 17-bit polynomial x17 + x16 + x14 + x13 + x11 + x6 + x4 + x1 + x0 in case of the frame payload of up to 16 bytes;
  • a 21-bit polynomial x21 + x20 + x13 + x11 + x7 + x4 + x3 + x0 in case of the frame payload from 16 bytes to 64 bytes. 

The chosen CRC polynomials have the same Hamming distance of six as in CAN CC to achieve the same error detectability. Additionally, in order to detect any single bit-error, an additional safeguard is necessary: the 3-bit stuff-bit count. The stuff-bit count is transmitted encoded in reflected binary code commonly known as a Gray code and additionally with the parity bit. The stuff bit count is protected by a parity bit and the following fixed stuff-bit is a second parity bit, so to speak, because the fixed stuff-bits always have the opposite value of the previous bit.

The safeguards specified for CAN FD frames reduce the probability of undetected erroneous messages significantly.

CAN FD and CAN FD light use the same CRC polynoms.

CAN FD (ISO and non-ISO)

The first version of the CAN FD protocol did not provide the stuff bit counter. It is incompatible with the CAN FD protocol standardized in ISO 11898-1. CiA recommends using the following terminology:

  • ISO CAN FD for implementations compliant to ISO 11898-1
  • Non-ISO CAN FD for predecessor implementations without stuff bit counter

Note that non-ISO CAN FD products are still on the market. CiA recommends using only ISO CAN FD products for serial product designs. Nevertheless, you can develop software and test physical layer prototypes using non-ISO CAN FD devices, because the protocol changes are user-transparent. Just a few bits more are transmitted, which are not visible at the user interface. But you should never mix ISO CAN FD and non-ISO CAN FD devices. Of course, if you only transmit CAN CC frames, it works.

Cyclic redundancy check in CAN XL frames

The CAN XL data frame uses two CRC fields:

  • a 13-bit polynomial x13 + x12 + x11 + x8 + x7 + x6 + x5 + x2 + x1 + 1 for preface CRC (PCRC) in control field;
  • a 32-bit polynomial x32 + x31 + x30 + x29 + x28 + x26 + x23 + x21 + x19+ x18+ x15+ x14+ x13+ x12+ x11+ x9+ x8+ x4+ x1+ 1 for frame CRC (FCRC) in CRC field. 

The CRCs are cascaded, which means the FCRC protects the whole frame, including the PCRC. Both CRCs are able to detect any five randomly distributed bit errors. This corresponds to a Hamming distance of 6.