Shop OBEX P1 Docs P2 Docs Learn Events
Erasing EEPROM — Parallax Forums

Erasing EEPROM

agentileagentile Posts: 101
edited 2005-03-21 15:44 in BASIC Stamp
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

Comments

  • NewzedNewzed Posts: 2,503
    edited 2005-03-19 22:18
    Agentile, what EEPROM are you using?· Some overwrite when you set the address to 0, others require an erase routine.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    NEW! 4 MB EEPROM

    http://hometown.aol.com/newzed/page4.html
    ·
  • agentileagentile Posts: 101
    edited 2005-03-20 17:03
    Sid,

    · 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
  • GadgetmanGadgetman Posts: 2,436
    edited 2005-03-20 17:25
    When you download a program to the Stamp it only writes to the locations SUPPOSED to contain either PROGRAM or predefined DATA, all other locations are left as they were.
    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'
  • edited 2005-03-21 05:49
    The command:

    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
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-03-21 15:44
    Neat syntax, Andy. I assume the 'Data 0 (2048)' command will erase the code itself, too.

    Oops, just tried it, apparently it is a compiler directive -- it HAS no code associated with it. Very nice.
Sign In or Register to comment.