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
asked Apr 9, 2015 at 7:51
\$\endgroup\$

2 Answers 2

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 
answered Apr 9, 2015 at 9:58
\$\endgroup\$
1
  • \$\begingroup\$ I did that, but the process never returns from PGM_MTP and never run ANL AUXR1, ... nor any instruction below. \$\endgroup\$ Commented Apr 9, 2015 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
answered Apr 11, 2015 at 18:35
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.