Remote Processing RPC-30 User Manual

Page 19

Advertising
background image

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 re placed 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
proced ure. The batter y may be replace d while pow er is
on. If you rep lace the batter y with pow er off, be sure to
reset the da te 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, arr ays, recipes, and formulas as applied to your
application.

Progr ams and C AMBA SIC variab les reside in the first
64K of RAM called segment 0. Your variables are
generally stored in segment 1 and higher.

PEEK and PO KE commands store and retrieve values
from memor y. 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
examp les. 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 c an be saved when the b oard is
power ed off then on . W hen your application m ust rely
on the accuracy of this data after power up, cor rupted
variables becomes a possibility.

The nature of RAM is it is easily written to. Any
POK E' d data is susceptib le 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 strin gs and floating p oint numbe rs, a reset co uld
interr upt 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 o ut.

If the program was P OKEing 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,
POKE d variables are called sets because data can consist
of a mixture of va riables, strings and arr ays.

On power up, the program compares values from one set
to the other one or two. If the two (or three) agr eed,
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. W hen
using a duplicate set, a corrupted set indicates that
d e fa u lt va l ue s (f r om s e ri a l E E P R O M o r t he p r og r a m )
should be used, since it is uncertain if the first or second
set is corrupted. Both data sets would then be re-
initialized.

A triplica te set is used to r ecover the last set or ind icate
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 (POK Ed) in three differ ent places.
Assume that the constant was assigned address 0, 100,
and 200 in segment 1. The data is PO KEd to addr ess 0
first, then 100, then 200.

Advertising