Powtran PI9100 Series Manual page 233

Table of Contents

Advertisement

Appendix I
8-bit data in each character is valid to the CRC, the start bit and stop bit, and parity
bit are invalid.
During generation of the CRC, each eight-bit character is exclusive OR(XOR)
with the register contents separately, the result moves to the direction of least
significant bit(LSB), and the most significant bit(MSB) is filled with 0. LSB will be
picked up for detection, if LSB is 1, the register will be XOR with the preset value
separately, if LSB is 0, then no XOR takes place. The whole process is repeated
eight times. After the last bit (eighth) is completed, the next eight-bit byte will be
XOR with the register's current value separately again. The final value of the register
is the CRC value that all the bytes of the message have been applied.
When the CRC is appended to the message, the low byte is appended firstly,
followed by the high byte. CRC simple functions 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++;
for(i=0;i<8;i++)
{
}
return(crc_value);
}
if(crc_value&0x0001)
{
c r c _ v a l u e = ( c r c _ v a l u e > > 1 )^0xa001;
}
else
{
crc_value=crc_value>>1;
}
}
228

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents