where the spirit leads
Offline
Newbie
Karma: 0
Posts: 31
Jack of all technologies, master of none
|
 |
« on: February 08, 2012, 11:59:05 am » |
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
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #1 on: February 08, 2012, 12:00:46 pm » |
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
Offline
Brattain Member
Karma: 245
Posts: 16515
Available for Design & Build services
|
 |
« Reply #2 on: February 08, 2012, 12:01:39 pm » |
Yes. Have your code write them to the internal EEPROM.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 245
Posts: 16515
Available for Design & Build services
|
 |
« Reply #3 on: February 08, 2012, 12:02:15 pm » |
(I must be slow typing today)
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #4 on: February 08, 2012, 12:05:47 pm » |
(I must be slow typing today)
Today? I've always found you on the somewhat tardy side.  I though fencing sped up one's reflexes? Lefty
|
|
|
|
« Last Edit: February 08, 2012, 12:07:23 pm by retrolefty »
|
Logged
|
|
|
|
|
Canada
Offline
Sr. Member
Karma: 0
Posts: 319
Sometimes teaching, always learning,
|
 |
« Reply #5 on: February 08, 2012, 12:07:28 pm » |
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 
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #6 on: February 08, 2012, 12:08:51 pm » |
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. 
|
|
|
|
|
Logged
|
|
|
|
|
where the spirit leads
Offline
Newbie
Karma: 0
Posts: 31
Jack of all technologies, master of none
|
 |
« Reply #7 on: February 08, 2012, 12:34:23 pm » |
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
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #8 on: February 08, 2012, 12:41:17 pm » |
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
Offline
Brattain Member
Karma: 245
Posts: 16515
Available for Design & Build services
|
 |
« Reply #9 on: February 08, 2012, 12:45:05 pm » |
Oh, I've got good reflexes, just slow fingers sometimes!
|
|
|
|
|
Logged
|
|
|
|
|
where the spirit leads
Offline
Newbie
Karma: 0
Posts: 31
Jack of all technologies, master of none
|
 |
« Reply #10 on: February 08, 2012, 01:16:08 pm » |
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.
|
|
|
|
|