EEPROM wear levelling

Because you'll need to erase a non-value marker before you can write a value to that location. That will require an additional erase. If you use the "erased" value of 0xFFFF as your non-value marker, you can write without erasing the non-value marker first.

Here's what I would do to Keep It Stupid Simple:

  1. To read a value, look for a value that is not 0xFFFF. That's your value.
  2. To write a new value, write the value to the next EEPROM location (wrapping around to location 0 as needed) and erase the old location (set it to 0xFFFF).

(Adjust the value when reading and writing so that it's not equal to 0xFFFF in EEPROM.)