EEPROM - BASIC Stamp Command Reference
subsequent EEPROM directives start with the pointer value left by the
previous EEPROM directive. For example, if the program contains:
EEPROM
(72, 69, 76, 76, 79)
EEPROM
(104, 101, 108, 108, 111)
The first EEPROM directive will start at location 0 and increment the
pointer for each data value it stores (1, 2, 3, 4 and 5). The second EEPROM
directive will start with the pointer value of 5 and work upward from
there.
As a result, the first 10 bytes of EEPROM will look like the
following:
0
72
69
Contents
What if you don't want to store values starting at location 0? Fortunately,
the EEPROM directive has an option to specify the next location to use.
You can specify the next location number (to set the pointer to) by using
the optional Location argument before the list of Dataitems. The following
code writes the same data in Table 5.9 to locations 50 through 59:
DATA
50, (72, 69, 76, 76, 79, 104, 101, 108, 108, 111)
In this example, the Location argument is given and tells the EEPROM
directive to store the following DataItem(s) starting at location 50. The
DataItems in the list are stored in their respective locations (50, 51, 52...
59).
It is important to realize that the entire BASIC Stamp 1 EEPROM is
overwritten during programming. Any EEPROM location not containing
a PBASIC program or DataItems from an EEPROM directive is written
with a 0.
A common use for EEPROM is to store strings; sequences of bytes
representing text. PBASIC converts quoted text like "A" into the
corresponding ASCII character code (65 in this case). To make data entry
easier, you can place quotes around a whole chunk of text used in a
EEPROM directive, and PBASIC will understand it to mean a series of
bytes (see the last line of code below). The following three EEPROM
directives are equivalent:
Page 112 • BASIC Stamp Programming Manual 2.0b • www.parallaxinc.com
EEPROM Location (address)
1
2
3
4
76
76
79
5
6
7
8
104
101
108
108
Table 5.9: Example EEPROM
storage.
9
111
W
RITING DATA TO OTHER LOCATIONS
I
MPORTANT CONCEPT
AND PROGRAMS ARE DOWNLOADED
EEPROM.
W
RITING TEXT STRINGS
.
: H
OW DATA
.
Need help?
Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?