The Monitor inputs commands, translates them from ASCII to a binary format, and sends them to the 8051 Kernel. The kernel stores and interprets [executes] these commands and sends the results back to the Monitor.
The communication protocols are the formats used for exchanging messages and data between the PC and the 8051 during this process. The protocols do not currently include error checking such as checksum or cyclic redundancy check [CRC]. These are however a part of the system design and will be incorporated.
In this initial version of the system, commands come
only from the keyboard and results are always displayed. The system design
however, calls for commands to come from any source, such as another program,
and for the results to be redirected to any target, possibly also another
program.
As a general principle, the Monitor accepts responsibility for minimizing the workload of the Kernel by, for example, translating commands and storing character string information in the PC.
A command is a sequence of single, case-insensitive
alphabetic characters, and hexadecimal numbers in the range 0000h to 0ffffh. A
typical command entered at the keyboard might be:
b i 20 10
This is a view memory in binary command; it requests display of 10H bytes in
binary format, beginning with address 20H, from the indirectly addressable
[IDATA] memory segment.
PC to
8051 Protocol
The protocol for sending such commands to
the 8051 Kernel is:
● Byte 0: number of bytes following this one
● Byte1 to Byte n: 1 byte for each alphabetic character, 2 bytes for each number; byte 1 typically represents an alphabetic command, with the following bytes being operands
● Maximum byte count for a block is 255
Alphabetic characters are translated into arbitrary even numbers to facilitate their interpretation by the Kernel. In the 8051 assembler code this structure is programmed with a jump table, and can be readily extended.
The above command is translated into the following byte array for sending:
Byte Number Value Interpretation Comment
0 06h Message length 6 bytes follow this one
1 02h Command code b = 02
2 04h Operand-0: i = 04
3 00h Operand-1: high byte of 0020h
4 20h Operand-2: low byte of 0020h
5 00h Operand-3: high byte of 0010h
6 10h Operand-4: low byte of 0010h
The Kernel does not interpret the command as the bytes arrive; rather, it stores the bytes in an array in IDATA memory and interprets the command after having received the entire message. The format of the message is implicit in the command code.
8051 To PC
Protocol
The results are returned to the Monitor with the following protocol:
● Byte 0: total number of bytes in this message including this one; error if not greater than 2; maximum 255
● Byte 1: a code instructing the Monitor how to interpret the following byte stream
● Bytes 2 to n: the data bytes; for the view memory commands bytes 2 and 3 are the address of the first data byte being returned
In the Visual Basic code, the logic is programmed with a switch statement, and
can readily be extended.
The results of the above view memory in binary command are returned to the
Monitor as:
Byte Number Value Comment
0 14h 02h+02h+10h
1 04h value for b command
2 00h high byte of 0020h
3 20h low byte of 0020h
4 to 13h xxh Data bytes to be displayed in binary
The monitor interprets this data stream to display the data bytes in binary, in a traditional dump format, with the address of the low byte on the left, and the next 4 values to the right.
MultiMIPS 8051 Monitor
Utility Procedures
Command Interpreter
Byte Stream Interpreter
Command Summary
Utility
Procedures
The utility procedures are the parts of the Monitor program that give it form
and function. These procedures are embodied in the menu and toolbar facilities.
They allow the user to:
● input commands using toolbar buttons and textboxes in addition to the keyboard
● choose a serial port and baud rate on the PC
● connect to the microcontroller either through a direct cable or through a modem
● open and close the port
● manage a log file
Command
Interpreter
The command interpreter is a Visual Basic KeyPress() procedure. It receives
keystrokes as ASCII codes, echoes them to the screen in a Visual Basic textbox,
and translates them into the Bytes() array which it sends to the 8051 via a
serial port. This procedure waits until the entire command has been entered and
translated before sending it to the 8051.
As a procedure, the command interpreter receives ASCII codes but is unaware of
their source. Consequently, it satisfies the design requirement of being
independent of the keyboard as a source of commands. Commands can therefore,
come from other sources such as another program. It remains only to provide a
mechanism through which other programs can access this procedure.
The logical structure of the command interpreter is a switch statement with the
following choices:
● the enter key, interpreted as the syntax character, and then as the end of the command
● the space character interpreted as the syntax character
● the digits 0 through 9
● the case insensitive letters a through z, with the subset a through f being interpreted as numeric if a leading numeric is present
● the backspace character, interpreted as terminate interpreting this command
● the remaining default is interpreted as an error
Byte
Stream Interpreter
The byte stream interpreter is a logical extension of the Visual Basic OnComm()
procedure. It receives the stream of bytes from the serial port, interprets it,
and displays the results on the screen in a set of Visual Basic text boxes.
As a procedure, the byte stream interpreter receives the stream of bytes but is
unaware of its source. Byte streams can therefore come from some other
microcontroller such as 68HC11.
The logical structure consists of a process to interpret the header of the byte
stream, and a switch statement to process the byte stream based on the mode
byte. This procedure waits until the entire byte stream has been received
before beginning the interpretation process.
Command Summary
Command Syntax
A command is a series of alphabetic and numeric characters separated by space
characters, and terminated by the Enter key. Any characters other than
alphabetic, numeric and the Enter key are treated as errors. Alphabetic
characters are case insensitive; they occur singly only so are normally
followed by a space character. To facilitate the interpretation of commands by
the Kernel, alphabetic characters are translated into even numbers known by the
Kernel. Numeric characters are always considered to be hexadecimal numbers in
the range [0000 through 0ffff]; if the first digit would be in the range [a, b,
…, f] then it must be preceded by a leading zero. Commands can originate either
from the keyboard or from some other source such as a program.
General Commands
r: reset or restart the 8051
If the watchdog timer is enabled the Kernel will reset the 8051; otherwise it
will restart from program memory location zero. The Kernel banner is displayed
by the Monitor if this process is successful.
m: monitor inquiry
The Kernel responds with the information needed by the Monitor to display the
Kernel banner.
View Memory Commands
These commands each have as the first operand an alphabetic character
indicating the memory segment to be viewed. A separate window is opened for
each segment so data from all segments can be viewed simultaneously.
● c: code or program segment
● d: direct data segment
● i indirect data segment
● x: external data segment
The second operand is the beginning address to be viewed; the third operand is the number of bytes. The number of bytes is forced to 1 for the dynamic command, and limited to hexadecimal 0FA [decimal 250] for the others.
d: dynamic
This command causes the content of the single specified memory location to be
continuously displayed in a window separate from the four segment windows. The
update speed of the display is the speed of the serial connection. No other
commands can be entered until this one is terminated. The d command is
terminated by clicking the mouse in the text box displaying the data.
b: binary
h: hexadecimal
t: text
u: unassemble
These commands cause the content of the specified memory locations to be statically displayed in the corresponding memory segment window.