using eeprom for persistent store
alpinekid
Posts: 8
I designing a propeller based product for a client and they need one variable to be persistent over a power cycle. I'm trying to figure out if the address of the variable returned by the @ operator in spin is useful to get the address of the variable in the EEPROM. The plan is to write the value to the EEPROM every minute.
I'm hoping that I can just use the I2C and rewrite that location with an updated value. Sort of like self modifying code.
I have declared the variable.
DAT
varName WORD 0
Does the @varName match or is a fix constant offset to the physical place in the EEROM?
I'm hoping that I can just use the I2C and rewrite that location with an updated value. Sort of like self modifying code.
I have declared the variable.
DAT
varName WORD 0
Does the @varName match or is a fix constant offset to the physical place in the EEROM?
Comments
Very important is to not write to EEPROM too often. It's too easy to wear out locations in the EEPROM. One thing that's useful is to read the data already in EEPROM and compare it to the data you intend to write. If they're the same, skip the write operation.
Do remember that, if you upload a new version of your program to the EEPROM, it replaces everything in the first (or only) 32K including any persistent values stored there.
I like your idea of reading first.
That's just for the location being written. Ideally you would write to new locations over time to maximize the life of the EEPROM.
That is, unless you get $$$$$ for swapping out the EEPROM...