Search code examples
embeddedspicrc

How is this crc calculated correctly?


I'm looking for help. The chip I'm using via SPI (MAX22190) specifies:

CRC polynom: x5 + x4 + x2 + x0

CRC is calculated using the first 19 data bits padded with the 5-bit initial word 00111.

The 5-bit CRC result is then appended to the original data bits to create the 24-bit SPI data frame.

The CRC result I calculated with multiple tools is: 0x18

However, the chip shows an CRC error on this. It expects: 0x0F

Can anybody tell me where my calculations are going wrong?

My input data (19 data bits) is:

19-bit data:

0x04 0x00 0x00

0000 0100 0000 0000 000

24-bit, padded with init value:

0x38 0x20 0x00

0011 1000 0010 0000 0000 0000

=> Data sent by me: 0x38 0x20 0x18

=> Data expected by chip: 0x38 0x20 0x0F


Solution

  • The CRC algorithm is explained here. I think your error comes from 00111 padding that must be padded on the right side instead on the left.