We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am wondering how to save a variable's value in case of power reset. I am creating a program to write to a display and I want to keep track of the selection that the user made before the system power went down and got reset. How can I do this? Thanks for any help, Vida
But if power has been lost, RAM contents will also have been lost! As the title suggests, you need some sort of non-volatile memory; eg, * EEPROM; * Battery-Backed RAM; * If your system has FLASH, it might be possible to use an area of the FLASH for non-volatile data storage If you use EEPROM, you'd need some way to detect that the power was about to go down, and then quickly save the required values; With Battery-Backed RAM you'd just need to ensure that the variables were located in the non-volatile area (and use NOINIT) Depending on how long you need to retain the data, you might be able to use a capacitor instead of a battery (there are capacitors available specifically for this purpose) Triscend has an App Note on using FLASH for data with their E5 devices: http://www.triscend.com/products/an01.pdf
Saving values for power cycle safekeeping is quite an art if you have to be absolutotally sure that the value is relevant. In both flash, EEPROM and battery backed RAM there are conditions where the value can be garbled during power down. A reasonably safe approach is to write the value in 3 places and on power up use 2 that match. Have fun, Erik