EasyManua.ls Logo

Inovance MD290T45G/55P - Page 221

Inovance MD290T45G/55P
350 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
7. Interfaces and Communication
- 220 -
7
Ƶ
CRC Check
,Q0RGEXV578PRGHDPHVVDJHLQFOXGHVD&5&EDVHGHUURUFKHFN¿HOG7KH&5&¿HOG
FKHFNVFRQWHQWRIHQWLUHPHVVDJH7KH&5&¿HOGLVWZRE\WHVFRQWDLQLQJDELWELQDU\
YDOXH7KH&5&¿HOGLVFDOFXODWHGE\WUDQVPLWWLQJGHYLFHDQGWKHQDGGHGWRPHVVDJH
The receiving device recalculates a CRC value after receiving message, and compares
WKHFDOFXODWHGYDOXHZLWKWKH&5&YDOXHLQWKHUHFHLYHG&5&¿HOG
7KH&5&LV¿UVWVWRUHGWR[))))7KHQDSURFHGXUHLVLQYRNHGWRSURFHVVWKHVXFFHVVLYH
8-bit byte in the message and the value in the register. Only the eight bits in each
character are used for the CRC. The start bit, stop bit and the parity bit do not apply to the
CRC.
During generation of the CRC, each eight-bit character is in exclusive-OR (XOR) with the
FRQWHQWLQWKHUHJLVWHU7KHQWKHUHVXOWLVVKLIWHGLQWKHGLUHFWLRQRIWKHOHDVWVLJQL¿FDQWELW
/6%ZLWKD]HUR¿OOHGLQWRWKHPRVWVLJQL¿FDQWELW06%SRVLWLRQ7KH/6%LVH[WUDFWHG
and examined. If the LSB was a 1, the register then performs XOR with a preset value.
If the LSB was a 0, no XOR is performed. This process is repeated until eight shifts have
been performed. After the last (eighth) shift, the next eight-bit byte is in XOR with the
register's current value, and the process repeats for eight more shifts as described above.
7KH¿QDOYDOXHRIWKHUHJLVWHUDIWHUDOOWKHE\WHVRIWKHPHVVDJHKDYHEHHQDSSOLHGLVWKH
CRC value.
The CRC is added to the message from the low-order byte followed by the high-order
byte. The CRC simple function is as follows:
unsigned int crc_chk_value
unsigned char *data_value,unsigned char length
{
unsigned int crc_value=0xFFFF;
int i;
while
length--
..
{
crc_value^=*data_value++;
IRUL LL
{
.. LIFUFBYDOXH[
{
.. FUFBYDOXH FUFBYDOXH!!A[D
.. }
.. else
{
.. crc_value=crc_value>>1;
}
.}
}
UHWXUQFUFBYDOXH
}

Table of Contents

Related product manuals