geek8051
Newbie level 2
rx2iaplib
I am trying to perform the In-Application Programming of the P89V51RC2. I have written this section of code for the program but it doesn't seem to be working at all. It
seems that it just kept printing Test Test Test message but never perform the erase
procedure. Anyone could give me suggestion? Thanks.
//erase block function
RSEG ?PR?_iap_erase_block?RX2IAPLIB
_iap_erase_block:
PUSH IE ; disable interrupts
CLR EA
MOV A,CMOD
MOV R2,A ; store copy of CMOD
JNB ACC.6,?IAPTAG13 ; if watchdog enabled then disable
ANL CMOD,#0BFH
?IAPTAG13:
ANL FCF,#0FCH ; enable bootrom
MOV R1,#08H
MOV DPH,R6 ; address to program
MOV DPL,R7
CALL 01FF0H ; call iap routine
ORL FCF,#01H ; disable bootrom
MOV CMOD,R2 ; restore CMOD (restore watchdog state)
POP IE ; restore interrupts to initial state
RET
; end of iap_erase_block
//main
sfr WDTC = 0xC0;
#define KILL_WDT WDTC = 0
#define DISABLE_ALL_INTERRUPT EA = false; ///< Disable all interrupt.
void main( void )
{
int i;
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("Test");
for(i = 0; i < 10; i++){
iap_erase_block(i * 128);
}
while(1);
}
I am trying to perform the In-Application Programming of the P89V51RC2. I have written this section of code for the program but it doesn't seem to be working at all. It
seems that it just kept printing Test Test Test message but never perform the erase
procedure. Anyone could give me suggestion? Thanks.
//erase block function
RSEG ?PR?_iap_erase_block?RX2IAPLIB
_iap_erase_block:
PUSH IE ; disable interrupts
CLR EA
MOV A,CMOD
MOV R2,A ; store copy of CMOD
JNB ACC.6,?IAPTAG13 ; if watchdog enabled then disable
ANL CMOD,#0BFH
?IAPTAG13:
ANL FCF,#0FCH ; enable bootrom
MOV R1,#08H
MOV DPH,R6 ; address to program
MOV DPL,R7
CALL 01FF0H ; call iap routine
ORL FCF,#01H ; disable bootrom
MOV CMOD,R2 ; restore CMOD (restore watchdog state)
POP IE ; restore interrupts to initial state
RET
; end of iap_erase_block
//main
sfr WDTC = 0xC0;
#define KILL_WDT WDTC = 0
#define DISABLE_ALL_INTERRUPT EA = false; ///< Disable all interrupt.
void main( void )
{
int i;
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("Test");
for(i = 0; i < 10; i++){
iap_erase_block(i * 128);
}
while(1);
}