![](http://datasheet.mmic.net.cn/30000/M30263F3AFP_datasheet_2358719/M30263F3AFP_230.png)
15. CRC Calculation Circuit
page 213
9
2
3
f
o
7
0
2
,
5
1
.
b
e
F
0
.
2
.
v
e
R
0
2
0
-
2
0
2
0
B
9
0
J
E
R
)
T
6
2
/
C
6
1
M
,
B
6
2
/
C
6
1
M
,
A
6
2
/
C
6
1
M
(
p
u
o
r
G
A
6
2
/
C
6
1
M
15. CRC Calculation Circuit
The Cyclic Redundancy Check (CRC) operation detects an error in data blocks. The microcomputer uses
a generator polynomial of CRC_CCITT (X16 + X12 + X5 + 1) or CRC-16 (X16 + X15 + X2 + 1) to generate
CRC code.
The CRC code is a 16-bit code generated for a block of a given data length in multiples of bytes. The code
is updated in the CRC data register everytime one byte of data is transferred to a CRC input register. The
data register needs to be initialized before use. Generation of CRC code for one byte of data is completed
in two machine cycles.
Figure 15.1 shows the block diagram of the CRC circuit. Figure 15.2 shows the CRC-related registers.
Figure 15.3 shows the calculation example using the CRC_CCITT operation.
15.1. CRC Snoop
The CRC circuit includes the ability to snoop reads and writes to certain SFR addresses. This can be
used to accumulate the CRC value on a stream of data without using extra bandwidth to explicitly write
data into the CRCIN register. All SFR addresses after 002016 are subject to the CRC snoop. The CRC
snoop is useful to snoop the writes to a UART TX buffer, or the reads from a UART RX buffer.
To snoop an SFR address, the target address is written to the CRC snoop Address Register (bits 9 to
0 in the CRCSAR register). The two most significant bits in this register enable snooping on reads or
writes to the target address. If the target SFR is written to by the CPU or DMA, and the CRC snoop write
bit is set (the CRCSW bit is set to "1"), the CRC will latch the data into the CRCIN register. The new
CRC code will be set in the CRCD register.
Similarly, if the target SFR is read by the CRC or DMA, and the CRC snoop read bit is set (the CRCSR
bit is set to "1"), the CRC will latch the data from the target into the CRCIN register and calculate the
CRC.
The CRC circuit can only calculate CRC codes on data byte at a time. Therefore, if a target SFR is
accessed in a word (16 bit) bus cycle, only the byte of data going to or from the target snooped into
CRCIN, the other byte of the word access is ignored.
Figure 15.1 CRC circuit block diagram
Eight low-order bits
Eight high-order bits
Data bus high-order
Data bus low-order
CRCD register (16)
CRC input register (8)
CRC code generating circuit
x16 + x12 + x5 + 1 OR x16 + x15 + x2 + 1
Address Bus
SnoopB
lock
Snoop
enable
Snoop Address
Equal?
(Address 03BD16, 03BC16)
(Address 03BE16)