[Solved] How to use persistant vars in EEPROM
DavidZemon
Posts: 2,973
Hello all,
I could pick a random large number for the variable address and hardcode it to a pointer... but I'd like to know if there is a better way to persistently read from and write to a variable in EEPROM. I only need to 16 bits, so a full filesystem on an SD card seems like a bit of overkill. Any ideas?
Thanks,
David
I could pick a random large number for the variable address and hardcode it to a pointer... but I'd like to know if there is a better way to persistently read from and write to a variable in EEPROM. I only need to 16 bits, so a full filesystem on an SD card seems like a bit of overkill. Any ideas?
Thanks,
David
Comments
Using Chris Gadd's "I2C driver.spin" as an example:
If you're using C, it should be pretty similar, but I would probably make the variable volatile.
Volatile just means don't optimize this out, right?
For anyone else stumbling across this thread, there are lots of ee_put* functions - there's one for byte, another for strings, etc.
All can be found in the doxygen documentation of Simple. Here's a link to ee_putInt() though:
http://david.zemon.name/PropWare/simpletools_8h.html#adf44a20755432a25076e28e94b809264