BASIC stamp manual v2.2
EEPROM – BASIC Stamp Command Reference
Page 184 • BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com
The EEPROM directive uses a counter, called a pointer, to keep track of
available EEPROM addresses. The value of the pointer is initially 0. When
a program is downloaded, the EEPROM directive stores the first byte
value at the current pointer address, then increments (adds 1 to) the
pointer. If the program contains more than one EEPROM directive,
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:
EEPROM Location (address)
0 1 2 3 4 5 6 7 8 9
Contents
72 69 76 76 79 104 101 108 108 111
Table 5.22: Example EEPROM
Storage.
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.22 to locations 50 through 59:
EEPROM 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 an
T
HE EEPROM POINTER (COUNTER).
W
RITING DATA TO OTHER LOCATIONS.
W
RITING TEXT STRINGS.
I
MPORTANT CONCEPT: HOW DATA AND
PROGRAMS ARE DOWNLOADED INTO
EEPROM.