Menu

Variable save and restore

Help
trackus
2018-04-09
2018-04-09
  • trackus

    trackus - 2018-04-09

    Hello maybe someone can help me or give me a tip,

    I look for a simple way to save and restore program variables in the EEPROM of the controller (in my case a atmega328).
    I have some different byte and word variables wich I want save in a for loop to the EEPROM and read back after power off/on.
    Array variables are not a option for me.
    If all variables were in an order then I could read by peek and save the value in the EEPROM, but how can I archieve this and how can I get the start and end of this variable area.

    Has anybody an idea?

     
  • kent_twt4

    kent_twt4 - 2018-04-09

    Keep the values all the same type , so all word values. Then set a unique flag value (like wordVal_H = 0x55, wordVal = 0xAA ?) after the end of the for loop, so that you know you have reached the end when you read them back from the eeprom. Use a similar flag, before the for loop, if a required start value is needed.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.