User Manual of EM760 High-Performance Inverter (8) After the calculation, the content of the CRC register is the value of CRC check. (9) In a system with limited time resources, it is recommended to perform CRC check by the table lookup method. The simple function of CRC is as follows (programmed in C language): 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 { 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 ofthis 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, 268