I am using built in CRC PE component to calculate CRC32 of an array which is coming fine but how do I do it for structure ?
char buffer = "abcdefghij";
CRC1_GetBlockCRC(crc1, buffer, sizeof(buffer)-1, &crc_val); // This syntax gives the actual CRC value which I compared with the online CRC calculator
Why do we have to subtract 1 from sizeof ??
Secondly , I want to calculate the CRC as following.
TEST.name = 0x41424344;
TEST.weight = 59.23;
TEST.marks = 530;
TEST.average = 46.58;
TEST.value = 120;
CRC1_GetBlockCRC(crc1, &TEST, sizeof(TEST)-5, &TEST.crc);// Get 32 bit CRC last 4 bytes of struct is CRC so excluding that. I have tested for ARRAY
FAT1_write(&fp1, &TEST, sizeof(TEST), &bw);
The above code is just for illustration. The CRC calculated by this is incorrect. My Query is how do we do operations on structure as we do for any strings or array ? Kindly help