Hi,
I've been testing the CRC library with the following setup:
CRC.seedValue = INIT_CRC8;
CRC.nMsgBytes = 4;
CRC.parity = CRC_parity_even;
CRC.crcResult = 0;
CRC.pMsgBuffer = (uint16_t *)buffer;
CRC.pCrcTable = (uint16_t *)&crc8Table[0];
CRC.init = (void (*)(void *))CRC_init8Bit;
CRC.run = (void (*)(void *))CRC_run8Bit; // Using VCU
// Initialize the handle
handleCRC = &CRC;
// Run the 8-bit table look-up CRC routine and save the result
CRC.init(handleCRC);
CRC.run(handleCRC);
crcResultC = CRC.crcResult;
Expected result: 0xC9
Actual result: 0x8D
I understand that with CRC_parity_even, CRC starts at the low byte of the first word. This means the actual input data is in this order: 0xFF, 0x00, 0xCD, 0xAB. With that, the result of 0x8D is explainable.
So I thought I could fix it by changing the parity to CRC_parity_odd.
However, the result is: 0x1B
I have tried another way, which is still using CRC_parity_even, but I needed to swap the bytes in each word before feeding into the CRC calculation. The result then becomes 0xC9 as expected. But I believe it's not ideal.
Could you let me know what is the issue with my code?
Thanks
Anthony