User Manual
EM303B General Purpose Inverter
180
2006H.
Name
Address
Description
Control
Command
40xx/70xx
Refers to 12.6 description of control command
Working
Status
41xx
Refers to 12.6 description of control command
13.5.4
CRC Parity
Sending equipment calculates CRC parity value first, and then attaches it to the sending
message. Upon receipt of the message, receiving equipment will calculate CRC parity value
again, and compare the operation result with received CRC parity value. If the two values
are different, it indicates that there is error during transmission.
Calculation process of CRC parity:
1.
Define a CRC parity register, and initialize it as FFFFH.
2.
Conduct XOR calculation between the 1
st
byte of sending message and the value of
CRC parity register, and then upload the result to CRC parity register. Start from
address code, the start bit and stop bit will not be calculated.
3.
Collect and check LSB (the least significant bit of CRC parity register).
4.
If LSB is 1, shift each bit of CRC parity register rightwards by 1 bit, the highest bit
filled with 0. Conduct XOR calculation between the value of CRC register and A001H,
and then upload the result to CRC parity register.
5.
If LSB is 0, shift each bit of CRC parity register rightwards by 1 bit, the highest bit
filled with 0.
6.
Repeat steps 3, 4 and 5 until completing 8 rounds of shifting.
7.
Repeat steps 2, 3, 4, 5 and 6, and process the next byte of sending message. Repeat
above process continuously until each byte of sending message is processed.
8.
CRC parity date will be saved in CRC parity register after calculation.
9.
LUT (Look-up table) method is to obtain CRC parity in the system with limited time
resources.
Simple CRC functions as shown in following (C language Programming):
unsigned int CRC_Cal_Value(unsigned char *Data, unsigned char Length)
{
unsigned int crc_value = 0xFFFF;
int i = 0;
while(Length--)
{
crc_value ^= *Data++;
for(i=0;i<8;i++)
{
if(crc_value & 0x0001)
{
crc_value = (crc_value>>1)^ 0xa001;