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.

CRC-16-CCITT on Tiva C

Other Parts Discussed in Thread: TM4C129DNCPDT

Hi, I am Using TM4C129DNCPDT

I want to calculate the CRC-16-CCITT (initial value all 0, polynomial: 0x8408, reversed) of an array of 8 bytes of data.

The resulting sum should be 2 bytes.

Can I use the hardware CCM0 module to do this?

Which of the following flags should i enable when i do  CRCConfigSet(CCM0_BASE, ...)

Initialize with seed: CRC_CFG_INIT_SEED
Initialize to all '0s': CRC_CFG_INIT_0
Initialize to all '1s': CRC_CFG_INIT_1
Input Data Size: CRC_CFG_SIZE_8BIT
Input Data Size: CRC_CFG_SIZE_32BIT
Result Inverse Enable: CRC_CFG_RESINV
Output Reverse Enable: CRC_CFG_OBR
Bit reverse enable: CRC_CFG_IBR
Swap byte in half-word: CRC_CFG_ENDIAN_SBHW
Swap half-word: CRC_CFG_ENDIAN_SHW
Polynomial 0x8005: CRC_CFG_TYPE_P8005
Polynomial 0x1021: CRC_CFG_TYPE_P1021
Polynomial 0x4C11DB7: CRC_CFG_TYPE_P4C11DB7
Polynomial 0x1EDC6F41: CRC_CFG_TYPE_P1EDC6F41
TCP checksum: CRC_CFG_TYPE_TCPCHKSUM

 

Anurag

  • To answer my own question:

    1) Setting:

    CRCConfigSet(CCM0_BASE, CRC_CFG_INIT_0 | CRC_CFG_TYPE_P1021 | CRC_CFG_SIZE_8BIT | CRC_CFG_IBR | CRC_CFG_OBR);

    2) Pass true as the last argument to CRCDataProcess()

    3) The LSB and MSB of value returned by CRCDataProcess() must be swapped to get the CRC-16-CCITT

  • Thanks for discovering this! I was going crazy trying to figure out why the TI CRC module was not generating the same results as the CRC routines I have been using for ages. Finally got things working after reading your post.
  • Should be added to the "What's Unclear" thread?

    Robert
  • For what it's worth, what you are expecting is called de CRC-CCITT (Xmode), and what this peripheral is giving you is called the CRC-CCITT (Kermit) output.
    You can check both results here:
    www.lammertbies.nl/.../crc-calculation.html

    It would be faster to just use:

    CRCConfigSet(CCM0_BASE, CRC_CFG_INIT_0 | CRC_CFG_TYPE_P1021 | CRC_CFG_SIZE_8BIT);

     

  • Once again this thread has saved me a bunch of time! I was trying to configure the CRC module to match the calculation method used by the IAR tools, and thanks to the CRC calculator website mentioned above, plus PAk's last post, I was able to get it working pretty quickly.

    FWIW, IAR uses the CCITT Xmodem variation.

  • Dave Hohl said:

    Once again this thread has saved me a bunch of time! I was trying to configure the CRC module to match the calculation method used by the IAR tools, and thanks to the CRC calculator website mentioned above, plus PAk's last post, I was able to get it working pretty quickly.

    FWIW, IAR uses the CCITT Xmodem variation.

    So glad you found it useful.