MS51
Nov. 28, 2019
Page
263
of 491
Rev 1.00
MS51
32K
SE
RIES
TE
CHNICAL RE
F
EREN
CE MA
N
UAL
MOV
TA,#55h
ORL
IAPUEN,#00000100b
;CFUEN = 1, enable CONFIG update
RET
Disable_CONFIG_Update:
MOV
TA,#0Aah
MOV
TA,#55h
ANL
IAPUEN,#11111011b
;CFUEN = 0, disable CONFIG update
RET
Trigger_IAP:
MOV
TA,#0Aah
;IAPTRG is TA protected
MOV
TA,#55h
ORL
IAPTRG,#00000001b
;write ‘1’ to IAPGO to trigger IAP
process
RET
;********************************************************************
;
IAP APROM Function
;********************************************************************
Erase_AP:
MOV
IAPCN,#PAGE_ERASE_AP
MOV
IAPFD,#0FFh
MOV
R0,#00h
Erase_AP_Loop:
MOV
IAPAH,R0
MOV
IAPAL,#00h
CALL Trigger_IAP
MOV
IAPAL,#80h
CALL Trigger_IAP
INC
R0
CJNE R0,#44h,Erase_AP_Loop
RET
Program_AP:
MOV
IAPCN,#BYTE_PROGRAM_AP
MOV
IAPAH,#00h
MOV
IAPAL,#00h
MOV
DPTR,#AP_code
Program_AP_Loop:
CLR
A
MOVC A,@A+DPTR
MOV
IAPFD,A
CALL Trigger_IAP
INC
DPTR
INC
IAPAL
MOV
A,IAPAL
CJNE A,#14,Program_AP_Loop
RET
Program_AP_Verify:
MOV
IAPCN,#BYTE_READ_AP