Shop OBEX P1 Docs P2 Docs Learn Events
EEPROM on Stamp? how do I store values to it? — Parallax Forums

EEPROM on Stamp? how do I store values to it?

MatthewMatthew Posts: 200
edited 2005-04-11 13:41 in BASIC Stamp
Hello, I'm running a program with my Stamp, and there's only one value of a variable that I would like to store on it, how would I do so?

Thanks,
Matthew

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-09 15:55
    Matthew,

    ·· You would use the Write command to do this.· Two things to be aware of when writing data to the EEPROM.· First of all, be sure you're not writing to an area that is already being used by the program or data.· Check the memory map to see what's being used and what's available.· Second, do not write the value within your main loop in the program.· You don't want to keep writing the value as if the EEPROM were RAM.

    ·· For one it's slow, so it can slow your program down if you are constantly updating the variable in EEPROM.· Also depending on how many writes per second to the same location you could actually exceed the max number of writes of the EEPROM.

    ·· Not trying to make you paranoid or anything, just seen this done twice in the last couple of years, and thought I would mention it.· You can find specifics and examples of using the Write command in the Help File within the Stamp Editor.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com


    Post Edited (Chris Savage (Parallax)) : 4/10/2005 1:30:04 AM GMT
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-04-09 23:30
    And what Chris failed to say is: the BS2 loads its code from High Memory down. Thus location zero up of the EEPROM are generally available to you as DATA statements, or targets of WRITE statements. Once you've compiled a program look at the memory map (that's the button with the Percent sign on it.) At the top of the map is location zero -- these are your declared 'DATA' statements, which allocate space in the EEPROM from location zero up.

    Scroll all the way down to the bottom -- this is HIGH EEPROM memory, where your program tokens are stored. As long as your DATA statements, and code tokens, don't collide, you should be ok.

    Note also you should write to the EEPROM seldom -- like once every 5 minutes max. The EEPROM allows 1 million to 10 million writes -- which sounds like a lot, and it IS a lot, it should allow you to write programs for years and years. The limitation comes if you write to the EEPROM under program control. You can wear out a location by writing to it every 10 mSec in about a week. That's something that's EASY for the BS2 to do, if you program it that way.

    There's ways of spreading the wear around -- but you should be aware this exists. Note you can add a 26L640 eeprom externally very easily, if you really do need to write that much -- and just swap chips when locations die.
  • Ben DamonBen Damon Posts: 42
    edited 2005-04-10 20:34
    Not that I've even stated to make a location die, but how did you know when one is dead?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ben Damon

    And may God Bless America!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-10 23:04
    ·· One of two things will tell you that...Depending on the location, you might get an EEPROM verify error when programming.· Otherwise, you will find out when the data you read back from the location is not what you put there.· This can be tricky if you don't know that's what's happening.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • nick bernardnick bernard Posts: 329
    edited 2005-04-11 13:41
    yessir, thats what happened to me. i was using eeprom locations in a loop to store an indexed counting variable.
    when i reprogramed the stamp with a debugging code and watched these locations in action i noticed that the variables would not count past 8, they would simply start back from 0 after an 8. i reasoned(w/ the boards help) that atleast one bit (bit3) on the eeprom memory location had fouled up because of over-writing. it was and expensive lesson to say the least.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    " Hey! Why is there silicone on my hemostats?"
Sign In or Register to comment.