Prolonging and Estimating EEPROM Life

Here are some ideas on prolonging the life of your EEPROM (this text assumes your familiarity with the stor. object*):

  • Limit the number of updates you make to the EEPROM's data. For example, if you are counting events, then do not write to the EEPROM every time you increment the count. Instead, keep a counter variable in RAM and implement the EEPROM update policy. For example, you may choose to update the EEPROM once for every 100 increments of the RAM counter, or after x hours of inactivity.
  • Before writing data into an EEPROM location, read this location to see if it already contains the data to be written. In EEPROMs, writing the same data into the same location still counts as a write cycle!
  • Use a wear leveling scheme, in which you rotate your storage area through a range of EEPROM addresses. For example, if you have a 32-bit counter, create an array of 32-bit locations and rotate between these locations when incrementing the counter. This one should be taken in conjunction with the next point...
  • When placing a frequently updated data into the EEPROM, try to keep this data within sector boundaries. Like flash storage, EEPROMs do have sectors. Tibbo devices with 2KB EEPROMs have 16-byte sectors. Devices with 256-byte EEPROMs have 8-byte sectors. When you update the data in a portion of a sector, you are actually wearing off the entire sector! When counting sector boundaries, take into the account the stor.base property — it gives all your writes a fixed offset! For example, on the EM1000 (2KB EEPROM), to write into the third sector of the EEPROM, use stor.setdata(s,4), because stor.base=29 and 29+4=33, i.e. the first location of the third 16-byte sector (stor. locations are counted from 1).
  • Use redundancy — keep two or more copies of your EEPROM data and protect the data with checksums. Should one copy fail, there will be another copy to use. This also helps against abrupt power failures. If the power is turned off while the EEPROM write is in progress you may lose your data. Having a backup copy helps in such situations.
  • Consider using our STG library* — it will save you a lot of headache in dealing with EEPROM data.

When estimating the life of the EEPROM in your system, consider the following:

  • Always take into the account the underlying sector nature of EEPROM ICs. Writing even a single byte into a sector reduces the lifespan of the entire sector.
  • Writing a string of several characters constitutes the number of write cycles equal to the number of characters in that string. Executing stor.setdata("ABC",4) counts as three write cycles, not one.
  • High ambient temperature reduces the life of EEPROMs.
  • All vendor estimates for the projected EEPROM life are probabilistic in nature. You will encounter "stronger" and "weaker" specimen with vastly different endurance levels. All in all, it is quite safe to assume that your EEPROM will last for at least 1 million write cycles per sector... and yet, there is no guarantee of that.
  • The stor. object and STG library are documented in the TIDE, TiOS, Tibbo BASIC, and Tibbo C manual.