0

I have seem the CRC calculation polynomial for CAN 2.0B, but I have no examples to actually make sure I understood how to calculate it.

X15 + X14 + X10 + X8 + X7 + X4 + X3 + 1

I would really appreciate seeing a step by step calculation for such a CRC.

artless noise
  • 21,212
  • 6
  • 68
  • 105

1 Answers1

0

The CAN 2.0 document says exactly how to do it:

CRC_RG = 0 //initialize shift register
REPEAT
    CRCNXT = NXTBIT EXOR CRC_RG(14)
    CRC_RG(14:1) = CRC_RG(13:0) //shift left by...
    CRC_RG(0) = 0 //...one position
    IF CRCNXT THEN
        CRC_RG(14:0) = CRC_RG(14:0) EXOR (4599 hex)
    ENDIF
UNTIL (CRC SEQUENCE starts or there is an ERROR condition)

Note that 4599 in hex is the polynomial, i.e. the bits 14, 10, 8, 7, 4, 3, and 0 are set. (The 15 bit position is what is pulled off after the shift.)

You can find an example here to verify that you're doing it right. This CRC applied to the ASCII string of digits (nine bytes) 123456789 is 0x059e.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
  • Could you show me a practical example so I can manually calculate it? –  Aug 06 '15 at 21:17