R8C/36T-A Group
27. CRC Calculator Function
Under development Preliminary document
Specifications in this document are tentative and subject to change.
R01UH0240EJ0010 Rev.0.10
Page 666 of 728
Aug 05, 2011
27.3
Operation
The CRC calculator generates 16-bit CRC code for an arbitrary length of a data block in 8-bit units. The generator
polynomial of CRC-CCITT (X16 + X12 + X5 + 1) or CRC-16 (X16 + X15 + X2 + 1) is used to generate the CRC
code.
After setting the initial value in the CRCD register, the CRC code is stored in the CRCD register every time 1 byte
of data is written to the CRCIN register. CRC code generation for 1-byte of data is completed in two CPU clock
cycles.
27.4
CRC Snoop
The CRC calculator has a CRC snoop function which monitors reads from and writes to a certain SFR address and
performs CRC calculation automatically on the data read from and written to the SFR address. Because the CRC
snoop recognizes writes to and reads from a certain SFR address as a trigger to perform CRC calculation, there is
no need to write data to the CRCIN register. All SFR addresses from 00080h to 002FFh and 06800h to 06FFFh are
subject to the CRC snoop.
To use this function, set a target SFR address in the CRCSAR register. Set the CRCSW bit in the CRCMR register
to 1 to enable snooping on writes to the target. Similarly, set the CRCSR bit in the CRCMR register to 1 to enable
snooping on reads from the target.
When the CRCSW bit is set to 1, if data is written to a target SFR address, the CRC calculator stores the data in the
CRCIN register and performs CRC calculation.
Similarly, when the CRCSR bit is set to 1, and data is written to a target SFR address, the CRC calculator stores the
data in the CRCIN register and performs CRC calculation.
The CRC calculation is performed 1 byte at a time. When the target SFR address is accessed in words (16 bits), the
CRC code is generated on the lower byte (1 byte) of data at the SFR address set in the CRCSAR register.
27.5
Usage Method
The following shows examples of CRC calculation to generate the CRC code for 80C4h.
When CRC-CCITT is used with LSB first
(1) Reverse the bit order of 80C4h by a program.
80h → 01h, C4h → 23h
(2) Set the CRCMR register to 00h.
(3) Set the CRCD register to the initial value 0000h.
(4) Set the CRCD register to 01h, a bit-order-reversed value of 80h.
1189h, which is a bit-order-reversed value of the CRC code 9188h for 80h, is stored in the CRCD register.
(5) Set the CRCIN register to 23h, a bit-order-reversed value of C4h.
0A41h, which is a bit-order-reversed value of the CRC code 8250h for 80C4h, is stored in the CRCD register.
When CRC-16 is used with MSB first
(1) Set the CRCMR register to 03h.
(2) Set the CRCD register to the initial value 0000h.
(3) Set the CRCIN register to 80h.
The CRC code 8303h for 80h is stored in the CRCD register.
(4) Set the CRCIN register to C4h.
The CRC code 0292h for 80C4h is stored in the CRCD register.