ML51/ML54/ML56
Sep. 01, 2020
Page
352
of 719
Rev 2.00
ML
51
/ML
54
/ML
5
6 S
E
RI
E
S
TECHNI
CA
L
RE
F
E
R
E
NC
E
M
A
NU
A
L
ML51/M
L54
/M
L56
Series
Tec
hnical Reference
Manual
BYTE_PROGRAM_AP EQU 00100001b
ORG 0000h
MOV TA,#0Aah
;CHPCON is TA protected
MOV TA,#55h
ORL CHPCON,#00000001b
;IAPEN = 1, enable IAP mode
MOV TA,#0Aah
;IAPUEN is TA protected
MOV TA,#55h
ORL IAPUEN,#00000001b
;APUEN = 1, enable APROM update
MOV IAPCN,#PAGE_ERASE_AP
;Erase page 200h~27Fh
MOV IAPAH,#02h
MOV IAPAL,#00h
MOV IAPFD,#0FFh
MOV TA,#0Aah
;IAPTRG is TA protected
MOV TA,#55h
ORL IAPTRG,#00000001b
;write ‘1’ to IAPGO to trigger IAP process
MOV IAPCN,#BYTE_PROGRAM_AP
;Program 201h with 55h
MOV IAPAH,#02h
MOV IAPAL,#01h
MOV IAPFD,#55h
MOV TA,#0Aah
MOV TA,#55h
ORL IAPTRG,#00000001b
MOV TA,#0Aah
MOV TA,#55h
ANL IAPUEN,#11111110b
;APUEN = 0, disable APROM update
MOV TA,#0Aah
MOV TA,#55h
ANL CHPCON,#11111110b
;IAPEN = 0, disable IAP mode
MOV DPTR,#201h
CLR A
MOVC A,@A+DPTR
;Read content of address 201h
MOV P0,A
SJMP $
C language demo code:
//*************************************************************************
// This code illustrates how to use IAP to make APROM 201h as a byte of
// Data Flash when user code is executed in APROM.
//*************************************************************************
#define PAGE_ERASE_AP
0x22
#define BYTE_PROGRAM_AP 0x21
/*Data Flash, as part of APROM, is read by MOVC. Data Flash can be defined as128-
element array in “code” area from absolute address 0x0200 */