User Manual of A90 Series Inverter
289
while(Length--)
{
crc_value ^= *Data++;
for(i=0;i<8;i++)
{
if(crc_value & 0x0001)
{
crc_value = (crc_value>>1)^ 0xa001;
}
else
{
crc_value = crc_value>>1;
}
}
}
return(crc_value);
}
This only describes the theory of CRC check and requires a long execution time.
Especially when the check data is long, the calculation time will be too long. Thus, the
following two table lookup methods are applied for 16-bit and 8-bit controllers,
respectively.
CRC16 lookup table for the 8-bit processor: (The high byte in the final result of this
program is in front. Please reverse it during sending.)
const Uint8 crc_l_tab[256] = {
0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,
0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,
0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,
0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,
0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,
0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,
0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,