5: BASIC Stamp Command Reference - DATA
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 91
DATA
BS1
BS2 BS2e BS2sx BS2p
(See EEPROM)
{
Symbol
} DATA
DataItem {, DataItem…}
Function
Write data to the EEPROM during program download.
•
Symbol
is an optional, unique symbol name that will be
automatically defined as a constant equal to the location number of
the first data item.
•
DataItem
is a constant/expression (0 – 65535) indicating a value or
how to store a value.
Explanation
When you download a program into the BASIC Stamp, it is stored in the
EEPROM starting at the highest address (2047) and working towards the
lowest address. Most programs don’t use the entire EEPROM, so the
lower portion is available for other uses. The DATA directive allows you
to define a set of data to store in the available EEPROM locations. It is
called a “directive” rather than a “command” because it performs an
activity at compile-time rather than at run-time (ie: the DATA directive is
not downloaded to the BASIC Stamp, but the data it contains is
downloaded).
The simplest form of the DATA directive is something like the following:
DATA 100, 200, 52, 45
This example, when downloaded, will cause the values 100, 200, 52 and 45
to be written to EEPROM locations 0, 1, 2 and 3, respectively. You can
then use the READ and WRITE commands in your code to access these
locations and the data you’ve stored there.
DATA 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 DATA 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 DATA directive, subsequent DATAs start with the
pointer value left by the previous DATA. For example, if the program
contains:
1
2
e
2
sx
2
p
2
W
RITING SIMPLE
,
SEQUENTIAL DATA
.
T
HE
DATA
POINTER
(
COUNTER
).
Summary of Contents for BASIC Stamp 2e
Page 1: ...BASIC Stamp Programming Manual Version 2 0c...
Page 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...