| Xmega IEC60730 Class B Library 1.0 |

All Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Submodules
CRC Tests

## Detailed Description

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.

- CRC software implementation
- CRC hardware implementation

# Usage

There are a number of symbols in Configuration of CRC Implementation 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

- `CLASSB_CRC`[16/32]_EEPROM_[SW/HW]

To calculate a Flash checksum, use the functions

- `CLASSB_CRC`[16/32]_Flash_[SW/HW].

If there should be any error, the error handler CLASSB_ERROR_HANDLER_CRC() would be 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.

- EEPROM
  - CRC32 lookup table is ~45% slower than HW.
  - CRC32 direct calculation is ~750% slower than HW.
  - CRC16 lookup table is ~20% slower than HW.
  - CRC16 direct calculation is ~430% slower than HW.
- Flash
  - CRC32 lookup table is ~4600% slower than HW.
  - CRC32 direct calculation is ~15800% slower than HW.
  - CRC16 lookup table is ~3% slower than HW.
  - CRC16 direct calculation is ~275% slower than HW.

## Submodules
| Configuration of CRC Implementation
| Symbols that can be defined to configure the CRC computation.
| Type definitions for CRC functions
| Data types used in connection with CRC computations.
| CRC hardware implementation
| Low-level driver implementation for the AVR XMEGA AU CRC module.
| CRC software implementation
| CRC computations implemented in software.