Remote Processing RPC-220 User Manual

Page 18

Advertising
background image

WRITING, DEBUGGING, AND SAVING PROGRAMS

SECTION 3

Page 3-7

SAVING YOUR PROGRAM TO FLASH

Your program is saved to flash EPROM when
development is done or when you wish to make sure a
program works proper ly.

Usually, but not alway s, the monitor is replace d. T his
means the save to flash feature will be gone UNLESS
y o u p u t i t i n y o ur p r og r a m . Se e " W R IT I N G C O D E
FOR U PDA TES" below for taking care of this situation.

You can put code or data in a portion of the flash using
the monitor save com mand. Howe ver, if you over write
starting at ad dress 0 to a bout 1900H , the monitor is
effectively destroyed.

The ' S' command transfer s the actual prom burning
routine RAM starting at address 0xff00 and executes
from there. M ake sure none of your program is located
in this area.

While pr ogram ming is in pr ogress, the letter ' P' is
printed for every 512 bytes program med (about 100
milli-seconds). The letter ' V' is printed on the next line
for every 512 bytes verified. If there is a verify error, a
letter ' E' is printed at the 512 byte block it was verifying
and the progr amming p rocess stops.

After verifying good, code jum ps to address 0. You
may wan t to press reset to simulate pow er on conditions.

Saving Process
You can use the monitor code (mon220.hex) to get a feel
for saving code. Save this code to an EP ROM address
not used (such as 0x4000). Then use the DP com mand
to view the contents of the EPROM.

The saving pr ocess consists of 2 steps:

First, down load code to RAM using the ' R' command.
Do not specify an offset. Begin saving at address 0.

Second, save to flash by e xecuting the ' S' comm and. Its
syntax is:

S RAM address, EPROM address, length

All parameters are in hex format. RAM and EPROM
address are usua lly 0. T he only re al figuring to do is
length. A quick w ay to check is fir st ' F' ill RAM with
all 0' s from 0 to 0x7fff. Down load the c ode. T hen use
the ' DX' comm and to view your cod e. W hen data is all
0' s, you can take the highest address and use it as your
length.

NOTE: The flash E PRO M is pr ogram med in 64 byte

blocks. The saving routine stops when the
length is rea ched. FF ' s are pr ogram med in
locations not specified to round out the block.

NOTE: Since the flash EPROM is programm ed in 64

byte blocks, you should star t on an even by te
boundary. An ' even' boundary is 0xXX00,
0xXX40, 0xXX80, or 0xXXc0.

WRITING CODE FOR UPDATES

Ther e are tw o ways to field update code . O ne metho d is
listed in the /LOADE R directory. There, a loader
program always resides in memory. You just set a line
low and the loader program is invoked. Programs are
stored starting at address 400H. Review the readme files
for more inform ation.

The second way is to embed a save routine in your code.
This is discussed further below.

A sam ple routine in FL ASH \P FL ASH .C is complete
code to prompt the field person to download and burn a
new pr ogram . It r eceives Intel H ex code, puts it to
RAM , uploads the flash burn program into RAM, and
runs it. How you get to this routine is up to you. You
could check a line status or check a password through
the serial port or any number of different mea ns.

In-circuit Reprogramming
The gen eral str ategy is to tem porar ily go into
development mode. The ROM code puts programm ing
code in RAM, sets the development mode bit, and jumps
to it. Sample code is under the "flash" direc tory.

Most likely new code is transferred through the serial
port. Y ou should allow for some character code or
sequence to put the card into programming mode. Using
the "FL ASH. C" pr ogram as an exam ple, the code
receives lines of hex, buffers them, and programs the
flash 64 bytes at a time. After program ming, the code
resets the development bit and jumps to CPU address 0.

You cannot read or execute from flash while it is writing
new data into itself. Ther efore, you must su spend all
other proc esses. M ake sure you tur n off interrupts.

Advertising