Chapter 3 saving and linking programs – Remote Processing RPC-2350 User Manual

Page 18

Advertising
background image

CHAPTER 3

SAVING AND LINKING PROGRAMS

3-3

SAVING DATA TO FLASH EPROM

Additional data, such as strings and constants, can be
saved to U3 using a variation of the SAVE comm and.
Exactly how much m emory you have depends upon how
many and how large of program(s) you have.

Flash sector size must be considered when saving. The
sector size determines the minimum write ar ea. Thus, if
you were to save just 1 byte, 128 (29C010A type) or 256
(29C04 0A) bytes w ill be written . A ll unwritten data is
s a ve d as F F H .

Font are stored starting at address &A C00, segment 9.
This is above program area 1. If space is tight, consider
using a 512K Flash.

Chapter 5 treats saving data to RAM and Flash more
extensively.

INSTALLING 128K OR 512K FLASH

Socket U3 can hold a 128K or 512K Flash EPROM.
Perform the following steps to install a a new Flash:

1)

Remove power from board and r emove existing
EPRO M from U3.

2)

Orient the new Flash so pin 1 is near the edge
o f th e bo a r d. I n st a ll th e IC .

3)

Set jumper W2 according to memory size:
W2[4-5]

128K (29C010A, 29C010)

W2[5-6]

512K (29C040A)

LINKING PROGRAMS

One CAMBASIC program can load and run another.
For example , the autorun p rogr am can , at so me point,
run the program in Flash area 1, which can then call the
original one. Using this technique, you can have
program sizes of nearly 70K bytes using a 128K Flash or
245K using a 512K Flash..

This linking is inten ded to be called occasionally
(although we have run programs that have linked
millions of tim es). For example , the second pr ogram is
a set up and ca libration r outine. This will fr ee up ma in
program RAM for variables.

Linking in CAMBASIC is not threaded code. It does
replace one program with another while keeping
variables.

When developing program s and testing for linking, make
sure you save any changes to Flash before running. Any
changes in program length, especially the first (autorun)
one, c an have adver se, str ange, or disastrous r esults.
When you have saved the changes, pr ess the reset button
to simulate an autorun. NEVER s ta r t w i th p r og r a m 1
(LOAD 1) then have it load program 0.

There are other do’s and don’ts, precautions and
limitations to linking. They are discussed below.

Program size
The first (autorun) program run MUST be larger than
the second, linked program. This is because variables
and data are stored above the program . If the second
progr am w as longer , it w ould wipe the m out. To simp ly
increase pr ogram size, add co mmen ts.

Multi-tasking
All multitasking (ON BIT, ON COM $, CO UNT, etc.)
and interrupts are disabled and multi-tasking data cleared
(hash table is zeroed out) when a program is linked.
You must re-enable them in your code. The reason for
this is the operating system stores the address (not line
number ) to execute. When you chan ge progr ams,
addresses change.

You can save some selected data by writing it to a
variable. For example, the current count can be saved
just before you LOAD 1 RUN. You will need to re-
e n ab le th e co u nt w he n yo u en te r th e pr o g ra m .

DATA statements
Use RESTOR E to reset the DATA statement pointer
every time you enter a program (if you are using DATA
statements).

Linking within the program
To link to ano ther pr ogram , ex ecute

LOAD n RUN

o n it s o w n l in e . D o n o t p u t a n y o th e r co d e a f te r it . D o
not make it as part of a c onditional statem ent, as in

IF A = N THEN LOAD 1 RUN

If you link within a subroutine, DO. .U NTIL, or
F O R . . N E X T , e x ec u te E X IT C L E A R be f or e L O A D .

.
.
2250

GOSUB 7000

Advertising