S3F84B8_UM_REV 1.00
19 EMBEDDED FLASH MEMORY INTERFACE
19-11
Example 19-2 Programming
Case1. 1-Byte Programming
WR_BYTE:
; Writes data “AAH” to destination address 0310H
LD FMUSR,#0A5H
; Enables User Program mode
LD
FMCON,#01010000B ; Selects Programming mode
LD
FMSECH, #03H ; Sets the base address of sector (0300H)
LD
FMSECL, #00H
LD
R9,#0AAH ; Loads data “AA” to write
LD R10,#03H
; Loads flash memory upper address into upper register of pair working
; register
LD
R11,#10H
; Loads flash memory lower address into lower register of pair working
; register
LDC @RR10,R9
; Writes data “AAH” to flash memory location (0310H)
LD
FMUSR,#00H
; Disables User Program mode
Case2. Programming in the same sector
WR_INSECTOR:
; RR10-->Address copy (R10-high address,R11-low address)
LD
R0,#40H
LD
FMUSR,#0A5H
; Enables User Program mode
LD
FMCON,#01010000B ; Selects Programming mode and starts programming
LD
FMSECH,#06H ; Sets the base address of sector located in target address to write data
LD
FMSECL,#00H
; Sector 12’s base address is 0600H.
LD
R9,#33H ; Loads data “33H” to write
LD R10,#06H
; Loads flash memory upper address into upper register of pair working
; register
LD
R11,#00H
; Loads flash memory lower address into lower register of pair working
; register
WR_BYTE:
LDC @RR10,R9
; Writes data “33H” to flash memory location
INC
R11
; Resets address in the same sector by INC instruction