This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

CRC register values for a 24 bit CRC.

A general question about the radio CRC registers: The CRCPOLY register is 24 bits wide, which can be used to specify a 24-bit polynomial, suitable for calculation a 23 bit CRC value. But the allowed values for CRC length are 0, 1, 2 or 3 bytes. Obviously 3 bytes is 24 bits of CRC value, which would required a 25 bit polynomial value. The documentation explicitly says that bit 0 of CRCPOLY is hardwired to 1, and ignored. How can you specify a 25 bit, or is the documentation really saying that you don't need to specify bit zero, just the other 24 bits of the 25 bit polynomial required to generate a 24 bit CRC?

  • or is the documentation really saying that you don't need to specify bit zero, just the other 24 bits of the 25 bit polynomial required to generate a 24 bit CRC?

    That is correct.

    Best regards,
    Kenneth

  • Hi Kenneth,

    Thanks for the reply...

    So just to clarify, the documentation gives as an example, a polynomial of

     x8 + x7 + x3 + x2 + 1 = 1 1000 1101 = 0x18d

    0x18d shifted right by 1 = 0xc6 = 1100 0110

    Does this mean I would write 0xc5 to the CRC register?

    I have a 24-bit CRC using a (25-bit) polynomial of x25 + x4 + x3 + x2 + 1 = 0x100001b

    Should I write 0x80000d to the CRC register?

    Best regards,

    Dave

  • Hi Dave,

    Maybe it is easier to refer to BT requirement, from the core spec:

    "The CRC polynomial is a 24-bit CRC and all bits in the PDU shall be processed
    in transmitted order starting from the least significant bit. The polynomial has
    the form of x24 + x10 + x9 + x6 + x4 + x3 + x + 1."

    In such case the CRCPOLY should be set to 0x65B.

    Best regards,
    Kenneth

  • Hi Kenneth,

    Thanks for the prompt reply again. Ok, so 

    x24 + x10 + x9 + x6 + x4 + x3 + x + 1 = ‭1 0000 0000 0000 0110 0101 1011‬ = 0x10065b

    So this would imply to me that it is the most significant bit that should be ignored, whereas the documentation quite clearly states that bit 0 is ignored. I am very grateful for the information, but would respectfully suggest that the documentation is at best very least misleading! Perhaps it should explicitly state which bit is bit 0, as certainly for the ARM processor with which this functionality is paired for the nRF52832 bit 0 is the other end!

    Thank you for your comprehensive answer,

    Dave

  • Just to caveat my previous answer, I am mistaken. The documentation is of course correct, what it means is that you can only implement polynomials that include the x0 term (which is any useful polynomial, in practice). What I think is unclear is that this implies that the highest term is implied, too. That is, x24 for a 3 byte checksum, x16 for a two byte checksum, and x8 for a single byte. So if one were to implement the standard CCITT 16 bit CRC with polynomial of x16 + x12 + x5 + 1 = 1 0001 0000 0010 0001 = 0x11021, one would only need to write the value 0x1021 to the CRC register. So the bottom term of the polynomial is fixed, and the top term is implied.

    Again, many thanks for the response.

    Dave

Related