📄 boot51.doc
字号:
II.3 Tayloring the Cables
-------------------------
Application programs are uploaded to the target system over a serial
interface. The serial ports of the PC may have 9-pin or 25-pin male
D-Shell connectors. Suitable RS-232 cables for the MCS-51 board can
be taylored as follows:
RS-232 cable with 25-pin female D-Shell connector:
--------------------------------------------------
PC serial port: MCS-51 target system:
pin
Tx 2 o-----------------------------------------> RXD
Rx 3 o-----------------------------------------> TXD
RTS 4 o-----+
|
CTS 5 o-----+
DSR 6 o-----+
|
DCD 8 o-----+
|
DTR 20 o-----+
ground 7 o-----------------------------------------> ground
Shortening the modem control signals is absolutely required for batch
operation! If the CTS-, DSR-, or DCD-input is not set to logic low (+12V),
the PC will hang during character output to the serial port.
For operation with most terminal emulation programs, only the Tx-, Rx-,
and ground lines are required, and the handshake lines may be left open.
For further information refer to the documentation of your terminal
emulation program.
RS-232 cable with 9-pin female D-Shell connector:
-------------------------------------------------
PC serial port: MCS-51 target system:
pin
Rx 2 o-----------------------------------------> TXD
Tx 3 o-----------------------------------------> RXD
RTS 7 o-----+
|
CTS 8 o-----+
DCD 1 o-----+
|
DTR 4 o-----+
|
DSR 6 o-----+
ground 5 o-----------------------------------------> ground
If you own a 9/25-pin mouse adaptor with all pins connected, the 9-pin
version of the cable should be preferred!
If your MCS-51 board has a reset input (or you can establish one), the
target system can be reset in batch files over a printer port of the PC.
For this, a suitable reset cable must be taylored as shown below:
Reset cable with 25-pin male D-Shell connector:
-----------------------------------------------
PC printer port: MCS-51 target system:
pin
D0 2 o-----------------------------------------> Reset
_____
D1 3 o-----------------------------------------> Reset
ground 25 o-----------------------------------------> ground
In practice, only one of the two reset lines will be required.
When the program RESET.EXE is invoked, a positive reset pulse appears
at D0 (8031, 8032), and a negative pulse at D1 (80C535, 80C537).
For detailed information on the RESET program, refer to chapter III.2,
"Batch File Operation".
III. BOOT-51 Operation
----------------------
When BOOT-51 is customized correctly, and the target board is connected to
the host PC with the cable(s) described above, we can start to upload and
run application programs. There are two possible modes of operation:
- interactive operation
- batch file operation
III.1 Interactive Operation
---------------------------
BOOT-51 implements a simple ASCII user interface for serial communication.
The bootstrap program can be operated interactively with a terminal emulation
program running on the PC (e.g. TELIX).
To perform this, start your terminal emulation program, and configure it for
the correct baudrate, 8 data bits, 1 stop bit, no parity, and no handshake.
Then reset the MCS-51 target system.
Now the BOOT-51 sign-on message should appear on your screen:
BOOT-51 V1.0 Copyright (c) 1996 by W.W. Heinz
>
The '>' character indicates that the BOOT-51 command line interpreter is
ready for input. It implements exactly two commands:
1. The UPLOAD command:
First press the 'U', and then the return key.
Now the upload prompt ':' should be displayed. BOOT-51 is now ready to
receive an application program in Intel-Hex format. Send an Intel-Hex
file with the ASCII upload function of your terminal emulation program.
Now the received Intel-Hex records are loaded to their start addresses
specified in the record headers. If an EOF record is received, upload
is terminated and the command prompt '>' is displayed again, and the
command line interpreter is ready for the next command.
When a format error is detected in the Intel-Hex file, BOOT-51 waits
until no more characters are received for about two seconds, and then
aborts with a corresponding error message. (see Appendix C)
2. The GO TO command:
To start an application program at address 8000H, enter "G 8000" and
press return. BOOT-51 sets now all MCU registers to reset conditions
(as far as possible), and jumps to the start address specified.
Now the previously loaded application program should be running!
Any desired number of Intel-Hex files may be loaded, before entering the
'G' command. The commands may be entered in upper or lower case letters.
Interactive operation should be preferred, when the application program
performs serial I/O. This can easily be supervised with the terminal
emulation program. In interactive mode, a reset cable is of little use!
III.2 Batch File Operation
--------------------------
If serial I/O is only used for program upload, batch file operation may be
the most convenient way of testing with the shortest turn-around cycles.
The sample batch job below, shows the principles of operating BOOT-51 from
a PC with MS-DOS batch commands:
MODE COM2:9600,N,8,1,P
RESET LPT1
ASEM %1
ECHO U >COM2
COPY %1.HEX COM2
ECHO G 8000 >COM2
In this example, serial I/O is done over serial port COM2, and the target
system can be reset over printer port LPT1.
First of all, the serial port COM2 is initialized to the desired baudrate
of 9600 bps, 8 data bits, 1 stop bit, and no parity with the MODE utility.
Then the RESET program provided is executed to reset the target system via
printer port LPT1.
To give the MCS-51 board some time to recover from reset (and to send its
sign-on message), ASEM-51 is now invoked to assemble the application program.
When finished, the BOOT-51 upload command 'U' is ECHOed to COM2, and the
Intel-Hex file is also simply copied to the serial port.
Finally the application program is started at address 8000H with the
command "ECHO G 8000 >COM2".
To test an application program MYPROG.A51 with the above batch job (stored
in a file TEST.BAT), simply type
TEST MYPROG
at the DOS prompt, and see what you get.
Of course this was only a minimized example! In general you will not only
have to modify serial port, baudrate, printer port, and start address for
your local requirements, but also to do something for plausibility checking
and error handling.
For this, the more sophisticated batch file BOOT.BAT has been provided.
It allows an easy change of all configuration parameters with any ASCII
editor. For further information see the commentary inside BOOT.BAT.
In principle, BOOT.BAT contains only that configuration data!
(The actual work is done by another batch file LOAD.BAT provided,
which is invoked by BOOT.BAT.)
A program MYPROG.A51 can now be assembled, uploaded and started with
BOOT MYPROG
Finally, the RESET program provided, may be worth a detailed explanation:
When invoked, RESET forms a reset pulse of the duration <pulsewidth> at
the D0 and D1 outputs of the PC printer port <port>:
RESET <port> [<pulsewidth>]
Legal <port> values are: PRN, LPT1, LPT2, and LPT3.
PRN and LPT1 are equivalent.
The optional parameter <pulsewidth> is the duration of the reset pulse in ms.
Legal values are: 1 <= <pulsewidth> <= 65535. (default is 50)
When invoked without parameters, a help screen is displayed.
In case of error, RESET returns the ERRORLEVEL 1, 0 otherwise.
When executed, RESET forms a positive pulse at D0 (pin 2), and a negative
pulse at D1 (pin 3) of the PC printer port. The default pulse width is 50 ms.
If it is too short to reset the MCS-51 board, specify a greater pulse width.
For batch file operation, a reset cable is highly recommended! If you don't
have it, you will always have to press the reset button of the target system,
before invoking BOOT.BAT. Since this may easily be forgotten, it is better
to automate this step.
III.3 The BLINK Program
-----------------------
When BOOT-51 is customized and blown into an EPROM, and the target board
is connected to the host PC, it would be nice to verify, whether the whole
configuration is working together correctly. This can be done with a short
test program that performs a well-defined action when started.
For this purpose the tiny assembly program BLINK.A51 has been provided.
It simply toggles the logic level of a port pin (roughly) once a second
(great when connected to a LED) to verify, whether all the components in
the chain
assembly -> serial interface -> target system <-> bootstrap program
are working together correctly.
It can be adapted to your requirements with little efforts:
1. If your target system carries a LED that can be switched with a
(bit-addressable) port pin, please change the BIT symbol LEDPIN
accordingly. Then the program will make the LED blink.
2. Change the program start address START to the location, where
user programs are usually loaded on your target system.
The program code itself is position-independent!
If there is no LED on your target system, connect the port pin LEDPIN to
a volt-meter. This may also do. Aside of P0 and P2 you may use every
bit-addressable port with LEDs or spare outputs. Now the DOS command
BOOT BLINK
should reset the MCS-51 board, assemble the test program, upload it to the
target system, and finally start it. If the LED is blinking, everything is
now perfectly installed and ready for daily work.
If not, you should read the next chapter!
IV. Troubleshooting
--------------------
1. When initializing the serial port, the DOS MODE utility aborts with an
error message like: "function not supported on this computer", or
"illegal parameter", or something like that.
On most PCs, the BIOS doesn't support baudrates greater than 9600 Baud.
However, most terminal emulation programs can operate at baudrates of up
to 115200 Baud.
2. The RESET program aborts with "printer port not found".
The PC-BIOS didn't recognize the printer port specified.
Try another printer port or check your PC hardware.
3. The RESET program aborts with "hardware failure".
The PC-BIOS has recognized the printer port, but the data latch doesn't
work. Try another printer port, or check the defective port.
4. RESET terminates without any error, but the target system is not reset.
The reset cable may be plugged into the wrong printer port.
First of all try the other ports.
There may also be something wrong with the cable itself.
Employ the BOOT-51 manual and the circuit diagram of the target board,
and check the cable.
Furthermore, the reset pulse may be too short.
Specify a greater pulse width. You may also decrease the reset capacitor
of the MCS-51 system.
5. The target system is reset all the time. _____
When tayloring the reset cable, you may have mixed up the RESET and RESET
lines. Simply interchange them.
6. The PC hangs when data are sent over the serial interface in batch mode.
The RS-232 cable may be plugged into the wrong COM-port.
First of all, try the other ports.
There may also something be wrong with the modem control signals.
Employ the BOOT-51 manual and check the RS-232 cable on the PC side.
7. It works in interactive mode, but the PC hangs, if data are sent in batch
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -