5: BASIC Stamp Command Reference – WRITE
3.
Check the program's memory map to determine what portion of memory
your program occupies and make sure that EEPROM writes cannot stray
into this area. You may also use the DATA directive on the BS2, BS2e,
BS2sx and BS2p to set aside EEPROM space.
On the BS1, location 255 holds the address of the last instruction in your
1
program. Therefore, your program can use any space below the address
given in location 255. For example, if location 255 holds the value 100,
then your program can use locations 0–99 for data.
2
2
2
2
On other BASIC Stamps, you'll need to view the Memory Map of the
e
sx
p
program before you download it, to determine the last EEPROM location
used. See the "Memory Map Function" section in Chapter 3.
2
On the BS2p, the READ and WRITE commands can affect locations in any
p
program slot as set by the STORE command. See the STORE command for
more information.
Demo Program (WRITE.bas)
1
' This program writes a few bytes to EEPROM and then reads them back out and displays
' them on the screen.
'{$STAMP BS1}
SYMBOL
SYMBOL
WriteItOut:
WRITE 0, 100
WRITE 1, 200
WRITE 2, 45
WRITE 3, 28
ReadItOut:
FOR ValAddr = 0 TO 3
READ ValAddr, Value
DEBUG ? Value
might take to exceed the guaranteed maximum. For example, on
the BS2, at one write per second (86,400 writes/day) it would take
nearly 116 days of continuous operation to exceed 10 million.
The primary function of the EEPROM is to store programs (data is
stored in leftover space). If data overwrites a portion of your
program, the program will most likely crash.
ValAddr
= B0
Value
= B1
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 331
'STAMP directive (specifies a BS1)
'Write some data to location 0 through 3
'Read all four locations and display the
'value on the screen
Need help?
Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?