CMD-5xx 08/07/02
8
Programming the Onboard Flash Memory
After testing your program running out of RAM you will probably want to program it into EEPROM so that it starts whenever
power is applied to the board. To do this you must first change the starting address of your program to match that of the memory
device being programmed. This is usually done in assembly language using the ORG statement, or by MAK or Project file
arguments to the LINKER if using a compiler.
As an example, a version of the "hello world" program is included on the support CD that has been relocated to start at address
0x400000. This will be the starting address assigned to external onboard flash memory, once we move some jumpers and reset the
board.
This version is called "
HELLO_F
". It uses the same HELLO.C and SERIAL.C source code as the RAM version, with the following
unique files:
INIT.S
Example Boot initialization assembly source file
HELLO_F.DLD
Diab Linker script - specifies the programs memory organization
HELLO_F.BAT
DOS batch file used to build the program
The output files produced from this build are called
HELLO_F.S19
and
HELLO_F.ELF
.
Follow these steps to program the "hello world" example to start on power-up instead of the monitor program:
1.
Make sure the
MAP_SW
positions 2 and 7 are only on. This will configure the board to match the default Memory Map.
2.
Make sure the
MEM_EN
jumper is installed and press RESET to get the utilities menu (see Getting Started).
3.
Select External Flash Programming from the menu.
4.
Select
2
for External Flash (U13/U14) - CS2.
5.
Select
1
to Erase the Flash Memory. This should take less than 20 seconds.
6.
Select
2
to Program from a file -> Flash CS. This will prompt you to upload the file to be programmed.
7.
Select the send text file (or upload) command from your terminal program and locate the file named "
HELLO_F.S19
"
included on the support CD and send this file to the board. If you have problems uploading, try adding a pacing delay.
8.
After all lines from the file have been programmed, the words programmed are displayed along with any errors, followed
by the menu again. Now the "hello world" program is at address 0xC00000 (the current location of onboard flash),
however it is linked to be run from 0x400000, since this is the address the program assigns to the CS0 base register at
runtime.
Explanation
: Since the monitor EPROMS in U15/16 use the same Chip Select 0 that we wish to use for the "hello world"
program (by the setting of the MEM_EN jumper), we must do an offset programming operation to a different chip select.
Setting the MAP Switch position 7 on configures the onboard flash to Chip Select 2. The monitor program will offset the
program to that chip select base address (0xC00000) temporarily during programming.
9.
Power down the board and move the MODE_SW1 switch 5 to the OFF position. This will configure the board to 32-bit
mode boot, which is required for the onboard flash memory to boot while in the 32 bit wide mode.
10.
Remove the MEM_EN jumper and change the MAP Switch to position 7 OFF and position 5 ON.
11.
Power up the board. You should see the "hello world" message on your terminal screen every time you press a key.
12.
To return to the Utilities Menu, turn power off the board, move the MODE_SW1 switch 5 back to ON, install the
MEM_EN jumper, and set the MAP switch position 5 OFF and position 7 ON. Power on the board and you should see
the menu again.
Although this "Hello World" example is a simple program, you can use the same procedure for programming your own application
into external flash memory using the CMD-5xx development board.
To develop more complex applications, with source level debugging, you will no doubt require a debugger tool. An excellent
choice would be a Background Debug Module (BDM) which is supported using the BDM-PORT on this board. See the "Using a
BDM" section of this manual for more information. Follow these steps to program the "hello world" example to start on power-up
instead of the monitor program: