S3F80P5_UM_ REV1.00 EMBEDDED FLASH MEMORY INTERFACE
PROGRAMMING TIP — Sector Erase
Case1. Erase one sector
ERASE_ONESECTOR:
SB1
LD FMUSR,#0A5H ; User program mode enable
LD FMSECH,#40H ; Set sector address 4000H,sector 128,
LD FMSECL,#00H ; among sector 0~511
LD FMCON,#10100001B ; Select erase mode enable & Start sector erase
ERASE_STOP: LD FMUSR,#00H ; User program mode disable
SB0
s
Case2.Erase flash memory space from sector (n) to sector (n + m)
;;Pre-define the number of sector to erase
LD SecNumH,#00H ; Set sector number
LD SecNumL,#128 ; Selection the sector128 ( base address 4000H )
LD R6,#01H ; Set the sector range (m) to erase
LD R7,#7DH ; into High-byte(R6) and Low-byte(R7)
LD R2,Sec NumH
LD R3,SecNumL
ERASE_LOOP: CALL SECTOR_ERASE
XOR P4,#11111111B ; Display ERASE_LOOP cycle
INCW RR2
LD Sec NumH,R2
LD SecNumL,R3
DECW RR6
LD R8,R6
OR R8,R7
CP R8,#00H
JP NZ,ERASE_LOOP
14-9