Microchip® Advanced Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRC Tests

This CRC module can be used to check the Flash and EEPROM memories.

Introduction to CRC

A cyclic redundancy check (CRC) is an error detection technique test algorithm used to detect errors in data. It is commonly used to determine the correctness of data stored in memory or data that is received through some communication channel. The CRC algorithm takes a data stream or a block of data as input and generates a 16- or 32-bit output that can be used as a checksum. We suggest two possible methods to detect errors using this checksum:

-Compute checksum of the data section and compare with the previous one. If they are different, there is an error.

-Compute checksum of the extended data section (data section and original checksum). The resulting checksum should be a fixed implementation-specific value, otherwise there is an error.

If there were errors in the data, the application should take corrective actions, e.g., requesting the data to be sent again or simply not using the incorrect data.

The CRC Tests module implements 16-bit CCITT CRC and IEE802.3 32-bit CRC algorithms in software and hardware:

Usage

There are a number of symbols in Configuration settings that can be defined or undefined in order to choose between software and hardware implementations, and 16-bit and 32-bit CRC. The software implementation can be further configured in the corresponding header file.

To calculate an EEPROM checksum, use the functions

To calculate a Flash checksum, use the functions

If there are any errors, the error handler CLASSB_ERROR_HANDLER_CRC() is called.

Note
Interrupts must be disabled during this test.

Execution speed

We provide an estimate for the execution speed of different CRC implementations. Note that this is based on empirical results.

Modules

 CRC software implementation
 CRC computations implemented in software.
 
 CRC hardware implementation
 Low-level driver implementation for the AVR XMEGA AU CRC module.
 
 Configuration settings
 Symbols that can be defined to configure the CRC computation.
 
 Constants for internal use
 Symbols for ensuring standard compliant CRC.
 
 Type definitions for CRC functions
 Data types used in connection with CRC computations.