(A001 == x^16 + x^15 + x^2 + 1 where x^16 is gone and LSB represents x^15).
Data bits are fed from LSB to MSB
At each iteration CRC is shifted to the right one bit
If data bit and LSB in CRC do not match, then crc ^= mask
So for data = 0x41
initial crc = 0x0000
first bit = 1
does not match crc's LSB so shift + xor
crc=0xa001
second bit = 0
does not match crc's LSB so shift + xor
crc=0xf001
third bit = 0
does not match crc's LSB so shift + xor
crc=0xd801
fourth bit = 0
does not match crc's LSB so shift + xor
crc=0xcc01
fifth bit = 0
does not match crc's LSB so shift + xor
crc=0xc601
sixth bit = 0
does not match crc's LSB so shift + xor
crc=0xc301
seventh bit = 1
shift only
crc=0x6180
eighth bit = 0
shift only
crc=0x30c0
Are you using a table-based algorithm?
ReplyDeleteNo, I am not, it is a shift register as the one shown in the picture.
ReplyDeletePlease note that as it is mentioned in this document CRC-16 requires the bit reversal of the resulting remainder.
ReplyDeleteBack of the envelope calculation
ReplyDelete