Please help with basic EEPROM
thokennedy
Posts: 4
I am having trouble with storing information.
If I just use the loop:
for counter = 0 to 99
write counter, 2
next
shouldn't that store '2' 100 times in the eeprom, taking up 100 bytes? When I run the memory map, or try to read them, I get nothing. Sorry I must be missing something basic here...thanks for any help.
If I just use the loop:
for counter = 0 to 99
write counter, 2
next
shouldn't that store '2' 100 times in the eeprom, taking up 100 bytes? When I run the memory map, or try to read them, I get nothing. Sorry I must be missing something basic here...thanks for any help.
Comments
Can you direct me to a simple program that I can see stores data in the EEPROM that I can then reference later? Does that data get cleared when you run another program?I guess myunderstanding is that, lets say, you store a byte in address 0 - then you can read that value, even after you shut down, until you over write it with something else.
The "Memory Map" only shows what the IDE is GOING to write to your BS2 -- it doesn't actually read out the contents of the BS2.
When you download a program to a Stamp, the program is stored starting at the upper end of the 2K of EEPROM extending downwards towards zero. Any DATA statements are stored beginning at location zero and extending upwards toward the program. If you're not using DATA statements, you can start storing data beginning at location zero. Since you have control of where the DATA statements go in memory, you can (and must) allocate where the various pieces of data go in the EEPROM. They just can't overlap the program.
Whatever you store with a WRITE statement will stay there until changed. If you download a new program and the new program doesn't occupy the same part of memory, the data will remain. The memory map for a program will show you what parts of the EEPROM are used by the program. To restate: downloading a new program does not clear the EEPROM. It only changes the portion of the EEPROM occupied by the new program as shown in the memory map.
Do remember that EEPROM locations can be written only a limited number of times (about 1000000 times). This may seem like a lot, but, in a loop, can be exceeded in just a few days.