Yes, an EEPROM is a type of nonvolatile memory which can hold data even without any power for a significant amount of time (the actual time depends on temperature and other conditions).
There are a few other non volatile solutions for you to consider:
1) Internal Flash memory - Most microcontrollers nowdays have Flash for code storage and some provide it for user data and logging as well. This also has limited write cycles and requires block erase before changing bits from '1' to '0' (you store data elsewhere in the meantime and then rewrite it).
2) Internal FRAM memory - TI has devices with FRAM memory which is nonvolatile, can be accessed very simply (like any other memory location. Reads are also destructive as writes (though in your case this might not matter since the number of cycles is 10^13 or so at 85 degrees celsius).
3) External Flash memory - You can add memory externally to hold a few megabits of data rather inexpensively.
Depending on the rate at which you want to save (and whether you can shutdown nicely) you might be able to increase the effective number of cycles available for you.
While the suggested approach from PeterJ is fine, its cleaner to decouple the "data layer" logic (EEPROM access) from the CRC routine.
This CRC-32 can be universally used, its not bound to program specific behavior:
// CCITT CRC-32 (Autodin II) polynomial
uint32_t CalcCRC32(uint32_t crc, uint8_t *buffer, uint16_t length) {
while(length--) {
crc = crc ^ *buffer++;
for (uint8_t j=0; j < 8; j++) {
if (crc & 1)
crc = (crc >> 1) ^ 0xEDB88320;
else
crc = crc >> 1;
}
}
return crc;
}
Then you just feed blocks of data to the CRC function like you see fit and as required by your application.
This usage example is just written down. It uses the fictional function eeprom_read() which reads a block of data from EEPROM. We start at EEPROM address 0.
const uint8_t BLOCKLENGTH = 128;
uint32_t crc32;
uint8_t buffer[BLOCKLENGTH]; // temporary data buffer
crc32 = 0xFFFFFFFF; // initial CRC value
for (uint16_t i=0; i < NUMBEROFBLOCKS; i++) {
eeprom_read(BLOCKLENGTH * i, buffer, BLOCKLENGTH); // read block number i from EEPROM into buffer
crc32 = CalcCRC32(crc32, buffer, BLOCKLENGTH); // update CRC
}
// crc32 is your final CRC here
Note that NUMBEROFBLOCKS is just a placeholder. I hope you get the idea.
Best Answer
Microchip provides ready made encryption library. Typically AES is the most commonly used and available, and I see no reason to use anything else.
Due to export restrictions, you will need to contact them directly to obtain the source code.