Remote Processing RPC-2350 User Manual

Page 29

Advertising
background image

CHAPTER 5

DATA MEMORY

5-3

A CAM BASIC progr am number and Flash segment
when using SAVE are related by the following formula:

SAVE segment = program + 8

K e ep tr a c k o f wh e r e y o u a r e wr i ti ng to . M o s t p r o gr a m s
will only use program area 0. Addresses above &9000
are alw ays available in any prog ram area. How ever, if
you have many program s, you will have to keep track of
where you are saving data to make sure a program does
not get clobbered.

LOAD is used to transfer data from Flash to RAM. An
e x am p le o f d a ta in c lu d e a r r ay s us e d i n C A M B A SI C .
This is explained further below.

Saving and Initializing Arrays and data
Sometimes it is convenient to save an array of
information to battery backed RAM and/or F lash for
retrieval later . T his is a handy way of storing “ recipes”
or tables of information for each job, customer , or
process.

A r r a ys a re in it ia l iz e d a n d f il le d by th e ba s ic p r og r a m .
Then, they are saved to either RAM or Flash EPROM.
The num ber and size of arr ays that can be saved is
limited only by available memory. The saved arrays can
be retrieved at any time.

How arrays are saved and retrieved depends upon what
kind of memory you ar e saving to and loading from. If
arra ys are sav ed to Flash , use SAVE . U se LOA D to
both save to and retrieve from RAM.

An exam ple of saving ar rays to R AM is shown in
ARRAY 1.BAS pr ogram, on the application disk. Saving
arrays to Flash is shown in ARRA Y2.BA S.
FL ASH .BA S shows str ings, bytes, and wor d saves to
Flash. ARRAY3.BAS is similar to ARRAY1.BAS
except it uses LOAD to transfer arrays. This makes
transfers faster.

Mapping your stored data
A frequent question is “Wher e do I store my data?” and
“How much do I have?” You have two places to store
data: RAM or Flash. How much you have depe nds upon
several factor s:

Expected program size
How much RAM and/or Flash memor y is free
W i ll yo u ne e d a s ec o nd p r og r a m ?
Amount of data to store
Type of data to store

How simple do you want to keep the program
How secure does the data have to be (where to store
data - Flash or RAM)
How often is information updated

E v e ry a pp li c at io n ha s a d if f er e n t s e t o f pr i or i ti e s. S o m e
program s are large, but only a few variables are stored.
Others, some data is critical and some are not. Start off
by determining what your storage requirements are (that
is, floating point numbers, integers, strings, screen
graphics.. .).

64K to 448K bytes of RAM are available, depending on
how U2 is popu lated. E ach data element type r equires a
differen t number of bytes. Use the follo wing table to
determine yo ur storage r equireme nts:

Type

Bytes of

storage

BASIC Commands

Byte

1

POKE & PEEK

Word

2

DPOKE & DPEEK

Float

4

FPOKE & FPEEK

String

1+ maximum
string length

POKE$ & P EEK$

Grap hic

32 - 9600
bytes

DISPLAY LOAD

Program
Size

1-32K

SYS(0)

The mathematics for keeping track of addresses can get
quite messy. It all depends upon your data structure. If
you are trying em ulate a struc ture in C or vector s in
JAVA, you will have some math to access the right data.

The demonstration program LOGGE R.BAS logs at over
2000 points using the structure below.

Suppose you are logging a process and need to store the
following types of information periodically:

N a m e

Type

Bytes

Date

String

9

T i m e

String

9

Temperature

Float

4

T i ck ti m e

Float

4

Level

word

2

First a dd up the total num ber of by tes needed. For this

Advertising