Remote Processing RPC-2350 User Manual

Page 31

Advertising
background image

CHAPTER 5

DATA MEMORY

5-5

severa l things happen. Data save d at line 1000 is
overwritten by the data in line 2000, even though
different write addresses were specified. This brings us
to the second r eason sector size is impor tant.

CAM BASIC forces the requeste d Flash a ddress do wn to
an even sec tor addr ess. In both cases a bove, data is
written to the Flash starting at address 0, not at 5 or 42.

The eas iest way to m ake an eve n sector a ddress is to
“A ND ” the Flash ad dress w ith &F F80 (as is done in
ARRAY 2.BAS pr ogram exam ple) when using a 128K
flash or &FF00 with a 512K.

Another consideration is the number of times Flash can
be wr itten to. A tmel specifie s anywhe re fr om 1000 to
10, 000 or m ore w rites. Com pared to R AM , this is qu ite
limiting. Flash sho uld be used to stor e default cons tants
or data that changes only occasionally.

Writing takes about 90 ms/1000 bytes. During SAVE
time, interrupts (ON COM$, ON KEYPAD, ON BIT,
etc.. ) are rec ognized but not serviced. If these
comm ands mu st be servic ed quicker , w rite data in
smaller blocks.

Using LOAD to transfer data
The LOA D comm and can be used to transfer data from
Flash to RAM or RAM to RAM. Use SAVE to transfer
from RA M to Flash.

LOAD transfers up to 64K blocks of memory at a time.
Use it to transfer an entire data structure containing
recipes, formulas, constants, etc.

The sample progr am ARR AY3. BAS shows how to move
data from extended mem ory RAM into CAMBASIC and
back.

INSTALLING 512K RAM

A 512K R AM (part num ber 103 9) can be installe d in
U2. The addition al RAM allows you to in crease data
storage, not program size.

Follow these steps to install RAM.

1.

Turn off power to the board.

2.

Remove existing IC from U 2.

3.

Install the 512K R AM . M ake sure pin 1 is
oriented towards the board edge. Pin 1 will be
marked with a dot or notch on top.

4.

Move jumper W2[1-2] to [2-3].

You are now ready to power up the board. You can
now PEE K and POKE data into segments 1-7.

CORRUPTED VARIABLES

When y our app lication must r ely on the acc uracy o f data
after power up, corrupted variables become 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. U26
monitor s the supply voltag e and turn s off wr iting when it
is below about 4.65 volts. How ever, when POKE ing
long data, such as strings and floating point numbers, or
writing to Flash, a pow er down could interrupt a saving
process. T he result is information is corrupted. A
scenario is explained below.

A p r og r a m i s r u n ni ng a nd s av in g da t a. D u r i ng th is ti m e
a reset occur s. A reset can occur due to power loss,
someone pushing the reset button, or a watchdog timer
time out. The data is c orru pted becaus e the com plete
value was not saved.

Since it is impossible to predict or delay a reset, a work
around is to duplicate or triplicate values. That is, you
would have to save the same information in two or three
different places. Usually you only need to save the
pointers to data structur es.

When y ou are w riting ar rays of da ta (such as show n in
LOG GER .BA S), th e sequence your pr ogram should
follow is this: Write data to RAM. Update the pointer.
This pointer could be in dup licate or tr iplicate. This
way, you only loose one set of data.

When you are saving only one set of data, the following
applies.

For purpose s of discussion, data varia bles are c alled sets
because it can consist of a mixture of variables, strings
and arra ys.

On power up, your program would compare 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. W hen
using a duplicate set, a corrupted set indicates that

Advertising