sinee — 12.3.6CRC Parity

EM500 Open-Loop Vector Control Inverter User Manual 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); } The contents above illustrate CRC parity theory. It takes a long time for execution with this method, especially when the parity data is long. Therefore, use the following two loop-up table methods for 16-bit and 8-bit controllers  CRC16 look-up table for 8-bit processor:

the finally returned result of this program is with high byte in the front, so please reverse it while 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, 399