| ??? 03/21/09 01:43 Read: times |
#163723 - IAP on NXP P89V51RC2 |
Hi,
I am working on an IAP (In Application Programming) project right now. I got the source code of IAP online and tried to integrated into my test program. I did check the content of the code and believed that it really followed the requirement of spec. The expected result is that it will print out the welcome message and print out the manufacture ID of the chip. (In this case, Philips is 15) However, it just kept printing out welcome message again and again. It seems that it won't execute the IAP code properly but reenter the main function when we called the IAP routine. Is there anyone who can give me some suggestion? Thanks. IAP Code
PGM_MTP EQU 01FF0H
FCF DATA 0B1H
RSEG ?PR?iap_read_manufacturer_id?RX2IAPLIB
iap_read_manufacturer_id:
PUSH IE ; disable interrupts
CLR EA
MOV A,CMOD
MOV R2,A ; store copy of CMOD
JNB ACC.6,?IAPTAG2 ; if watchdog enabled then disable
ANL CMOD,#0BFH
?IAPTAG2:
ANL FCF,#0FCH ; enable bootrom
MOV R1,#00H
MOV DPH,#00H
MOV DPL,#00H
CALL PGM_MTP ; call iap routine
MOV R7,A ; id in accumulator
ORL FCF,#01H ; disable bootrom
MOV CMOD,R2 ; restore CMOD (restore watchdog state)
POP IE ; restore interrupts to initial state
RET
; end of iap_read_manufacturer_id
Main sfr WDTC = 0xC0;
#define KILL_WDT WDTC = 0
#define DISABLE_ALL_INTERRUPT EA = false; ///< Disable all interrupt.
void main( void )
{
BYTE man_id;
DISABLE_ALL_INTERRUPT //disable all interrupt
KILL_WDT; // Disable watchdog
TI = false; // Clear serial transmission interrupt
RI = false; // Clear serial receiving interrupt
initSioPoll(); // initialize serial port
printf("Welcome");
man_id = iap_read_manufacturer_id(); //obtain the manufacture ID by calling IAP function
printf("Manufacturer ID = %2.2bxHn",man_id);
while(1);
}
|
| Topic | Author | Date |
| IAP on NXP P89V51RC2 | 01/01/70 00:00 | |
| Is the code located above 0x2000? | 01/01/70 00:00 | |
| It didn't start from 0x2000h | 01/01/70 00:00 | |
| This is the Linker's job | 01/01/70 00:00 | |
| Linker works. But Erase and Program could work only half way | 01/01/70 00:00 | |
| Boot loader | 01/01/70 00:00 | |
| sawing the branch you are sitting on... | 01/01/70 00:00 | |
| Parts of a live application can be replaced with care | 01/01/70 00:00 | |
| Update Prgram using IAP | 01/01/70 00:00 | |
| Back to boot loader concept again | 01/01/70 00:00 | |
| About Locate Function in C code | 01/01/70 00:00 | |
It worked finally | 01/01/70 00:00 |



