Not directly.Is there a way to declare a default value using EEPROMData?
But if your data can NEVER include the value 255 ($FF), then yes.
On power up, read the value from EEPROM.
If it's 255, write the "default" value.
Then if you ever need to restore the default value, set the location to $FF and reset.
Unfortunately, some bootloaders have chosen to "erase" EEPROM values to 0 instead of the $FF done by hardware. This can be problematic.
As long as you know which way your programmer works, it's a definite possibility.
ADDED: You can also handle it the same way EE_vars does and create a location that indicates which EEPROM locations have been restored. If the value of that location is less than or equal to (<=) the address being tested, or $FF, restore the default value and only increment the counter AFTER a successful and verified WRITE.
This way 0, $FF and anything less than the address being tested indicates the location needs to be restored.
Bookmarks