38.2 Overview
A Cyclic Redundancy Check (CRC) takes a data stream of bytes from the Flash (either the boot section, application code section, or application data section) and generates a checksum. The CRC peripheral (CRCSCAN) can be used to detect errors in the program memory.
The last location in the section being checked must contain a correct pre-calculated 16- or 32-bit checksum for comparison. If the checksum calculated by the CRCSCAN and the pre-calculated checksums match, a Status bit is set. If they do not match, the Status A (CRCSCAN.STATUSA) register will indicate that it failed. The CRCSCAN can be configured to generate a Non-Maskable Interrupt (NMI) if there is a checksum mismatch.
The CRC generator supports CRC-16-CCITT and CRC-32 (IEEE 802.3).
Polynomial:
- CRC-16-CCITT: x16 +
x12 + x5 + 1, initial value =
0xFFFF
- CRC-32: x32 + x26
+ x23 + x22 + x16 + x12 + x11 +
x10 + x8 + x7 + x5 + x4 +
x2 + x + 1, initial value =
0xFFFF_FFFF
The CRC reads byte-by-byte the content of the section(s) it is set up to check, starting with byte 0, and generates a new checksum for each byte. The byte is sent through a shift register, as depicted below, starting with the most significant bit. The CRC passes if the last bytes in the section contain the correct checksum. See the Checksum section for instruction on how to place the checksum.