

The function that should be used depends on the polynomial size that was set with the setup_crc() function. To calculate the CRC checksum the CCS C Compiler supplies the following functions, crc_calc8(), crc_calc16 and crc_calc32(), for devices with a 32-bit CRC module only. The following getenv() statement can be used in the CCS C Compiler to determine if the device has a CRC module: There are two basic versions of the CRC module that some Microchip PIC ® MCUs have, a 16-bit module and a 32-bit module. Many new PIC ® MCUs released today include a CRC module that perform this algorithm quickly in hardware, and CCS provides a library for accessing this module. In reference to the previous example, the CRC of 0x0000 isn't 0x00. The Cyclic Redundancy Check (CRC) is a more robust method for hashing data. That means a checksum based on XOR would couldn't tell the difference between 0x0000 or 0x00. For example, the result of 0 XOR 0 is still 0. Unfortunately this method does accurately detect situations where data may have been received correctly. A common and easy method of performing a checksum is just summing or XORing all the bytes in the data. Creating a checksum of data is a great way to detect if data has be successfully received by comparing a received checksum to a mathematically determined checksum it can be determined if the data was sent and received properly. Reliably sending data between two devices usually involves a checksum. CCS C Compiler Makes It Easy To Calculate a CRC Using the PIC® MCU's CRC Module Friday 26 May, 2017
