EasyManua.ls Logo

Parallax BASIC Stamp 2e - Page 95

Default Icon
353 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
5: BASIC Stamp Command Reference - DATA
BASIC Stamp Programming Manual 2.0c www.parallaxinc.com Page 93
program can then use the MyNumbers constant as a reference to the start of
the data within a READ or WRITE command. Each DATA directive can
have a unique symbol preceding it, allowing you to reference the data
defined at different locations.
There may be a time when you wish to reserve a section of EEPROM for
use by your BASIC code, but not necessarily store data there to begin with.
To do this, simply specify a DataItem within parentheses, as in:
DATA @100, (20)
The above DATA directive will reserve 20 bytes of EEPROM, starting with
location 100. It doesn’t store any values there, rather it simply leaves the
data as it is and increments DATA’s location pointer by 20. A good reason
to do this is when you have a program already downloaded into the
BASIC Stamp that has created or manipulated some data in EEPROM. To
protect that section of EEPROM from being overwritten by your next
program (perhaps a new version of the same program) you can reserve the
space as shown above. The EEPROM’s contents from locations 100 to 119
will remain intact. NOTE: This only "reserves" the space for the program
you are currently downloading; the BASIC Stamp does not know to
"reserve" the space for future programs. In other words, make sure use
this feature of the DATA directive in every program you download if you
don't want to risk overwriting valuable EEPROM data.
It is important to realize that EEPROM is not overwritten during
programming unless it is needed for program storage, or is filled by a
DATA directive specifying data to be written. During downloading,
EEPROM is always written in 16-byte sections if, and only if, any
location within that section needs writing.
DATA can also store the same number in a block of consecutive locations.
This is similar to reserving a block of EEPROM, above, but with a value
added before the first parenthesis. For example,
DATA @100, 0 (20)
This statement writes the value 0 in all the EEPROM locations from 100 to
119.
R
ESERVING EEPROM LOCATIONS.
W
RITING A BLOCK OF THE SAME
VALUE.
IMPORTANT CONCEPT: HOW DATA
AND PROGRAMS ARE DOWNLOADED
EEPROM.

Table of Contents

Related product manuals