EEPROM factory values?

Hi

Does the EEPROM have factory default values?

The reason I ask is that I've created a sketch where the user must go through a setup procedure. Those values are then stored in the EEPROM (using something like this Arduino Playground - EEPROMLoadAndSaveSettings). On each restart of the sketch the settings are loaded back in to a settings object.

The issue I have encountered is that when the user interacts with the program for the very first time it needs to know whether the settings have been stored (otherwise the settings object will be loaded with garbage).

One idea is to use the first EEPROM byte to store a value which will let the sketch know whether settings have been stored (if so, the settings will be loaded; if not the user must go through the setup procedure). After the setup procedure, this EEPROM byte would be changed.

However, this will only work if the factory default EEPROM values are guaranteed to be a certain value. Is this the case?

Thanks

An EEPROM will always read as all ones if it hasn't been programmed or has been erased. i.e. each byte will read as 0xFF = 255 (decimal).

Pete

Calculate the crc over your data in the eeprom and compare it with a crc stored in e.g the last four bytes. If they don't match, the settings are corrupt / not valid.

Once the user has entered the data and it's saved in the eeprom, calculate the crc and store it in the last four bytes.

There is a crc example in the eeprom examples.

You can also use the CRC functions built into AVR-GCC:
http://www.nongnu.org/avr-libc/user-manual/group__util__crc.html#ga95371c87f25b0a2497d9cba13190847f