Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/10/07 14:01
Read: times


 
#141680 - P89V51Rxx In-Application Programming
Hello members,

I have previously posted this message to NXP MCU forum. Following Jan Waclawek's advice I am posting it here, with the assembler output addition. Since I am new to this forum, please excuse me if this topic has been discussed previously.

I am porting working code from the 89C51RD2 to the new 89V51RD2 and I am having problems with the IAP routines.

Has anyone made them work? What is the address to access them?

In page 25 of the product data sheet (P89V51RB2_RC2_RD2_4.pdf) they say it is 0x1FF0 while in page 3 of technical note TN06007 (V51RX2 migration) they say it is 0x1F00. Anyway, I have used both and have no success. It seems the routine never returns to my code.

Following is the non-working code. I am using Keil C.


#define CALL_BOOT_ROM ((void(code*)(void))0x1FF0)()

UCHAR
WriteFlashByte( UINT byteAddr, UCHAR byteVal )
{
DBYTE[0x0001]= 0x02; // IAP function, Program User Code
DPTR = byteAddr; // flash address to write
ACC = byteVal; // value to write

EA = 0; // disable interrupts
FCF &= 0x00; // enable boot code map
CALL_BOOT_ROM; // call IAP routine
FCF |= 0x01; // disable boot code map
EA = 1; // enable interrupts

return ACC;
}

- UCHAR and UINT are typedef for unsigned char and unsigned int.
- DBYTE is a way to write in an absolute address (register R1 in this case)
- The function is located at 0x2000, non-overlapping bootcode.
RSEG ?PR?_WriteFlashByte?CABBOOT

The assembler output is:

_WriteFlashByte:
USING 0
; SOURCE LINE # 503
MOV byteAddr?1260,R6
MOV byteAddr?1260+01H,R7
MOV byteVal?1261,R5
;
; DBYTE[0x0001]= 0x02; // IAP function, Program User Code
; SOURCE LINE # 509
MOV R0,#01H
MOV @R0,#02H
; DPTR = byteAddr; ; SOURCE LINE # 510
MOV DPH,byteAddr?1260
MOV DPL,byteAddr?1260+01H
; ACC = byteVal; ; SOURCE LINE # 511
MOV A,byteVal?1261

; EA = 0; ; SOURCE LINE # 513
CLR EA

; FCF &= 0x00; ; SOURCE LINE # 514
MOV FCF,#00H

; CALL_BOOT_ROM; ; SOURCE LINE # 515
LCALL 01FF0H

; FCF |= 0x01; ; SOURCE LINE # 516
ORL FCF,#01H

; EA = 1; ; SOURCE LINE # 517
SETB EA

MOV R7,A
RET
; }

; END OF _WriteFlashByte



Am I missing something?

Thank you in advance for any help.

Alejandro


List of 2 messages in thread
TopicAuthorDate
P89V51Rxx In-Application Programming            01/01/70 00:00      
   hummmm...            01/01/70 00:00      

Back to Subject List