Go Down

Topic: Store permanent data? (Read 1 time) previous topic - next topic

mdkoskenmaki

Is there a mechanism to permanently store some information, such as a couple numbers, and have those numbers read after a power down and restart? 
+++++++++++++++++++++++++++++

5 of every 4 people have math issues.

retrolefty


Is there a mechanism to permanently store some information, such as a couple numbers, and have those numbers read after a power down and restart?   


Yes, the 328p AVR chip includes 1K byte of EEPROM memory for just that purpose.

Lefty

CrossRoads

Yes. Have your code write them to the internal EEPROM.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

(I must be slow typing today)
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

retrolefty

#4
Feb 08, 2012, 06:05 pm Last Edit: Feb 08, 2012, 06:07 pm by retrolefty Reason: 1

(I must be slow typing today)



Today? I've always found you on the somewhat tardy side.  ]:D

I though fencing sped up one's reflexes?


Lefty

John_S

Depends what your definition of permanent is. The EEPROM is only good for 20 years at 85°C or 100 years at 25°C.

In most cases though, that should be sufficient :)
http://jsrintervalometers.blogspot.ca

retrolefty


Depends what your definition of permanent is. The EEPROM is only good for 20 years at 85°C or 100 years at 25°C.

In most cases though, that should be sufficient :)


At my age that seems as good as infinite time.  ;)

mdkoskenmaki

ok, then.  I didn't realize that some had EEPROM.   

Anyone have a clever way of not consuming a large amount of clock cycles, but yet "saving" a variable that can get changed by the user?   It is supposed to boot initially with a default and operate from it.   Should the user ever decide to alter that default, they change it via an input and after that, it uses the saved, not the default, when it starts up after that. 

Just looking for a mechanism, not necessarily code.  So far, I'm a bit stymied as to how to do that.  Normally, computer data is saved at the end of  the program.  But since these have no 'end' and are just randomly powered down, one can't use that trigger to "save".  I wanted to use user input to change the default as the trigger to save.   If I do that, how do I not substitute whatever's randomly in EEPROM at boot time until it has been written?   


+++++++++++++++++++++++++++++

5 of every 4 people have math issues.

retrolefty

Quote
If I do that, how do I not substitute whatever's randomly in EEPROM at boot time until it has been written


Well the key is that EEPROM memory unless written to by user program coding will not contain 'random' values, but rather all 0xFF bytes at every location. So your sketch in it's setup code can just read a specific address in EEPROM and if it contains other then 0xFF values then it can assume that was a saved new default value to use.

Make sense?

Lefty

CrossRoads

Oh, I've got good reflexes, just slow fingers sometimes!
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

mdkoskenmaki


Quote
If I do that, how do I not substitute whatever's randomly in EEPROM at boot time until it has been written


Well the key is that EEPROM memory unless written to by user program coding will not contain 'random' values, but rather all 0xFF bytes at every location. So your sketch in it's setup code can just read a specific address in EEPROM and if it contains other then 0xFF values then it can assume that was a saved new default value to use.

Make sense?

Lefty



Ok, I wasn't aware of that.  I had, for whatever reason, assumed it was just "random" set bits. 

If I can depend on that, then I don't see any issue. 

+++++++++++++++++++++++++++++

5 of every 4 people have math issues.

Go Up