
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, arrays, 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 POKE type statements.
The upper 512 bytes of mem ory are 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 storage. Process variables 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 RAM is necessary. Additional RAM is
necessary when your program has large arrays and / or
string storage requirements.
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
RAM system.
STORING VARIABLES IN RAM
Program s and RPBASIC-52 variables reside in segment
0. Data is generally stored in segment 1 and higher (a
segment is 64K of memory). See memory map figure 5-
2. "Data Area" is segment 1 or higher.
PEEK and POKE commands store and retrieve values
from memory. For example:
20 POKEB1,12,A
puts the 8 bit value of A into segment 1, address 12.
Use the PEEK statement to retrieve the variable:
50 B = PEEKB(1,12)
Accessing reserved mem ory in a 32K RAM system is
accomplished as follows:
100 POKEB0,7E00H,C
120 B = PEEKB(0,7E05H)
The highest address in a 32K RAM system is 7FFFH.
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 elements:
Bytes Type Description
1 Byte Job counter
2 Word Analog output offset
6 Floating Correction factor
20 String Job name
Total number of byes required for each array is 30 (add
1 for a < CR> at the end of the string).
The Job counter is incremented every time it is
completed. Analog 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 Element to fill
310 CF = 23.432 Correction factor
320 JC = JC + 1 Job counter
330 AC = 25 Analog offset
350 GOSUB 1000
500 NO = 5 Element to retrieve