RDS transmission is a somewhat unreliable trasnmission format, very low deviation modulation, multipath fading etc in cars. So the protocol uses a CRC on all frames to detect possible transmission errors.
The UCED uses a specific polynominal (CCITT-16 polynomial x16 + x12 + x5 + 1) as a cyclic redundancy check (CRC).
void Calculate_CRC( byte* __rptr buffer, word first, word last, word* ccitt) { // Calculate the CCITT crc x16 + x12 + x5 + 1 word crc = 0xFFFF; // Initialise for CCITT-16 word i = 0; // Scan buffer for(i = first; i <= last; i++) { crc = (word)(((crc >> 8) & 0x00FF) | ((crc << 8) & 0xFF00)); crc ^= (word)((word)buffer[i] & 0x00FF); crc ^= (word)((crc & 0x00FF) >> 4); crc ^= (word)((((crc << 8) & 0xFF00) << 4) & 0xF000); crc ^= (word)(((crc & 0x00FF) << 4) << 1); } *ccitt = crc; return; }
This is C coding.
static public UInt16 RDS_CRC_CCITT16(Byte[] buffer, UInt16 first, UInt16 last) { // Takes the chain of bytes in buffer from first to last inclusive UInt16 i = 0; UInt16 crc = 0xFFFF; // Initialise for CCITT-16 // Scan buffer for (i = first; i <= last; i++) { crc = (UInt16)(((crc >> 8) & 0x00FF) | ((crc << 8) & 0xFF00)); crc ^= (UInt16)buffer[i]; crc ^= (UInt16)((crc & 0x00FF) >> 4); crc ^= (UInt16)((crc << 8) << 4); crc ^= (UInt16)(((crc & 0x00FF) << 4) << 1); } return crc; }
and this is C# coding.