FLASH MONITOR 52

A software Debug Monitor for the 8051

FMO 52 English Tech. Manual PDF format.

Ver.5.00 - Rel.. 07 March 2003.


I N D E X

FMO52 TABLE OF CONTENTS

1. INTRODUCTION

2. USING FMO52

3. Using FMO52 through GET 51

4. Using FMO52 through BASCOM LT; BASCOM-8051


1. INTRODUCTION

FMO52 is an interactive software debugger and machine language monitor forthe Intel 8051 family of microprocessors which allows to Debug the user program inthe RAM memory area from 2050H to 7FFFH, splitted in code area and data area.

If code is compiled to run in the Flash memory area, addressed from 8050H to DFFFH, the whole RAM memory area from 20C6H to 7FFFH becomes available for user data, this happens in AUTO RUM mode.

FMO52 contains display/alter memory/register facilities, as well as a full 8051 disassembler,
breakpoint, software single step functions, RAM test, Flash erase, user program Flash programming and execution functions, in AUTO RUN mode, selectable by DIP-SWITCH or Jumper at startup.

FMO52 requires the presence of an ATMEL 29c256 Flash memory for the complete management of the user program programming and execution and emploies a small fraction of the on-board hardware resources.

Currently FMO52 uses the serial line to communicate with the developement P.C., 80 bytes of external memory (from 2000H to 204FH) for its own variables, 6631 bytes of ROM code and TIMER1 to generate the baude rate for serial communication and to manage the single step execution.

To be able to download the user program from the development P.C. and set its breakpoints, FMO52 has to write data in the code area. As the 8051 architecture does not allow such operations when using separated data and code areas, RAM area where the program is downloaded must be addressable both as data and as code (logical AND with /PSEN and /RD).

Memory mapping:

Please refer to paragraph 2.6 FMO52 Configurations for GPC® xxx

FMO52 preserves the entire contents of registers and internal RAM when passing control back and forth to the user program. This allows the user program to operate as if it were running "standalone" without fear of conflicting with FMO52.


2. USING FMO52

2.1 Monitor Commands

The following commands are implemented in the monitor:

A <address>

Alter INTERNAL memory. FMO52 prompts with the specified address and its current contents. You may enter TWO hex digits to change its value, SPACE to advance to the next location, BACKSPACE to backup to the previous location, or CARRIAGE RETURN to terminate the Alter command.

B <breakpoint#> <address>

Set breakpoint at specified address. Breakpoint is removed if address is 0000. There can be up to four breakpoints, which are referenced by the numbers 0-3. If SPACE is entered instead of a breakpoint#, the currently set breakpoint addresses are displayed.

NOTE: The 8051 family of processors does not have a single byte transfer instruction such as is normally used to implement breakpoints. Breakpoints are handled by inserting 'LCALL' instructions into your code during the processing of a 'G' command and restoring the code in the
breakpoint handler. Each 'LCALL' occupies three bytes of memory, which causes the following restrictions when using breakpoints:

You MUST be careful to place breakpoints in locations where there will NOT be any JUMPs or CALLs to the addresses containing the second and third bytes of the breakpoint. For example, if you set a breakpoint at address 1234, there should NOT be a label in your program occuring at address 1235 or 1236 (Note, a label at 1234 is OK).

You may not set breakpoints that are within three bytes of each other. The message 'Breakpoint conflict' results if you attempt to do so.

Attempt to 'G'o at an address containing a breakpoint will also result in the 'Breakpoint conflict' message. This will most commonly occur when you wish to resume execution following a breakpoint. In this case, you must either remove the breakpoint, or use the 'S'tep command to advance the program counter until it is NOT positioned over any part of a breakpoint (Remember, breakpoints are three bytes long).

C <register> <value>

Changes 8051 registers values. Register is a single character, which may be as follows:

A - Set Accumulator ( 8 bit value).
B - Set B register ( 8 bit value).
D - Set DPTR (16 bit value)
S - Set stack pointer ( 8 bit value).
P - Set program counter (16 bit value).
W - Set PSW ( 8 bit value).
0-7 - Set R0-R7 in current register bank (8 bit value).

D <start>,<end>

Displays EXTERNAL DATA memory, in HEX/ASCII dump format, starting at the indicated address. If a SPACE is entered for <end> address, assumes FFFF.

E <address>

Edit's EXTERNAL DATA memory, Address and contents are displayed, Enter TWO hex digits to change value. Entering SPACE skips to the next location, BACKSPACE backups to the previous location. CARRIAGE RETURN terminates the edit command.

F <start>,<end> <value>

Fill's external memory from <start> to <end> with the byte <value>.

G <address>

Begins execution at the indicated address. If a SPACE is entered instead of an address, begins execution at the address in the 8051 program counter.

H

Enables the use of the Flash programming related commands, such modality is indicated
by the prompt shape, if '*' is printed then you are working in debugging mode, while
if the '&' character is printed then the Flash related command are enabled (the
different situation influences the command L):

W Flash writing, copy of the RAM content from 2050H to 7FFFH, into
the Flash memory from 8050H to DFFFH.

X Erasing of the whole content of Flash memory.

I <start>,<end>

Displays the contents of INTERNAL memory between the specified addresses.

L

Downloads data from the console port, which may be in either MOTOROLA or INTEL hex format.
If you accidently enter this command, you may enter either 'S9' or ': 00' tosignify a null download file and return to the command prompt.
If the prompt shown is '*'then the code downloaded will be used in debugging mode, while if the prompt is '&' then the code will be used to program the Flash memory, in fact during the download the file will be reallocated 6000H bytes backward (6000H is the offset between RAM and Flash), this will make possible the Flash programming.
On startup the user program will be automatically executed from Flash memory if AUTO RUN mode is enabled (see 2.4).

R

Displays the current values of the 8051 registers (A, B, DPTR, SP, PC, PSW and R0-R7).

S

Single-Steps one instruction from the current 8051 Program Counter address. Disassembly of the instruction stepped is displyed on the console.
The use this command involves the loss of TIMER1 overflow interrupt, as this is redirected to the RAM memory 201BH, 201CH and 201DH locations

T

A complete RAM test is performed from 2050H to 7FFFH. This command alters definitely the RAM content, after having used it we suggest you to reformat the RAM content with value 00H by a F command. (Example: F 2050 7FFF 00)

U <start>,<end>

Un-assembles PROGRAM memory, starting at indicated address. If SPACE is entered for <end> address, assumes FFFF. Disassembler output contains address, opcodes bytes, instruction neumonic, and operands to instruction.

?

Displays a short help summary of the commands.


2.2 Display Output

In order to maintain the maximum amount of data on the terminal screen during he debugging session, FMO52 has been designed to minimize the number of screen lines in any display. All commands which output only one line of data (such as 'B' and 'S'), will do so on the same line on which the command is issued (To the right of the command).

For commands which output larger amounts of data (such as 'D', 'U'), pressing the SPACE key during the display will halt the display on the next line. Each subsequent SPACE entered will cause one more line of data be displayed. Pressing CARRIAGE RETURN will allow the display to continue at full speed.

The escape key may be used to cancel command output, and return to the '*' or '&' prompt.


2.3 Interrupts

FMO52 re-vectors all interrupts (except for TIMER1 OVERFLOW which is used internally for single-stepping and takes three more RAM memory locations, see command 'S') to the corresponding locations in the first page of user RAM.
When a user program happens to use interrupts it will just have to allocate them in the user RAM, that is to sum to each of them the starting address of such RAM.
Interrupt response procedures should not be changed.

When the user program is executed in AUTO RUN mode, FMO52 copies the interrupt vectors from Flash to RAM before running the program. In detail, the vectors are copied from 8050H - 80C5H to 2050H - 20C5H, to have the same configuration as in debugging mode.


2.4 Flash programming and AUTO-RUN mode

FMO52 receives files for execution in debugging mode or for Flash programming. The debugging mode is indicated by the '*' prompt, in this mode the downloaded file(s) are stored in 2050H - 7FFFH RAM memory area, so the program and its variable MUST be able to fit in this area.

Flash programming abilitation is indicated by the '&' prompt, see command H for toggling it, in this mode the downloaded file(s) will be stored in the 8050H - DFFFH Flash memory area, the file(s) will be temporarily stored in RAM waiting for the W command to copy them into the Flash memory, so the source code must be compiled with origin 8050H before downloading it.
On startup FMO52 checks whether Flash memory has been succesfully programmed, if so detects the AUTO RUN mode abilitation, this abilitation is given by a DIP-SWITCH or a Jumper (see paragraph 2.6), then executes the user program stored in Flash memory, in this case the user available RAM is addressed form 20C6H to 7FFFH.


2.5 Flash programming by user program

The Flash memory area is divided into three parts:

This free memory area is available to the user in 64 bytes blocks during AUTO RUN mode by a CALL stored at the address 1A00H which uses 12 bytes of stack.
To correctly use this procedure you must previously set the value of some memory locations:

To know about the effect of the last call to this procedure, you should check the value stored in 2043H according to this table:

Example: to write in the block 1 of the Flash memory 64 timesthe value 0:

 DATA

 Block

 Check Sum

from 2001H to 2042H

00H.......00H

2043H

01H

2044H

02H


2.6 FMO52 configurations for GPC® xxx

The previous descriptions are valid for each 8051 based card while in this paragraph the information relative to FMO52 use on grifo® boards, are listed:

COMMUNICATION :

BOARD NAME

 Memory Mapping

Mapping Selection

EPROM

RAM

FLASH

AUTO RUN

Jumper Memories

GPC® 323

MODE 1

 DIP5=On DIP6=On

IC5

 IC4

IC3

 DIP8=On

J4=1-2 J5=1-2 J2=1-2 J3=wire 2-3 J2

GPC® 323D

MODE 1

 DIP5=On DIP6=On

 IC5

 IC4

 IC3

 DIP8=On

 J4=1-2 J5=1-2 J2=1-2 J3=wire 2-3 J2

GPC® 324

MODE 3

 DIP5=On DIP6=On

 IC8

On Board

 IC5

 J1= Connected

 J4=1-2 J5=wire 2-3 J4

GPC® 324D

MODE 3

 DIP5=On DIP6=On

 IC8

On Board

 IC5

 J1= Connected

 J4=1-2 J5=wire 2-3J 4-2

 GPC® 552

MODE 1

 J1=3 J2=3 J14=1,2,3 ASM

 IC15

IC13

 IC12

 DIP8=On

 J18=1-2 J17=wire 2-3 J18

 GPC® 553

MODE 3

 DIP5=On DIP6=On

 IC1

IC2

 IC3

DIP8=On

 J4;J5=1-2 J2=1-2 J3=wire 2-3 J2

 GPC® 554

MODE 3

 J1= Connected J6=2-3

 IC4

On Board

 IC6

 J2= Connected

 J3=1-2 J4=wire 2-3 J3

 GPC® R63

MODE 3

 J1= Connected J3=2-3

 IC7

On Board

 IC10

 J1= Connected

 J4=1-2 J3=wire 2-3 J4

 GPC® T63

MODE 3

 J1= Connected J3=2-3

 IC7

On Board

 IC10

 J1= Connected

 J4=1-2 J3=wire 2-3 J4


3. Using FMO52 through GET 51

To configure GET 51 executing the command line GET51 /I.
Set the appropiate COM port, set the Baud rate to 19200, set the M/DP-(F)MO52 terminal then press install.
It is now possible to run the program executing the command line GET51, press ALT T, connect the board, supply it, the starting message of FMO52 Rel.1.1 monitor should appear, to DOWNLOAD a file press F8, select a file.HEX with origin from 2050H.
Wait a few seconds for the visualization of the message:

xxxx Bytes
*

xxxx indicates the amount of bytes downloaded rounded up to the first multiple of 16 (decimal) or 10 (hexadecimal).
To run the program type the command "G 2050".


4. Using FMO52 through BASCOM LT/8051

When a BASCOM LT source program is compiled, it is produced an HEX file that contains the machine code for the used microcontroller.
This file must be burned into an EPROM or into microcontroller internal ROM, but if the source program is still in the debug phase and it is not completed, it becomes necessary to repeat the burn operation for many times. This involves a big quantity of used time and uncomfortable component replacement.
To simplify the described debug phase it is sufficient to install the FMO52 monitor on GPC® xxx, see Paragraph 2.6.


4.1 Generating file.hex through BASCOM LT/8051

The following compiler directives must be specified at the beginning of the BASIC source program:

GPC® board with 22.1184 MHz quartz
$crystal = 22118400 ' Microcontroller clock frequency
$baud = 19200 ' RS 232 communication baud rate

$romstart = &H2050 ' Code area start address
$ramstart = &H6000 ' Data area start address
$ramsize = &H1FFF ' Data area size = 8K

$large ' 16 bit addressing mode
'***************** Program start **********************
Waitms 1 ' Delay for signal adjustement
..... ' Program main
.....
End ' Program end
..... ' Possible program procedures

In addition select "Option"|"Compiler"|"Misc" then pick "Register file" according to the following table:

Board

Register File

 GPC® R63  8052.DAT
 GPC® T63  8052.DAT
 GPC® 323  87C520.DAT
 GPC® 323D  87C520.DAT
 GPC® 324  87C520.DAT
 GPC® 324D  87C520.DAT
 GPC® 552  80C552.DAT
 GPC® 553  80C552.DAT
 GPC® 554  80C552.DAT


4.2 Generating file.hex for AUTO RUN, through BASCOM LT/8051

At the beginning of each source code, replace the following compiler directives:

Compile the program, execute commend H, download the program and copy it into the Flash memory by the command W.


4.3 How to configure BASCOM LT/8051 for DOWNLOADING files to FMO52

La version of BASCOM LT/8051 MUST be at least :

BASCOM LT configuration:

BASCOM 8051 configuration:


4.4 How to DOWNLOAD

Compile the BASCOM LT source program through the opportune option ("File"|"Compile" for BASCOM LT, "Program"|"Compile" for BASCOM 8051) and if no errors are detected, open the terminal emulator window through the opportune option ("File"|"Terminal emulator" for BASCOM LT, "Tools"|"Terminal emulator" for BASCOM 8051).
When this windows is active, connect the primary serial line of GPC® xxx to the preselected PC COM line and power supply the card; at this point the power on message of FMO52 will be displayed inside the window.
Now the download can be executed through the opportune option of the terminal emulator window ("File"|"Send" for BASCOM LT, "File"|"Upload file" for BASCOM 8051), wait some seconds until the message:

xxxx Bytes
*

is displayed. The xxxx value indicates the number of downloaded bytes and it coincides with the length of the compiled code, rounded to next 10H multiple.
To execute the downloaded code, digit the "G 8050" command.


Last Up-dated at March 13, 2004 - Rel.1.3


homeHome Software Tables