15.3.2 Using the CRC on a Data Stream
The CRC module may be used to perform CRC calculations on any data set available to the firmware. To perform a CRC on an arbitra-
ry data sream:
1. Select the initial result value using CRCVAL.
2. Set the result to its initial value (write 1 to CRCINIT).
3. Write the data to CRC0IN one byte at a time. The CRC result registers are automatically updated after each byte is written.
4. Write the CRCPNT bit to 0 to target the low byte of the result.
5. Read CRC0DAT multiple times to access each byte of the CRC result. CRCPNT will automatically point to the next value after
each read.
15.3.3 Using the CRC to Check Code Memory
The CRC module may be configured to automatically perform a CRC on one or more blocks of code memory. To perform a CRC on
code contents:
1. Select the initial result value using CRCVAL.
2. Set the result to its initial value (write 1 to CRCINIT).
3. Write the high byte of the starting address to the CRCST bit field.
4. Set the AUTOEN bit to 1.
5. Write the number of byte blocks to perform in the CRC calculation to CRCCNT.
6. Write any value to CRC0CN0 (or OR its contents with 0x00) to initiate the CRC calculation. The CPU will not execute code any
additional code until the CRC operation completes.
Note:
Upon initiation of an automatic CRC calculation, the three cycles following a write to CRC0CN0 that initiate a CRC operation
must only contain instructions which execute in the same number of cycles as the number of bytes in the instruction. An example of
such an instruction is a 3-byte MOV that targets the CRC0FLIP register. When programming in C, the dummy value written to
CRC0FLIP should be a non-zero value to prevent the compiler from generating a 2-byte MOV instruction.
7. Clear the AUTOEN.
8. Write the CRCPNT bit to 0 to target the low byte of the result.
9. Read CRC0DAT multiple times to access each byte of the CRC result. CRCPNT will automatically point to the next value after
each read.
15.3.4 Bit Reversal
CRC0 includes hardware to reverse the bit order of each bit in a byte. Writing a byte to CRC0FLIP initiates the bit reversal operation,
and the result may be read back from CRC0FLIP on the next instruction. For example, if 0xC0 is written to CRC0FLIP, the data read
back is 0x03. Bit reversal can be used to change the order of information passing through the CRC engine and is also used in algo-
rithms such as FFT.
EFM8UB3 Reference Manual
Cyclic Redundancy Check (CRC0)
silabs.com
| Building a more connected world.
Rev. 0.2 | 184