ARM Technical Support Knowledge Articles

INTERFACE FOR IAP FUNCTIONS ON PHILIPS DEVICES

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

I'm using a Philips P89C51RD2 chip that provides In-system Application Programming (IAP). Philips provides an Assembler interface, however, I want to use these routines from C. What can I do?

ANSWER

The Philips IAP assembly interface is fully documented in the datasheet. In general, your program must make calls to address 0xFFF0.

This is easily accomplished by creating a small assembly routine that can be called from your C functions. For example:

sfr AUXR1        = 0xA2;

XTAL_MHZ        EQU     12            ; Chip runs at 12MHz
?PR?_ProgramDataByte?ISA  SEGMENT CODE
RSEG ?PR?_ProgramDataByte?ISA

PUBLIC _ProgramDataByte         ; Entry Point for C Compiler
; unsigned char ProgramDataByte (unsigned int addr, unsigned char v);
; The C51 compiler passes addr in R6/R7 and v in R5

_ProgramDataByte:       ORL   AUXR1,#20H     ; ENBOOT = 1 (required on some parts)

                        MOV   DPH,R6
                        MOV   DPL,R7
                        MOV   A,R5
                        MOV   R0,#XTAL_MHZ
                        MOV   R1,#02H        ; function code
                        CALL  0FFF0H         ; Call Philips firmware
                        MOV   R7,A           ; C51 expects return in R7

                        ANL   AUXR1,#NOT 20H ; ENBOOT = 0(required on some parts)
                        RET

                        END

Note: Some devices require that you set the ENBOOT bit in the SFR AUXR1. You need to check with the device datasheet if this is required or not.

This routine may be called directly from your C functions as follows:

extern unsigned char ProgramDataByte (unsigned int addr, unsigned char v);
.
.
.
void main (void)  {
  ProgramDataByte (0x8000, 0x55);   // programs 0x55 at address 0x8000
}

You can implement the assembly interface to other routines just as easily. The same method works for many other parts like Philips P89C668.

MORE INFORMATION

SEE ALSO

Article last edited on: 2006-03-15 12:40:52

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential