Microchip logo
  • All
  • Products
  • Documents
  • Applications Notes

8-Bit MCUs

Cyclic Redundancy Check (CRC/SCAN)

What Is CRC?

Whether you are trying to obtain regulatory compliance or to simply design a robust and reliable product, functional safety is an absolute necessity. Several methods can be used to ensure the functional safety of end products. One of them, Cyclic Redundancy Check (CRC), is a powerful technique commonly used to check integrity in digital data. CRC generates an initial checksum of the data in memory that can be later compared with the calculated checksum for mismatch. A checksum mismatch can indicate an otherwise undetectable memory fault.

Why Is CRC Used?

CRC is a vital element of functional safety, and it is one of the key methods required to meet IEC or UL safety standards such as Class B (IEC 60730). Implementation of functional safety techniques is required by law for almost all consumer appliances and industrial electronics.

How Does CRC Work in PIC® and AVR® Microcontrollers

Many modern PIC and AVR microcontrollers (MCUs) have a built-in hardware module for CRC. This allows faster and lower-power CRC calculation without extra memory usage or additional CPU cycles when compared with a software implementation. This hardware module supports up to 32-bit polynomials and is implemented with a Linear Feedback Shift Register (LFSR) to generate a checksum of the data. PIC devices can directly feed data into the CRC module, which is useful for calculating the checksum of an outgoing datastream or for verifying an incoming datastream for transmission errors.

If the device is equipped with the SCAN feature, then the CRC module can directly read the memory on the device. This allows you to automatically validate specific regions of memory, such as boot or application, for system integrity. A more advanced version of the SCAN feature (available on select devices) is CRC On-Boot. This feature can be used to scan and verify areas, such as the boot, application, or data EEPROM with a preprogrammed checksum prior to the device running code.

Check microcontroller data alteration with CRC/Scan