Pages: [1]   Go Down
Author Topic: Store permanent data?  (Read 820 times)
0 Members and 1 Guest are viewing this topic.
where the spirit leads
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Jack of all technologies, master of none
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?   
Logged

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

5 of every 4 people have math issues.  

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16513
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 437
Posts: 23692
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes. Have your code write them to the internal EEPROM.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 437
Posts: 23692
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

(I must be slow typing today)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16513
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

(I must be slow typing today)


Today? I've always found you on the somewhat tardy side.  smiley-twist

I though fencing sped up one's reflexes?


Lefty
« Last Edit: February 08, 2012, 12:07:23 pm by retrolefty » Logged

Canada
Offline Offline
Sr. Member
****
Karma: 0
Posts: 318
Sometimes teaching, always learning,
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged


Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16513
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

At my age that seems as good as infinite time.  smiley-wink
Logged

where the spirit leads
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Jack of all technologies, master of none
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?   


Logged

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

5 of every 4 people have math issues.  

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16513
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 437
Posts: 23692
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, I've got good reflexes, just slow fingers sometimes!
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

where the spirit leads
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Jack of all technologies, master of none
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. 

Logged

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

5 of every 4 people have math issues.  

Pages: [1]   Go Up
Jump to: