phillips p89v51rd2
I am trying to perform the In-Application Programming of this microcontroller. I have written this section of code for the program but it doesn't seem to be working at all.
call_iap_write:
PUSH IEN0 ; disable interrupts
CLR EA
MOV B,CMOD
MOV R2,B ; store copy of CMOD
JNB B.6,?IAPTAG11 ; if watchdog enabled then disable
ANL CMOD,#0BFH
?IAPTAG11:
MOV ACC, 55H
MOV DPH, 23H
MOV DPL, 70H
MOV R1, #02H
ANL FCF, #0FEH ; enable bootrom
CALL 01FF0H ; call iap routine
MOV R7, ACC
ORL FCF,#01H ; disable bootrom
MOV CMOD,R2 ; restore CMOD (restore watchdog state)
POP IEN0 ; restore interrupts to initial state
RET
I have ensured that this code is well beyond 1FFFH i.e. the part of memory that the bootloader will occupy.
Can anyone please help?