View Full Version : eeprom storage problem
05-29-2005, 06:26 AM
Ok, I am being thick here I am sure.
One of my programs fills nearly all the memory up, and just leaves a small amount left.
During my program, a routine needs to store three values in the eeprom for retrieval even after a power down.
I cannot get it to store these values, as the program is over-writing the memory addresses.
How do you work out the memory address of the spare remaining space, so that I can 'write' to a free memory area.
IC0, 1B0 and 1D0 are the rows showing free on the memory map.·
05-29-2005, 06:35 AM
When you try to store data in EEPROM, data storage starts at the very bottom of the memory.· If you have free space at the top of the memory map, beginning with 000 then you can store data.· For instance:
write 0, var1
write 10, var2
write 20, var3
Then you can read what you have stored and put the values in any variable you choose:
read 0, x
read 10, y
read 20, z
Need a bezel for your LCD?
05-29-2005, 06:54 AM
Another way of saying this is that PBasic and the IDE store your program starting at high memory addresses. This leaves the low memory addresses (like zero, 1, 2, ... ) free for 'DATA 0, 100' type statements. If you DID use this statement, then you could READ and WRITE location zero as desired.
If you do this, you as a programmer need to insure your eeprom DATA space, and your code space, do not collide. PBasic does not insure this by itself. You can easily use the Memory Map to determine what space is available. Look up the DATA statement for how to set and use these addresses.
05-29-2005, 06:58 AM
The Memory Map feature of the IDE will show you how much you're actually using. Addresses starting at 0 are where you may be able to store data. And remember that with PBASIC 2.5 you can store a Word with one line of code:
WRITE 0, Word myValue
-- and it works for READ too:
READ 0, Word myValue
Applications Engineer, Parallax