With microprocessor ATmEL 89C51RC2 , when I prepare registers and ACC for API call and I call
CALL 0xFFF0
instructions below the call are never executed. The process never returns from 0xFFF0. Are there any common mistakes begginers can do, that causes this? What is important to take care of, for API instruction to execute properly?
My code:
FLASH_ADR equ 01000h ; adress in FLASH to write to
PGM_MTP equ 0FFF0h ; adress of API subprogram
PulseRRef set 4230;
MOV R0, #11
MOV R1,#02h
MOV A, #low(PulseRRef)
MOV DPTR,#FLASH_ADR
LCALL PGM_MTP
JZ END_S
MOV DPTR,#TEXTES ; writes message to the terminal
CALL SEND
END_S:
MOV DPTR,#TEXTME ; writes different message to the terminal
CALL SEND
RET
2 Answers 2
The IAP function PGM_MTP
is in the boot loader ROM. In normal operation the boot ROM is disabled, so trying to call functions in it will fail. To enable the boot ROM you have to set ENBOOT
(bit 5) in register AUXR1
(0A2h). After making the IAP call you should clear ENBOOT
to disable the ROM again.
The code might look like this:-
AUXR1 equ 0A2h
ORL AUXR1,#20h
LCALL PGM_MTP
ANL AUXR1,#NOT 20h
-
\$\begingroup\$ I did that, but the process never returns from PGM_MTP and never run ANL AUXR1, ... nor any instruction below. \$\endgroup\$user50222– user502222015年04月09日 10:05:20 +00:00Commented Apr 9, 2015 at 10:05
I had my own handlers for interrupts (serial). I think this might cause the problem. When I disable global interrupt permission (EA) before calling PGM_MTP and allow it after the call, instruction pointer does return in my program.
So the programm should look like:
MOV R0, #11 ;crystal frequency
MOV R1,#02h
MOV A, byteToWrite
MOV DPTR,#FLASH_ADR
CLR EA
ORL AUXR1,#20h ;set BOOTEN
CALL PGM_MTP
ANL AUXR1,#0DFh ;clear BOOTEN
SETB EA
JZ END_S
MOV DPTR,#FAILED ; writes warning message to the terminal
CALL SEND
END_S:
RET