Remote Processing RPC-220 User Manual

Page 19

Advertising
background image

WRITING, DEBUGGING, AND SAVING PROGRAMS

SECTION 3

Page 3-8

WRITING FOR C

Mem ory Models
Most C compilers have different memory models. They
are usually referred to as SM ALL, COM PAC T, and
LAR GE. The D unfield com piler has 5 m odels while
Keil has 3. The differ ences betw een the m emor y models
have to do with where and how much data is stored and
how they are accessed. When selecting a memory
model, do not select one where code and data are
overlapped into a single 64K address space.
Do not use the SMAL L or CO MPA CT m odels in the
Dunfield compiler. The TINY, MEDIUM, and LARGE

models are OK.

Memory Use
Most pr ogram s written f or 8051 C PUs requir e relatively
little RAM for control (data logging does require a lot
more). C compilers use both internal and external RAM
to store variables. Internal RAM is faster to access,
although there is much less of it. You have about 32K
of extern al RAM for var iable space du ring deve lopment.

Set up your com piler so external R AM star ts at address
0x0000. During dev elopment, you can use up to addre ss
0x7FBF. Addresses 0x7FC 0 to 0x7FFF are used by the
monitor . A ddresse s 0x8000 to 0xF FF F is wh ere cod e is
executed in R AM . A ll of RAM in segmen ts 1-7 is
available for data storag e, a lthough this is not dir ectly
supported by the compiler.

The RP C-220 c an access up to 512K of RA M. This is
done by selecting a RAM segment the reading or w riting
to it. See ME M220. C under M EM220 dir ectory,
functions speek, spoke, spokew, speekw for exam ple
access.

Other Considerations for Writing and Saving

P r og r am s

Starting address
All demonstration program s use a starting address of
0x8000. You can put programs into RAM anywhere
from 0x8000 to 0xff00 (the last 256 bytes are used by the
SAVE com mand).

Interrupts
The monitor ROM vectors all interrupts to RAM.
Simply add 0x8000 to the C PU' s interrupt base addr ess.
When an interrupt is serviced, the monitor ROM vectors
off to RAM. The jump code in RAM then jumps to the
appropriate location. When compiling for the final
version, the jump co des in RA M ar e replac ed with

vector addresses only.

Reprogram ming
See "WR ITING C ODE FOR U PDA TES" above for
more inform ation.

USING DEMONSTRATION PROGRAMS

Demo programs and batch files were written for
Dunfield Development systems C compiler. A freeware
assembler, ASM51, is included and is in the root
directory. If you use another compiler you must modify
the code accordingly.

Demo nstration progr ams are in separate director ies.
Each directory has source, output (hex), and batch files
for C. All are ready to run.

Batch and sour ce files assum e the Dun field comp iler is
used. Switches used in the command line may not work
with other compilers or assemblers. When you order a
compiler or development system fr om us, w e will send
you library and include files to make the start up code.
In general, startup code wa s modified to instruct the
compiler wher e to begin assem bly and include interru pts
particular to the CPU type used.

PROGRAMS LARGER THAN 32K

The largest program that can be developed on the
RPC-220 is 32K. This is because the RAM allocated for
development is 32K and the flash EPROM is 32K.
It is possible to develop and put up to 64K of code in the
RPC-220. You must do three things to make this happen:

1

Use an EPR OM em ulator. Rem ove the flash from
U3 and install the emulator. Set the emulator for a
64K EPRO M (27C512). Make sure you m ake the
modifications described in 2 below.

2

Cut a trace (write line) on the circuit side to Jumper
W5. Refer to Figure 3-3 below.

Advertising