Fujitsu FR81S Manual Do Utilizador

Página de 2342
CHAPTER 38: CRC 
 
 
5. Operation 
 
FUJITSU SEMICONDUCTOR LIMITED 
CHAPTER
 : CRC 
FUJITSU SEMICONDUCTOR CONFIDENTIAL 
20 
5.6.2.   Example 2 CRC16, Mixture of Different Input Bit 
Widths 
Example 2 CRC16 and Mixture of Different Input Bit Widths are shown below. 
Figure 5-3 Example 2 
 
 
When the byte and bit orders are set correctly and the orders to input bits to the CRC calculator are the 
same, any writing width can be used. 
 
For example, there is a case that words are written basically and bytes or a half word is written if there is 
a fraction of 1, 2, or 3 bytes at the end. 
//************************************** 
// CRC16 (CRC ITU-T) 
//  polynomial:    0x1021 
// initial value: 0xFFFF 
//  CRCCR.CRC32    0  //  CRC16 
// CRCCR.LTLEND:  0 // big endian 
// CRCCR.LSBFST:  0 // MSB First 
// CRCCR.CRCLTE:  0 // CRC big endian 
// CRCCR.CRCLSF:  0 // CRC MSB First 
// CRCCR.FXOR:    0 // CRC Final XOR off 
//************************************** 
 
// 
//  Example 2-1 (Mixture of writing size) 
// 
 
// Initialization 
B_WRITE (CRCCR, 0x01); 
 
// data write "123456789" 
W_WRITE (CRCIN, 0x31323334); 
H_WRITE (CRCIN, 0x3556); 
H_WRITE (CRCIN+2, 0x3738); 
B_WRITE (CRCIN+3, 0x39); 
 
// read result 
H_READ (CRCR+2, data); 
 
// check result 
assert (data == 0x29B1); 
 
// 
// Example 2-2 (CRC check) 
// 
 
// Initialization 
B_WRITE (CRCCR, 0x01); 
 
// data write "123456789" + CRC 
W_WRITE (CRCIN, 0x31313334); 
W_WRITE (CRCIN, 0x35363738); 
H_WRITE (CRCIN, 0x3929); // <-- CRC(0x29) 
B_WRITE (CRCIN, 0xB1); 
// <-- CRC(0xB1) 
 
// read result 
H_READ (CRCR+2, data); 
 
// check result 
assert (data == 0x0000); 
3
9
3
7
3
8
3
5
3
6
(The following is assumed)
B_WRITE -- Byte writing
H_WRITE -- Half-word writing
W_WRITE -- Word writing
B_READ -- Byte reading
H_READ -- Half-word reading
W_READ -- Word reading
CRCCR
-- Control register address
CRCINIT -- Initial value register address
CRCIN
-- Input data register address
CRCR
-- Current CRC register address
3
1
Image of input order into CRC calculator
MSB
LSB
3
2
3
3
3
4
MB91520 Series
MN705-00010-1v0-E
1289