
CHAPTER 5 RAM MEMORY
RPC-30 Page 17
Battery voltage is between 2.5 and 3.3 volts. T he
voltage is measured by placing a volt meter between
ground and the battery clip.
The battery may be replaced by the following type or
equivalent:
Panasonic BR2325
To replace the battery, lift up the holder and push the
battery from behind. To install, simply reverse the
procedure. The batter y may be replaced while pow er is
on. If you replace the batter y with power off, be sure to
reset the date and time. Also, data stored in RAM will
be lost.
STORING VARIABLES IN RAM
The term "var iables" in this context includes numb ers,
strings, arrays, recipes, and formulas as applied to your
application.
Progr ams and C AMBASIC variables reside in the first
64K of RAM called segment 0. Your variables are
generally stored in segment 1 and higher.
PEEK and POKE commands store and retrieve values
from memory. For example:
20 POKE 12,A,1
puts the value of A into segment 1, address 12.
Use the PEEK statement to retrieve the variable:
50 B = PEEK(12, 1)
You can store and retrieve arrays, strings, and variables
in this way. There ar e many variations of PEE K and
POKE statements. Refer to the CAMBA SIC
Programming Manual for additional information and
examples. A list of comm ands appea rs at the end of this
chapter.
CORRUPTED VARIABLES
The RPC -30' s RAM is automatically battery backed up.
User defined data can be saved when the board is
powered off then on. W hen your application m ust rely
on the accuracy of this data after power up, corrupted
variables becomes a possibility.
The nature of RAM is it is easily written to. Any
POKE' d data is susceptible to corr uption. This is
especially true when the board is powered down. The
RPC-30 has an intelligent reset circuit which minimizes
data corruption. However, when POKEing long data,
such as strings and floating point numbers, a reset could
interrupt a saving pr ocess. The r esult is inform ation is
corrupted. A scenario is explained below.
A program is running and POKEing data into RAM. At
the same time it is poking, a reset occurs. A reset can
occur due to power loss, someone pushing the reset
button, or a wa tchdog time r time out.
If the program was POKEing a string (POKE $), floating
point number (FPOKE), double byte (DPOKE ), or arr ay
while the reset occurred, the data became corrupted.
This is because the complete value was not saved.
Since it is impossible to predict or delay a reset, a work
around is to duplicate or triplicate POKEd values. That
is, you would have to save the same information in two
or three different places. F or purposes of discussion,
POKEd variables are called sets because data can consist
of a mixture of variables, strings and arrays.
On power up, the program compares values from one set
to the other one or two. If the two (or three) agreed,
then there was no corruption and the program can
reliably use the values. In practice, you would read
information from set 1, but would save data to all two or
three.
The use of duplicate or triplicate sets depends upon what
the system must or can do if data is corrupted. When
using a duplicate set, a corrupted set indicates that
default values (from serial EEPROM or the program)
should be used, since it is uncertain if the first or second
set is corrupted. Both data sets would then be re-
initialized.
A triplicate set is used to recover the last set or indicate
that the data in the first set is valid. The pr ocedure and
logic is as follows.
Data is written to each element in a set in a specific and
consistent order (data to an entire set does not have to be
written to, just that element). For example, a calibration
constant is saved (POKEd) in three different places.
Assume that the constant was assigned address 0, 100,
and 200 in segment 1. The data is POKEd to address 0
first, then 100, then 200.
Komentáře k této Příručce