This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADS131M04: Error in example code

Part Number: ADS131M04

The example code (http://www.ti.com/lit/zip/sbac254) for the ASS131M0x family contains an error in the CRC function which causes the function to generate incorrect CRCs.

The calculateCRC() function transposes the values for the CCITT and ANSI binary polynomials, using the CCITT value (0x1021) when the manifest constant CRC_ANSI is defined, and the ANSI value (0x8005) when the manifest constant CRC_CCITT is defined.

    #ifdef CRC_CCITT
    /* CCITT CRC polynomial = x^16 + x^12 + x^5 + 1 */
    const uint16_t poly = 0x8005;
    #endif

    #ifdef CRC_ANSI
    /* ANSI CRC polynomial = x^16 + x^15 + x^2 + 1 */
    const uint16_t poly = 0x1021;
    #endif

The ADS131M04 datasheet defines the CRC binary polynomials in Table 9 in section 8.3.13:

CCITT CRC binary polynomial: 0001 0000 0010 0001 (0x1021)

ANSI CRC binary polynomial: 1000 0000 0000 0101 (0x8005)

-Nick

  • Nick,

    Thanks for pointing that out. It looks like the polynomials for CRC-16 for CCITT and ANSI were swapped. I already recognize the CCITT polynomial as 0x1021 offhand. 

    Let me look into it and we'll see if we can get that changed soon.

    Joseph Wu