S3F80P5_UM_ REV1.00 EMBEDDED FLASH MEMORY INTERFACE
Case3. Programming to the flash memory space located in other sectors
•
•
WR_INSECTOR2:
LD R0,#40H
LD R1,#40H
SB1
LD FMUSR,#0A5H ; User program mode enable
LD FMCON,#01010000B ; Selection programming mode and Start programming
LD FMSECH,#01H ; Set the base address of sector located in target address to write data
LD FMSECL,#00H ; The sector 2’s base address is 100H
LD R9,#0CCH ; Load data “CCH” to write
LD R10,#01H ; Load flash memory upper address into upper register of pair working
; register
LD R11,#40H ; Load flash memory lower address into lower register of pair working
; register
CALL WR_BYTE
LD R0,#40H
WR_INSECTOR50:
LD FMSECH,#19H ; Set the base address of sector located in target address to write data
LD FMSECL,#00H ; The sector 50’s base address is 1900H
LD R9,# 55H ; Load data “55H” to write
LD R10,#19H ; Load flash memory upper address into upper register of pair working
; register
LD R11,#40H ; Load flash memory lower address into lower register of pair working
; register
CALL WR_BYTE
WR_INSECTOR128:
LD FMSECH,#40H ; Set the base address of sector located in target address to write data
LD FMSECL,#00H ; The sector 128’s base address is 4000H
LD R9,#0A3H ; Load data “A3H” to write
LD R10,#40H ; Load flash memory upper address into upper register of pair working
; register
LD R11,#40H ; Load flash memory lower address into lower register of pair working
; register
WR_BYTE1:
LDC @RR10,R9 ; Write data 'A3H' at flash memory location
INC R11
DJNZ R1,WR_BYTE1
LD FMUSR,#00H ; User Program mode disable
SB0
•
•
WR_BYTE:
LDC @RR10,R9 ; Write data written by R9 at flash memory location
INC R11
DJNZ R0,WR_BYTE
RET
14-15