1
\$\begingroup\$

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
\$\endgroup\$
1
\$\begingroup\$

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  
\$\endgroup\$
  • \$\begingroup\$ I did that, but the process never returns from PGM_MTP and never run ANL AUXR1, ... nor any instruction below. \$\endgroup\$ – user50222 Apr 9 '15 at 10:05
1
\$\begingroup\$

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
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.