Sunteți pe pagina 1din 3

MONITOR-51

for the 8051 family


Overview
MONITOR-51 is a simple system that provides functions for the debugging of embedded systems of any 8051 derivative,
without the need for explicit hardware systems; such as an emulator.
The monitor is derived from C and assembler files, that can be associated (by linking) with any project. During
debugging it provides the following simple functions:

display of the main registers and the Program Counter (++PC),


display of memory blocks on all addressable spaces,
byte by byte modify,
execution in step-by-step mode,
setting and clearing of breakpoints
Source files are included in the product delivery to permit quick and easy modification of the Monitor to accommodate
application constraints or limits.
Monitor-51 is best used when downloaded into an EPROM emulator. These are available from many sources.

Principle
MONITOR-51 is called via a serial interrupt. In order to prevent interferrence with normal serial I/O, the PUTCHAR()
function filters all characters received. Execution begins when PUTCHAR() encounters a predefined escape sequence.
The default setting of this sequence is !!. The monitor is launched, and through the use of menus, presents a list of its
debugging functions. When Monitor functions are complete, the Monitor returns to the execution point.

Description of files
MONITOR.C
MONITOR.C is the main file. It contains the activity management menus, and the debugging routines.

MON_IO.C
MON_IO.C contains the I/O functions: GetVal and SetVal.

PUTCHAR.A51
PUTCHAR.A51 contains a modified version of the standard Putchar() and Getchar() functions. It also contains
the serial ports interrupt handler.

Implementation
Using the ProView project manager, it is possible to include these three files into your existing project. This permits the
monitors debug facility to be applied to the project under development. In addition, the target program must call the
MonitorInit() function. This will initialized the monitor and prepare it for use.
When the monitor gets launched, a dialogue is established via the serial connection. Any terminal (such at Hyper
Terminal for Windows) can be used for interface and control of the monitor. It is helpful to choose a non-proportional font
such as Courier New.

Limitations
Some limitations and precautions have to be observed:

C files can be compiled in only the SMALL or LARGE model. Compact in NOT recommended, and not
supported. However, in the SMALL model, you must be aware of the stack size requirements. Note that
both printf() and scanf() are called by the monitor. These functions are reentrant and could consume
unexpected amounts of memory.

If the application intensively uses the serial port to transfer binary data, then filtering for the repetition !
character is probably not the best way to call the monitor.

The monitor interrupt must be enabled.

Debugging Commands
Inspect
To use the INSPECT command you must first specify which memory space is to be examined. This is
communicated with the letter C for Code, X for XData, D for Data, S for Sfr addresses, and B for Bit
addresses. The letter code is followed by the hex address to be displayed, optionally followed by the number of
characters to be displayed. A <CR> is used to terminate input and initiate the command. All data is displayed in
hexadecimal.

Modify
To alter the value, you must specify the letter X for XData, D for Data, S for Sfr addresses, and B for Bit
addresses. The letter code is followed by the hex address to be modified, and the value to be written. A <CR> is
used to terminate input and initiate the command.
NOTE: It should be obvious, but please accept this reminder that it is not possible to modify a Code byte.

Step
One assembly instruction will be executed before returning to the monitor.

Breakpoint
Principle
Since they are inserted into the source code, breakpoints must be set before downloading. Their action is to set
a software interrupt that will call the monitor. This method was chosen to minimize the size and intrusiveness of
the monitor.
Place the following macro in your sources to generate a breakpoint:
#define BREAKPOINT { flag_Step = 1 ; TI = 1 ; asm { 0, 0 } ;}
The asm{ 0, 0} semantic will generate two NOPs.

S-ar putea să vă placă și