How to erase sector throgh IAP

Started by sanketbarot, August 10, 2007, 05:54:25 AM

Previous topic - Next topic

sanketbarot

Hello friends.

I have to erase a perticular sector thorugh IAP.. I am downloading my code frm 0x2000 address. now the problwm i am facing is that when i am erasing a particular sector at that time ACC gives me 00 i.e. PASS. but when reading the memory at that time that sector was not erased. for that in thought that may be sector number is wrong so i fill up all the memory and then try to erase the sector but none of the sector was erase. I am calculatin the sector like. if i have to erae the sector strating from 0xd000. then decimal of 0xd000 is 53248 and divide by 128 means 416 so sector no. is 417 and whose hex is 0x1A1. but i cdnt..
so i am just pasting that code here and i am using keil compiler for that..


Its very urgent...........

same way i have writtebn the Iap program byte and its running properly..

        RSEG  ?PR?iap_erase_sector?RX3IAPLIB
iap_erase_sector:
        PUSH    IE                       ; disable interrupts
        CLR     EA
        MOV     A,CMOD 
        MOV     R2,A                     ; store copy of CMOD
        JNB     ACC.6,?IAPTAG41           ; if watchdog enabled then disable
        ANL     CMOD,#0BFH
?IAPTAG41:
   MOV     R1,#08H
        MOV     DPH,#00H                  ;Address staring from address 0xd000
        MOV     DPL,#0A1H
        CALL    1FF0H                   ; call iap routine
   MOV     R7,A                     ; pass or fail decesion
        MOV     CMOD,R2                  ; restore CMOD (restore watchdog state)
        POP     IE                       ; restore interrupts to initial state
        RET     







Je Gold

Before you call 1FF0  you have to switch-in/enable block1 flash (bootloader).

IE  SWAP-OUT the 1st 0000 -  1FFF    and SWAP-IN the bootloader in to this address segment

By activating the boot code registers.

Page 14 of the P89V51 User manual   section 7.1.1

Joe

sanketbarot

hi!!

I have written just assembly code actully i am calling this function from  main code and before calling this I write '0' in FCF register and after comming out from it write '1' in FCF register i.e.

FCF=0;
IAP_erase_sector();
FCF=1;

and i download my code form address 2000H in the falsh..
so is it the corretc procedure if yes then why it is not erasing the sector and as i mentioned earlier my IAP_program_byte function works properly but erase setor dosent work....

please let me know where im wrong.....

Jan Waclawek

Quote from: sanketbarot on August 10, 2007, 05:54:25 AM
I am calculatin the sector like. if i have to erae the sector strating from 0xd000. then decimal of 0xd000 is 53248 and divide by 128 means 416 so sector no. is 417 and whose hex is 0x1A1. but i cdnt..
I think you misunderstood the meaning of "sector count" - simply load dptr by 0xd000 and perform the IAP call...

JW

sanketbarot

thank you..
i have load DPTR with 0xd000. and it works fine...