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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/08/07 07:58
Read: times


 
#146759 - what's the program of my sectr erase code
Now I am using P89V51RD2's IAP routine .


I used sector erase command of P89V51RD2 to erase code form 0x000 to 0xd000.
But when I used commercial programer to read the code content of the chip,I found that only part of the code(0000H--01FFH) area was erased.
Here is my erase code( part of my program):
;subfunction: ERASE
;description: erase sector range from 0 t0 1A0H(416)
ERASE:
MOV R4, #00H ;sector high byte
MOV R5, #00H ; sector low byte
ERASE_EXEC:
MOV ACC, R4
MOV DPH, ACC
MOV ACC, R5
MOV DPL, ACC
LCALL IAP_EraseSector
INC R5 ;pointer to next sector
CJNE R5, #0A0H, ERASE0
CJNE R4, #01H, ERASE0
LJMP IntelHEX_LOAD ;jump to main loop
ERASE0:
CJNE R5, #00H,ERASE_EXEC
INC R4
CJNE R4, #01H, ERASE_EXEC
CJNE R5, #0A0H, ERASE_EXEC
LJMP IntelHEX_LOAD ;jump to mainloop

;subfunction name: IAP_EraseSector
;function: The routine to erase chip'code area which divided into 512 sector( 0-511)
;Input: Input parameters store in DPH,DPL,ACC
;Oput: return parameter in the ACC
IAP_EraseSector:
;PUSH ACC
;PUSH DPH
;PUSH DPL
MOV R1,#08H ;erase sector which range 0 to 511
ANL FCF,#0FCH ;Claer BSEL enable boot1
LCALL PGM_MTP ; call IAP routine
;ORL FCF,#01H ;jump to user program
;POP DPL
;POP DPH
;POP ACC
JNZ IAP_EraseSector
RET



List of 5 messages in thread
TopicAuthorDate
what's the program of my sectr erase code            01/01/70 00:00      
   reply            01/01/70 00:00      
   remarks            01/01/70 00:00      
      It works now            01/01/70 00:00      
         congratulations            01/01/70 00:00      

Back to Subject List