|
|
View previous topic :: View next topic |
Author |
Message |
Rank amateur Guest
|
How does EEPROM help |
Posted: Mon Jun 28, 2004 2:07 am |
|
|
Really dumb question from a micro hardware novice:
From what I have read, some PICs have onboard EEPROM. Let's say I store some constants I need in EEPROM. Then when I want to do a calculation, instead of defining a constant in my code, I retrieve the constant data from EEPROM. Lets say I need to use the constant hexadecimal number 0x211 for some reason.
So, for example I use this line of code in my program:
> the_const = read_eeprom(data_address);
where the data byte 0x211 has already been written to EEPROM "data_address" already.
What is the advantage of doing the above over saying doing this:
> the_const = 0x211;
If I need to define and manipulate the variable "the_const" in my code anyway, how does EEPROM help?
Thanks! |
|
|
Ttelmah Guest
|
Re: How does EEPROM help |
Posted: Mon Jun 28, 2004 2:41 am |
|
|
Rank amateur wrote: | Really dumb question from a micro hardware novice:
From what I have read, some PICs have onboard EEPROM. Let's say I store some constants I need in EEPROM. Then when I want to do a calculation, instead of defining a constant in my code, I retrieve the constant data from EEPROM. Lets say I need to use the constant hexadecimal number 0x211 for some reason.
So, for example I use this line of code in my program:
> the_const = read_eeprom(data_address);
where the data byte 0x211 has already been written to EEPROM "data_address" already.
What is the advantage of doing the above over saying doing this:
> the_const = 0x211;
If I need to define and manipulate the variable "the_const" in my code anyway, how does EEPROM help?
Thanks! |
Multiple parts:
Think of EEPROM as being for 'long term', rather than 'constant' data. So, if the value required is a 'constant', then just use const, and store it in the ROM. However if this value is going to change (say) daily, when the system recalibrates itself, then you really _must_ use the EEPROM. The reason is that the main program memory, has a life cycle for number of writes, that is typically perhaps 1000 cycles, while the EEPROM has a life usually at least 100* larger.
Seperately, the use of the EEPROM as a seperate storage area for calibration values etc., is good where the system may be going to undergo flash updates. Potentially, you can flash the program code, and still have the current calibration values retained, were values stored 'in' the code, will be overwritten.
Use of the seperate area, also has the advantage of structuring the storage, and potentially reducing the code size. If (for instance), you code twenty 'constants' into the main program ROM, each will be accompanied by the code to retrieve it. If instead you store these same values into the EEPROM, and have a single shared subroutine called with the address where the data is to be saved, the overall code size drops significantly.
Finally, EEPROM is also available on some chips that are not 'flash' programmable. So you can again store 'long term' near constants, in semi-permanent storage on these, while you only otherwise have a choice of fully 'constant' (stored when the chip is initially programmed), or RAM.
Best Wishes |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Mon Jun 28, 2004 4:53 am |
|
|
One more thing worth mentioning, is using the EEPROM for saving the state of the system. By doing this you can recover from a crash/power failure/etc gracefully. I had to do a couple of projects for a few rural areas with very shakey power distribution, and the EEPROM came in very handy.
And as Mr.Hamlett already mentioned, calibration is another thing that makes EEPROMs useful. In another project we required the installing technician to calibrate each device based on each home that the device was being installed in. Where else to save these values other than the good old EEPROM? |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|