I wanted to check redundancy in eeprom and crosscheck the data for any errors occurred or not and I ended up reading CRC code. I found it useful but have some doubts that need clarity.
My objective is to check the memory address locations 0-15k of eeprom and store the checksum in memory and do the same for next 15k-30k address locations. The Both address locations store the same data and it is done so that eeprom memory is utilized.
Well When I began reading the docs. I ended up with a useful code:
unsigned int crc32(unsigned char *message) {
int i, j;
unsigned int byte, crc;
i = 0;
crc = 0xFFFFFFFF;
while (message[i] != 0) {
byte = message[i]; // Get next byte.
byte = reverse(byte); // 32-bit reversal.
for (j = 0; j <= 7; j++) { // Do eight times.
if ((int)(crc ^ byte) < 0)
crc = (crc << 1) ^ 0x04C11DB7;
else crc = crc << 1;
byte = byte << 1; // Ready next msg bit.
}
i = i + 1;
}
return reverse(~crc);
}
Here as far as my understanding the 'message' awaits bytes and continues CRC calculation until the character is not received. If I wanted to check the two blocks of eeprom memory as said before. How can I append the eeprom memory to the message variable.
Well my another *doubt is whether eeprom read have any limit regarding reading reading address from 0-15k at a stretch rather like eeprom write * I need your inputs to make this attempt useful and rewarding Regards
message
. But you want the CRC of (almost) your entire EEPROM, so just replace thewhile
clause with a loop over (most of) your EEPROM address space, andmessage[i]
with a read of the i-th 32-bit word of your EEPROM. Unlike writing, reading it will not degrade it. Remember to exclude the part of the EEPROM where you store the CRC checksum for comparison. \$\endgroup\$