PDA

View Full Version : EEPROM vs DATA



90alper90
- 8th July 2009, 23:25
Is there any difference between EEPROM and DATA command?

Both of them write informations to hex file and data which will be stored in eeprom is written to eeprom during programming, isn't it?

I can't see any technical difference between them.

Thanks :)

ScaleRobotics
- 9th July 2009, 09:03
They both write to eeprom, but DATA can only write static values from compile at program time. Eeprom can write to the eeprom while executing your program, so live data or results can be stored.

Melanie
- 9th July 2009, 10:42
No, not quite correct...

DATA and EPROM are compiler directives that create EEPROM contents at COMPILE TIME only. Those values will be burned into your HEX file and loaded into the chip when you program it. So yes, DATA and EPROM are the same as alper queried. I believe it was included to maintain compatability with BASIC STAMP - but don't quote me on that as I've never played with STAMP.

Use the WRITE command to alter those preset values thereafter during program execution.

90alper90
- 9th July 2009, 10:44
Thanks scalerobotics

You mean that we can store variables -live data- by EEPROM, aren't you?

However, explanation given by Melabs says that:


Store constants in on-chip EEPROM. If the optional Location value is omitted, the first EEPROM statement starts storing at address 0 and subsequent statements store at the following locations. If the Location value is specified, it denotes the starting location where these values are stored. Constant can be a numeric constant or a string constant. Only the least significant byte of numeric values are stored. Strings are stored as consecutive bytes of ASCII values. No length or terminator is automatically added.

I understood that we can't store variables. If we want, we have to use WRITE.

Thanks

Edit: While I was writing, Melanie sent a reply.

Thanks Melanie,

Combatability seems to be logical reason. Can we say that we can use either of them without hesitation?

Some examples are given by Melabs on http://www.melabs.com/resources/pbpmanual/

Examples of DATA seem to be more complex than EEPROM. For example, you can skip some location while storing. But, there isn't such an example in EEPROM.

Thanks

Melanie
- 9th July 2009, 14:18
I've never bothered with EPROM because DATA works nicely for me. The only salient difference I can see is that DATA has the ability to prefix the memory location with a reference LABEL which EPROM doesn't do (or at least it doesn't appear to have this feature - though I've never bothered to find out for myself). Now prefixing a location with a label is very useful, as you then don't have to bother keeping track of EEPROM addresses per se... Example...



EContrast Data 2 ' Contrast Level
EBackLight Data 2 ' BackLight Level


... and in your code if you need the Contrast value you can simply...



Read EContrast,LCDContrast


Now if you used EPROM to save your data, you would have to keep track that the Contrast was (for example) at EEPROM address 252...



Read 252,LCDContrast


...which just isn't as professional. Apart from that, if you have dozens of items in EPROM, sliding one into the middle of the list is easy with DATA LABELS (because when you recompile the compiler will re-address all your code labels), but if you use EPROM, and you add something into the list before it, then it won't be address 252 anymore, but 253, so it is then up to YOU to go through all your hundreds (or even thousands) of lines of code to make sure that what you have added or taken away from your EPROM list hasn't impacted elsewhere (which it probably would have done!).

So, DATA usage (with LABELS) is real good, EPROM usage (without LABELS) is amateurish.

90alper90
- 14th July 2009, 20:51
Thanks Melanie and scalerobotics :)

Your replies helped me very well. :)