Hello,
i'am trying to implement a CRC calculation in AI2.
But i dont get the expected result and want to ask if there is an obvious Error
here is the C-Code on the BLE Device:
for (uint8_t i = 0; i < 5 ; i++) { // CRC Check of Header (CMD, Adress, Size
crc = _crc_xmodem_update (crc, buf[i]);
}
uint16_t _crc_xmodem_update (uint16_t crc, uint8_t data) {
int i;
crc = crc ^ ((uint16_t)data << 8);
for (i = 0; i < 8; i++) {
if (crc & 0x8000)
crc = (crc << 1) ^ 0x1021;
else
crc <<= 1;
}
return crc;
}
for the following blocks the CRC should be 0x60 (MSB) and 0x96 (LSB)