unsigned long CRC = 0xFFFF; for(i=0;i<cnt;i++) { crc^=(long)data[i]; for(j=0;j<8;j++) { if(crc & 0x0001) crc = (crc >> 1) ^ 0x8408; else crc =crc >>1; } } crc = ~crc;