Megawin 8051 User manual

This document information is the intellectual property of Megawin Technology Co., Ltd. 1
©Megawin Technology Co., Ltd. 2007 All right reserved.
MEGAWIN
MAKE YOU WIN
Megawin 8051 ISP via COM Port
User Manual, v1.02
Megawin
8051 ISP via COM Port
User Manual
By Vincent Y. C. Yu

This document information is the intellectual property of Megawin Technology Co., Ltd. 2
©Megawin Technology Co., Ltd. 2007 All right reserved.
MEGAWIN
MAKE YOU WIN
Megawin 8051 ISP via COM Port
User Manual, v1.02
Contents
1 What is ISP ..................................................................................................... 3
2 Chip Configuration for ISP .............................................................................. 4
2.1 Using the “Megawin 8051 Writer” for Chip Configuration..........................................................4
2.2 Using the “Hi-Lo ALL-11 Programmer” for Chip Configuration..................................................5
3 How to Do ISP via COM Port.......................................................................... 9
3-1 System Diagram & Circuit.........................................................................................................9
3-2 Install the PC-site AP..............................................................................................................10
3-3 Operating Steps......................................................................................................................11
4 About USB-to-RS232 Cables........................................................................ 13
Revision History................................................................................................. 14

This document information is the intellectual property of Megawin Technology Co., Ltd. 3
©Megawin Technology Co., Ltd. 2007 All right reserved.
MEGAWIN
MAKE YOU WIN
Megawin 8051 ISP via COM Port
User Manual, v1.02
1 What is ISP
ISP is the acronym of In-System Programming, and makes it possible that the user can alter the application code
under the software control without removing the mounted MCU chip from the actual end product.
To do ISP, the loader program (called “ISP code”) should be pre-programmed into the target MCU’s ISP-memory
before mounting the MCU chip to the PCB. When powered on, the MCU boots from the ISP-memory and runs
the loader program for checking if the user wants to do ISP. If the ISP is not requested, the MCU will re-boot from
the AP-memory by triggering the software reset to run the user’s application code.

This document information is the intellectual property of Megawin Technology Co., Ltd. 4
©Megawin Technology Co., Ltd. 2007 All right reserved.
MEGAWIN
MAKE YOU WIN
Megawin 8051 ISP via COM Port
User Manual, v1.02
2 Chip Configuration for ISP
To use the ISP function, the user should configure the MCU chip by the following two steps:
Step1:
Use a universal Writer or Programmer to configure the ISP-memory with 1K bytes (or 1.5K bytes for
MPC82L(E)54 ) and make HWBS or HWBS2 option enabled.
Step2:
Program the Megawin-provided standard ISP code, "ISP_by_COM.BIN" in the [(2) Target ISP-code] folder, into
the configured ISP-memory.
The user may utilize the “Megawin 8051 Writer” or the “Hi-Lo ALL-11 Universal Programmer” for the MCU chip
configuration.
2.1 Using the “Megawin 8051 Writer” for Chip Configuration
Please follow the steps (also shown in the following picture):
Step1: Select the Part No.
Step2: Select the Programming Area: ISP-memory.
Step3: Load the ISP code, “ISP_by_COM.BIN”, to the Writer’s buffer.
Step4: Configure the MCU’s H/W Option: 1KB (or 1.5KB for MPC82L(E)54) for ISP-memory and enable HWBS
or HWBS2.
Step5: Click “Auto” and select “Program Option”, then click “Run” for auto programming.

This document information is the intellectual property of Megawin Technology Co., Ltd. 5
©Megawin Technology Co., Ltd. 2007 All right reserved.
MEGAWIN
MAKE YOU WIN
Megawin 8051 ISP via COM Port
User Manual, v1.02
2.2 Using the “Hi-Lo ALL-11 Programmer” for Chip Configuration
Step 1. Configure the H/W option: Enable HWBS and select ISP Address
(1) For MPC89L(E)51/52/53: select 0x3800-0x3BFF (1K bytes for Megawin-provided ISP code)
(2) For MPC89L(E)54/58/515: select 0xF800-0xFBFF (1K bytes for Megawin-provided ISP code)
(3) For MPC82L(E)52: select 0x1C00-0x1FFF (1K bytes for Megawin-provided ISP code)
(4) For MPC82L(E)54: select 0x3800-0x3DFF (1.5K bytes for Megawin-provided ISP code)
(5) For MPC82G516: select 0xFC00-0xFFFF (1K bytes for Megawin-provided ISP code)
See the following example:
For MPC89L(E)51/52/53:
Select ISP Address
Enable HWBS

This document information is the intellectual property of Megawin Technology Co., Ltd. 6
©Megawin Technology Co., Ltd. 2007 All right reserved.
MEGAWIN
MAKE YOU WIN
Megawin 8051 ISP via COM Port
User Manual, v1.02
Step 2. Load the “ISP code” to the programmer’s buffer
As the following figure, select “Load File to Programmer Buffer” to load the ISP code “ISP_by_COM.BIN” into the
Programmer Buffer.

This document information is the intellectual property of Megawin Technology Co., Ltd. 7
©Megawin Technology Co., Ltd. 2007 All right reserved.
MEGAWIN
MAKE YOU WIN
Megawin 8051 ISP via COM Port
User Manual, v1.02
Step 3. Change the “Buff start” to the MCU’s ISP start address
(1) For MPC89L(E)51/52/53: change to 0x3800
(2) For MPC89L(E)54/58/515: change to 0xF800
(3) For MPC82L(E)52: change to 0x1C00
(4) For MPC82L(E)54: change to 0x3800
(5) For MPC82G516: change to 0xFC00
Note: Hi-Lo will support MPC82G516 in the future.
Change the “Buff start”

This document information is the intellectual property of Megawin Technology Co., Ltd. 8
©Megawin Technology Co., Ltd. 2007 All right reserved.
MEGAWIN
MAKE YOU WIN
Megawin 8051 ISP via COM Port
User Manual, v1.02
Step 4. Click the “Auto” button to program the ISP code and H/W option into the MCU chip

This document information is the intellectual property of Megawin Technology Co., Ltd. 9
©Megawin Technology Co., Ltd. 2007 All right reserved.
MEGAWIN
MAKE YOU WIN
Megawin 8051 ISP via COM Port
User Manual, v1.02
3 How to Do ISP via COM Port
3-1 System Diagram & Circuit
To connect the target system to the COM port of a host PC, there needs an RS232 signal level converter, i.e., an
RS232 transceiver (such as the MAX232 chip). The following block diagram shows the connection between the
target system and the PC. Where, the P3.0 & P3.1 of the target MCU function as the UART receive & transmit,
respectively; And, a MAX232 chip and a 9-pin RS232 connector are used for communication with the PC’s COM
port.
Block Diagram
Target System
PC
COM Port
P3.1
P3.0
Target MCU RS232 Transceiver
(such as MAX232)
T_IN T_OUT
R_INR_OUT
TXD
RXD
RS232
Connector
1
2
3
4
6
5
7
8
9
RS232 Cable
Circuitry
C2
1u/16V
To PC
DTR
VCC
8051_TXD
P1
Male DB9
5
9
4
8
3
7
2
6
1
8051_RXD
X1
12MHz
RTS
VCC
DCD
RS232 to PC
C3
1u/16V
C4
1u/16V
RD
Note:
(1) The VCC power can be 3.3V (for L-series) or 5.0V (for E-series).
(2) There is no restriction on the XTAL's frequency.
TD
DSR
GND
R1 100K
C7
1u
8051_RXD
Target MCU
CTS
C6
10p
BC1 0.1u
8051_TXD
RI
U1
MAX232
1
3
4
5
11
10
12
9
2
6
14
7
13
8
15
16
C1+
C1-
C2+
C2-
T1_IN
T2_IN
R1_OUT
R2_OUT
V+
V-
T1_OUT
T2_OUT
R1_IN
R2_IN
GND
VCC
C1
1u/16V
C5
10p
U2
MPC89L515(40-DIP)
31
19
18
9
12
13
14
15
1
2
3
4
5
6
7
8
39
38
37
36
35
34
33
32
21
22
23
24
25
26
27
28
17
16
29
30
11
10
40
20
EA
XTAL1
XTAL2
RST
P3.2/INT0
P3.3/INT1
P3.4/T0
P3.5/T1
P1.0/T2
P1.1/T2EX
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
P0.0
P0.1
P0.2
P0.3
P0.4
P0.5
P0.6
P0.7
P2.0
P2.1
P2.2
P2.3
P2.4
P2.5
P2.6
P2.7
RD/P3.7
WR/P3.6
PSEN
ALE
TXD/P3.1
RXD/P3.0
VCC
GND

This document information is the intellectual property of Megawin Technology Co., Ltd. 10
©Megawin Technology Co., Ltd. 2007 All right reserved.
MEGAWIN
MAKE YOU WIN
Megawin 8051 ISP via COM Port
User Manual, v1.02
3-2 Install the PC-site AP
Run “Setup.exe” (in the [(1) PC-site AP] folder) to install the application program on PC-site. Using its default
installing setting, you will find the item “Megawin Utilities \ Megawin 8051 ISP via COM Port (v…)” appearing
in the Windows’ START-menu.
(Note: the v?.?? means the current version and may be upgraded in the future.)
Introduction to the GUI of the AP
GUI means “Graphic User Interface” of the Application Program running in the Windows.

This document information is the intellectual property of Megawin Technology Co., Ltd. 11
©Megawin Technology Co., Ltd. 2007 All right reserved.
MEGAWIN
MAKE YOU WIN
Megawin 8051 ISP via COM Port
User Manual, v1.02
3-3 Operating Steps
First, turn off the target system and run the installed AP on PC-site. Then, follow the steps listed below:
Step1: Select Part No.
Step2: Click “Load File” to load the new program code
Step3: Fill the “Target Page Offset” if need
Step4: Select the COM Port to which the target system is connected, and select Auto/Manual BaudRate
Step5: Click “Update Target”, and then turn on the target system within 10 seconds when the message
‘Device Detect…’ is shown in the processing status window. !Very important !
Step6: Wait the processing result.
Step7: Go to Step5 for trying again if any errors happen.
See notes in the next page.

This document information is the intellectual property of Megawin Technology Co., Ltd. 12
©Megawin Technology Co., Ltd. 2007 All right reserved.
MEGAWIN
MAKE YOU WIN
Megawin 8051 ISP via COM Port
User Manual, v1.02
Notes:
For Step2:
When load file, both “.HEX” and “.BIN” are acceptable, and the code size is based on its binary format.
For MPC89L(E)51/52/53, the maximum code size is 15K-1K=14K bytes, which includes IAP data.
For MPC89L(E)54/58/515, the maximum code size is 63K-1K=62K bytes, which includes IAP data.
For MPC82L(E)52, the maximum code size is 8K-1K=7K bytes, which includes IAP data.
For MPC82L(E)54, the maximum code size is 15.5K-1.5K=14K bytes, which includes IAP data.
For MPC82G516, the maximum code size is 64K-1K=63K bytes, which includes IAP data.
Where, “minus 1K” (or 1.5K for MPC82L(E)54 ) means subtracting the space of ISP-memory.
For Step3:
The “Target Page Offset” means the starting address of the Flash memory to be programmed. For example, if the
offset is filled with ‘5A’, then the new program code will be programmed into the Flash memory starting from
0x5A00. In fact, the offset value is the high-byte Flash page address. Because each page has 512 bytes, this
offset value should be an even number.
For Step4:
If a “USB-to-RS232” cable is used, its COM port number can be checked by the following steps:
1) Open the My Computer folder.
2) Open the Control Panel folder.
3) Open the System.
4) Click on the Hardware tab at the top of the dialog box, then click on the Device Manager.
5) Click on the plus sign in front of the Ports (COM & LPT) to check the device listing for the cable’s
COM number.
The user can select either Auto BaudRate or Manual BaudRate. Sometimes the ISP processing may fail
when Auto Baudrate is used. At this time, please select Manual BaudRate and choose a lower baudrate for
successful ISP processing.
For Step5:
Anyway, before clicking “Update Target”, the user should keep the target system in powered-off state.

This document information is the intellectual property of Megawin Technology Co., Ltd. 13
©Megawin Technology Co., Ltd. 2007 All right reserved.
MEGAWIN
MAKE YOU WIN
Megawin 8051 ISP via COM Port
User Manual, v1.02
4 About USB-to-RS232 Cables
So many modern Note Book computers have no COM port built-in. Therefore, the user may use the “USB-to-
RS232” (or “USB-to-Serial”) adapter to substitute the real COM Port. However, not all the cables can work well
for our ISP application. It is strongly recommended that user use the cable with Prolific chip (PL-2303) or
FTDI chip built in.

This document information is the intellectual property of Megawin Technology Co., Ltd. 14
©Megawin Technology Co., Ltd. 2007 All right reserved.
MEGAWIN
MAKE YOU WIN
Megawin 8051 ISP via COM Port
User Manual, v1.02
Revision History
Revision Description Date
v1.00 The first released version. 2007/04/24
v1.01 Fix the PC-site AP bug: Hex to Binary conversion error. 2007/08/06
v1.02 In the target MCU, only the pages occupied by the new program code are erased. 2008/01/22
Other manuals for 8051
1
Table of contents
Other Megawin Computer Hardware manuals