
RAM MEMORY
SECTION 5
Page 5-2 RPC -320
Figure 5-2 RPBASIC-52 memory map
RESERVED MEMORY
Many control systems use process variables that are
operator entered. "variables" in this context include
numbers, strings, ar rays, recipes, or formulas as applied
to your application. They are not a part of the variables
used by Basic. Process variables are accessed by PEEK
and POK E type statements.
The upp er 512 by tes of mem ory ar e set aside for this
purpose in a 32K RAM system. In 128K and 512K
RAM systems, all of the first 64K of RAM is used for
program and variable stora ge. P rocess var iables in these
larger versions are stored starting at segment 1 and
higher.
When the combined program and data size exceed 30K,
a 128K or 512K RA M is nec essary. Additional R AM is
necessary when your pr ogram has large ar rays and / or
string storage r equireme nts.
MTOP should not be used when variables are battery
backed for power off conditions. Basic clears all of
RAM in segment 0 (except for the last 512 bytes in a
32K system) at power up. Store process variables
starting at segment 1 or higher in a 128K or 512K RAM
system or start at address 7E00H, segment 0 in a 32K
R A M s ys te m .
STORING VARIABLES IN RAM
Program s and RPBASIC-52 var iables reside in segment
0. D ata is generally stored in segment 1 and higher (a
segment is 64K of memory). See memor y map figure 5-
2. "Data Area" is segment 1 or higher.
PEEK and PO KE commands store and retrieve values
from memor y. For example:
20 POKEB1,12,A
puts the 8 bit value of A into segment 1, addr ess 12.
Use the PEEK statement to retrieve the variable:
50 B = PEEKB(1,12)
Accessing reser ved mem ory in a 32 K RAM system is
accomplished as follow s:
100 POKEB0,7E00H,C
120 B = PEEKB(0,7E05H)
T h e hi gh e st ad d r es s i n a 3 2K R A M sy s te m is 7 F F F H .
Many times it is desirable to store an array containing a
"mixed" set of variables. Suppose you needed to save an
array m ade up of the following elem ents:
Bytes
Type
Description
1
Byte
Job counter
2
Word
Analog output offset
6
Floating
Corr ection factor
20
String
J o b n a m e
Total number of byes required for each array is 30 (add
1 for a < CR> at the end of the string).
The Job c ounter is inc rem ented ever y time it is
completed. A nalog output offset is an output constant or
other var iable used to initialize the outputs. Job name is
used with the display to identify a job.
For this example, suppose there are 20 of these arrays
that need to be set up. A program fragment is as
follows:
100 STRING 400,20 Initialize 20 string arrays
300 NO = 12
Elem ent to fill
310 CF = 23.432
Corr ection factor
3 2 0 J C = J C + 1
Job counter
330 AC = 25
Analog offset
350 GOSUB 1000
500 NO = 5
Element to retrieve