Erasing EEPROM
agentile
Posts: 101
I am working on a data-recording program, wherein the BS2 records time and temperature at five minute intervals.· At each interval the values for time and temp are stored in EEPROM.· I have had no trouble recording values to EEPROM.· I ran the system as a test, recording once a minute for two hours.· But now when I do a memory dump into hyperterminal, I get not just my new data, but a lot of old data that I don't want.· I had assumed that all the EEPROM would be set to 0 (or 255) upon loading a program.· But apparently this is not the case.· Is there an easy way to erase all my old data from EEPROM?
Thanks,
agentile
Thanks,
agentile
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
NEW! 4 MB EEPROM
http://hometown.aol.com/newzed/page4.html
·
· I don't know exactly what type of EEPROM is on the stamp, but I am using the memory on the stamp.··I wrote a program which places 255 in each of the first 1500·memory locations.· This works, but I was hoping that there would be an easier way.· If you know of one, please let me know.
thanks,
agentile
I believe this was to increase the speed of the download.
If you want to erase every location, use DATA statements to overwrite the locations with '0'
DATA 0 (2048)
will overwrite the BASIC Stamp's EEPROM with zeros. A separate program can then be loaded into memory for the datalogging.
Another way to deal with the problem is to write a unique value to the address that immediately follows the last address of valid data in EEPROM. For example, if you only plan on storing values from 0 to 127, a DO...LOOP or IF...THEN statement can be used to check for the "end of data" value before reading the next value. Here is a reading example:
index VAR Word
value VAR Byte
DO UNTIL value = 128
READ index, value
DEBUG ? value
index = index + 1
LOOP
END
Here is the writing example:
index VAR Word
value VAR Byte
DO UNTIL value = 128
DEBUG "Enter value: ", CR
DEBUGIN DEC value
WRITE index, value
index = index + 1
LOOP
END
Oops, just tried it, apparently it is a compiler directive -- it HAS no code associated with it. Very nice.