CRC16 Qestions | Cypress Semiconductor
How to use CRC16 module to calculate an data array's CRC result ?
In order to use TX8 module to send out the "data+crc" by H/W CRC.
code from cypress web --- S/W CRC16
unsigned short ComputeCrc(unsigned char *Buffer, unsigned char Length, unsigned char Seed)
unsigned char Data;
unsigned char Count = 0;
// Load the CRC with an initial value.
unsigned short Crc = (unsigned char)Seed;
// loop through all bytes in the buffer
while (Count < Length)
Data = Buffer[Count];
// Update the CRC for transmitted and received data using
// the CCITT 16-bit CRC algorithm (X^16 + X^12 + X^5 + 1).
// The next 5 lines take 143 bytes
Crc = (unsigned char)(Crc >> 8) | (Crc << 8);
Crc ^= Data;
Crc ^= (unsigned char)(Crc & 0xff) >> 4;
Crc ^= (Crc << 8) << 4;
Crc ^= ((Crc & 0xff) << 4) << 1;
if use Polynomial as (X^16 + X^15 + X^2 + 1) , how to change the code?