MS51
Nov. 28, 2019
Page
261
of 491
Rev 1.00
MS51
32K
SE
RIES
TE
CHNICAL RE
F
EREN
CE MA
N
UAL
TA = 0x55;
IAPUEN &= ~0x01;
//APUEN = 0, disable APROM update
TA = 0Xaa;
//CHPCON is TA protected
TA = 0x55;
CHPCON &= ~0x01;
//IAPEN = 0, disable IAP mode
P0 = Data_Flash[1];
//Read content of address 200h+1
while(1);
}
In-System-Programming (ISP)
6.3.1.5
The Flash Memory supports both hardware programming and In-Application-Programming (IAP). If the
product is just under development or the end product needs firmware updating in the hand of an end
user, the hardware programming mode will make repeated programming difficult and inconvenient. In-
System-Programming (ISP) makes it easy and possible. ISP performs Flash Memory updating without
removing the microcontroller from the system. It allows a device to be re-programmed under software
control. Furthermore, the capability to update the application firmware makes wide range of
applications possible.
User can develop a custom Boot Code that resides in LDROM. The maximum size of LDROM is 4K
Byte. User developed Boot Code can be re-programmed by parallel writer or In-Circuit-Programming
(ICP) tool.
General speaking, an ISP is carried out by a communication between PC and MCU. PC transfers the
new User Code to MCU through serial port. Then Boot Code receives it and re-programs into User
Code through IAP commands. Nuvoton provides ISP firmware and PC application for MS51. It makes
user quite easy perform ISP through UART port. Please visit Nuvoton 8-bit Microcontroller website:
Nuvoton 80C51 Microcontroller Technical Support
. A simple ISP demo code is given below.
Assembly demo code:
;**************************************************************************
****
; This code illustrates how to do APROM and CONFIG IAP from LDROM.
; APROM are re-programmed by the code to output P1 as 55h and P2 as
aah.
; The CONFIG2 is also updated to disable BOD reset.
; User needs to configure CONFIG0 = 0x7F, CONFIG1 = 0Xfe, CONFIG2 =
0Xff.
;**************************************************************************
****
PAGE_ERASE_AP
EQU
00100010b
BYTE_PROGRAM_AP
EQU
00100001b
BYTE_READ_AP
EQU
00000000b
ALL_ERASE_CONFIG
EQU
11100010b
BYTE_PROGRAM_CONFIG
EQU
11100001b
BYTE_READ_CONFIG
EQU
11000000b
ORG
0000h
CLR
EA
;disable all interrupts
CALL Enable_IAP