In the CRC-16 calculation what is the difference (if any) between polynomial (x16 + x15 + x2 + x0) and (x16 + x15 + x2 + 1)?
Are the same (any number raised to zero is equal to one)?
Can someone explain me how get the hex number from this notation?
I don't understand because these polynomial seems to be 17 bits long:
0x18005 or 0b11000000000000101
No, there is no difference.
The correct way to write those is with superscripts, representing "to the power of":
x16 + x15 + x2 + x0
and:
x16 + x15 + x2 + 1
As you noted, anything raised to the zero power is one.
A 16-bit CRC uses a polynomial of degree 16. That means there must be an x16 term. You have the correct hexadecimal notation
0x18005. However in writing code to implement the CRC, you can do it with 16-bit operations and don't need the high1. In the code you will see an exclusive-or with0x8005. The high1is in fact being taken into account in the conditional that decides whether or not to exclusive-or with0x8005.Here is an example in C:
The
crc & 0x8000is checking the high bit ofcrcwhich is about to be shifted up and out, before it is shifted out, to decide whether or not to exclusive-or with0x8005after the shift. That is the same as doing it in a 32-bit register instead, doing the shift first, and if the 16th bit (0x10000) is one, then exclusive-oring with0x18005to effect the polynomial remainder operation. So that innermost line of code could have been, with auint32_t crc: