
CHAPTER 21 CRC FUNCTION
User’s Manual U17790EJ2V0UD
905
Communication errors can easily be detected if the CRC code is transmitted/received along with transmit/receive
data when transmitting/receiving data consisting of several bytes.
The following is an illustration using the transmission of 12345678H (0001 0010 0011 0100 0101 0110 0111
1000B) LSB-first as an example.
Figure 21-4. CRC Transmission Example
78
Transmit/receive data
(12345678H)
CRC code
(08F6H)
56
34
12
F6
08
Setting procedure on transmitting side
<1>
Write the initial value 0000H to the CRCD register.
<2>
Write the 1 byte of data to be transmitted first to the transmit buffer register. (At this time, also write the
same data to the CRCIN register.)
<3>
When transmitting several bytes of data, write the same data to the CRCIN register each time transmit
data is written to the transmit buffer register.
<4>
After all the data has been transmitted, write the contents of the CRCD register (CRC code) to the
transmit buffer register and transmit them. (Since this is LSB first, transmit the data starting from the lower
bytes, then the higher bytes.)
Setting procedure on receiving side
<1>
Write the initial value 0000H to the CRCD register.
<2>
When reception of the first 1 byte of data is complete, write that receive data to the CRCIN register.
<3>
If receiving several bytes of data, write the receive data to the CRCIN register upon every reception
completion. (In the case of normal reception, when all the receive data has been written to the CRCIN
register, the contents of the CRCD register on the receiving side and the contents of the CRCD register on
the transmitting side are the same.)
<4>
Next, the CRC code is transmitted from the transmitting side, so write this data to the CRCIN register
similarly to receive data.
<5>
When reception of all the data, including the CRC code, has been completed, reception was normal if the
contents of the CRCD register are 0000H. If the contents of the CRCD register are other than 0000H, this
indicates a communication error, so transmit a resend request to the transmitting side.