Remote-processing RPC-2350 Manuel d'utilisateur Page 29

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 83
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 28
CHAPTER 5 DATA MEMORY
5-3
A CAM BASIC program number and Flash segment
when using SAVE are related by the following formula:
SAVE segment = program + 8
Keep track of where you are writing to. Most programs
will only use program area 0. Addresses above &9000
are always available in any program area. However, 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
example of data include arrays used in CAMBASIC.
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.
Arrays are initialized and filled by the basic program.
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 are saving to and loading from. If
arrays are saved to Flash , use SAVE . U se LOA D to
both save to and retrieve from RAM.
An exam ple of saving ar rays to RAM is shown in
ARRAY1.BAS program, on the application disk. Saving
arrays to Flash is shown in ARRAY2.BAS.
FLASH .BA S shows strings, 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 “Where 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 depends upon
several factors:
Expected program size
How much RAM and/or Flash memory is free
Will you need a second program?
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
Every application has a different set of priorities. Some
programs 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 populated. E ach data element type r equires a
different number of bytes. Use the following table to
determine your 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$ & PEEK$
Graphic 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:
Name Type Bytes
Date String 9
Time String 9
Tempe rature Float 4
Tick time Float 4
Level word 2
First add up the total num ber of bytes needed. For this
Vue de la page 28
1 2 ... 24 25 26 27 28 29 30 31 32 33 34 ... 82 83

Commentaires sur ces manuels

Pas de commentaire