MS51
Nov. 28, 2019
Page
264
of 491
Rev 1.00
MS51
32K
SE
RIES
TE
CHNICAL RE
F
EREN
CE MA
N
UAL
MOV
IAPAH,#00h
MOV
IAPAL,#00h
MOV
DPTR,#AP_code
Program_AP_Verify_Loop:
CALL Trigger_IAP
CLR
A
MOVC A,@A+DPTR
MOV
B,A
MOV
A,IAPFD
CJNE A,B,Program_AP_Verify_Error
INC
DPTR
INC
IAPAL
MOV
A,IAPAL
CJNE A,#14,Program_AP_Verify_Loop
RET
Program_AP_Verify_Error:
CALL Disable_IAP
MOV
P0,#00h
SJMP $
;********************************************************************
;
IAP CONFIG Function
;********************************************************************
Erase_CONFIG:
MOV
IAPCN,#ALL_ERASE_CONFIG
MOV
IAPAH,#00h
MOV
IAPAL,#00h
MOV
IAPFD,#0FFh
CALL Trigger_IAP
RET
Read_CONFIG:
MOV
IAPCN,#BYTE_READ_CONFIG
MOV
IAPAH,#00h
MOV
IAPAL,#02h
CALL Trigger_IAP
MOV
R7,IAPFD
RET
Program_CONFIG:
MOV
IAPCN,#BYTE_PROGRAM_CONFIG
MOV
IAPAH,#00h
MOV
IAPAL,#02h
MOV
A,R7
ANL
A,#11111011b
MOV
IAPFD,A
;disable BOD reset
MOV
R6,A
;temp data
CALL Trigger_IAP
RET
Program_CONFIG_Verify: