Hello,
I have to check CRC from external device via the SCI.
The CRC is computed to SCI 8bits data with the following CRC code G(X) = X^8 + 1
Then I have the following code to compute it:
static uint8_t DV_SmartAbs_iCaclCrc(uint8_t* Data, uint8_t Size) { uint8_t j; uint8_t Carry; uint8_t Crc; Crc = 0; while (Size-- > 0) { Crc ^= *Data++; for (j = 8; j != 0; j--) { Carry = Crc & 0x80; Crc <<= 1; if (Carry != 0) { Crc ^= 0x01; /* Polynome X^8 + 1 */ } } } return (Crc & 0x00FF); }
So with this If I have the following buffer:
0x001A, 0x0020, 0x00AF, 0x000A, 0x0001, 0x0011, 0x0002, 0x0000, 0x0000, 0x0080, (Size = 10) I have the following result:
Crc = 0x0D0D which is truncated to 8 LSB so 0x0D.
This is correct for my external device.
No I would use Crc library using VCU. But the datasheet indicate it is use Polynomial 0x7. This seems not correspond with my polynomial?
To check taht, I decided to implement My Algorithm which respect the 0x07 Polynomial and check if My algorithm found the same CRC than the library.
If in my algorithm I replace my polynomial 0x01 by 0x07 (Replace Crc ^= 0x01; by Crc ^= 0x07; )
The result of Crc is 0x53B9, the result of CRC_run8bit is 0xAB and CRC_run8bitReflected is 0x29 (With Seed = 0) but not 0xB9..
So what I missed?
CRC_run8Bit