Remote Processing RPC-2350 User Manual

Page 32

Advertising
background image

DATA MEMORY

CHAPTER 5

5-6

default values (from 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 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 E' d) in three different place s.
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.

Upon reset, the calibration value is checked. If the value
at address 0 agrees with address 100 and 200, then no
corruption occurred. When address 0 and 100 agree but
not 200, then this indicates tha t a reset occ urre d while
updating the third set. The first data set can be trusted.
The third data set simply needs to be updated.

When the first two sets do not agree, then you know that
the first data is corrupted. If the second and third set
agree, then, depe nding upon the system r equireme nts,
the first set could be "corrected" using the old data. The
user or other device could be alerted that a calibration
(or other ) must be pe rfor med aga in. W hen all thre e sets
disagree, then you must take action appropriate to the
situation.

Another technique to ch eck for v alid mem ory is
checksum s. Sim ply write a progr am to add the values in
RAM and compare it against a number is a good check.
However, you cannot tell which data element was
corrupted.

Instances of data corr uption are rar e. T hey do increase
as the boar d power is cycled or reset.

ASSEMBLY LANGUAGE INTERFACE

A s se m b ly la n gu a ge p r og r a m s ( in c lu d in g co m p il e d C )
must start from segment 0. Use the CAMBASIC CALL
s ta t em e n t t o e x ec u te a n a s se m b ly la n gu a ge p r og r a m .

A specific area of RAM should be reserved for the
program . This is to prevent strings and variables from
corrupting that area of RAM . U se the SYS(1) and
SYS(2) statements to do this. SYS(1) retur ns the lowest
memory location while SYS(2) returns the upper
location. Run the pr ogram first to ma ke sure v ariable

memory has been allocated before running these SYS
comm ands. F ailure to do so may r esult in address
returned that are not really free for assem bly language
program s.

There are sever al ways to put a program in mem ory,
depending upon your application.

1.

Use D ATA statements a nd PO KE the co de into
segment 0 RAM.

2.

W r i te a pr o g ra m to d ow n lo a d c o de . S om e
applications are connected to a larger system which
"initializes" its systems. Using INKEY $ or COM $,
code is received and then poked into memory using
POKE$.

3.

Read the code from the EPROM (U3) (using INP)
and transfer it to RAM (using PO KE).

4.

Some space is available in the CAMBASIC ROM.
Space fr om abou t 6B00H to 6F FF H is availab le in
version 1.4 of the 2350G boar d. The star ting
address will proba bly change in the future w ith
different CAMBASIC versions. You may burn
your assembly language program in U1 and CALL

i n f r om B A SI C .

5.

Space is available in the Flash EPROM. In theory
you can run directly from Flash. This involves
running in sectored areas unique to the Z180.
However , this is probably more effort. Use the
Flash to stor e the prog ram and then tr ansfer it to
RAM segment 0.

I n al l c a se s , it is b es t t o l oa d co d e i nt o R A M f r om a
"secure" source, such as F lash EPROM . Even though
RAM is battery ba cked, over tim e there is the possibility
it could be corrupted.

Below is an exa mple of loa ding and r unning an asse mbly
l a ng u ag e pr o g ra m .

100 FOR N = &FB00 TO &FB0C
110 READ A
120 POKE N,A
130 NEXT
900 DATA &DB, 2, &47, &E6, &FE, &D3
910 DATA 2, &78, &F6, 1, &D3, 2, &C9

2000 CALL &FB00

Lines 100 to 130 load the program into RAM. DATA
statements may be entered manually.

Advertising