English
Language : 

H83048 Datasheet, PDF (636/905 Pages) Renesas Technology Corp – Renesas 16-Bit Single-Chip Microcomputer H8 Family/H8/300H Series
Section 19 Flash Memory (H8/3048F: Dual Power Supply (VPP = 12 V))
Sample Program for Erasing One Block: This program uses the following registers.
R0: Prewrite-verify and erase-verify fail counter
ER1: Stores address used in prewrite
ER2: Stores address used in prewrite and erase-verify
ER3: Stores address used in erase-verify
ER4: Timing loop counter
R5: Sets appropriate registers
R6: Sets appropriate registers
The values of #a, #c, #d, #e, #f, #g, and #h, in the program depend on the clock frequency. They
can be calculated as indicated in tables 19.9 and 19.10.
FLMCR: .EQU
FFFF40
EBR1: .EQU
FFFF42
EBR2: .EQU
FFFF43
TCSR: .EQU
FFFFA8
; #BLKSTR is top address of block to be erased
; #BLKEND is last address of block to be erased
MOV.L
#BLKSTR:32, ER1
MOV.L
#BLKEND:32, ER2
; Execute prewrite
PREWRT: MOV.W
#g,
R4
; ER1: top address of block to be erased
; ER2: last address of block to be erased
; Set wait counter
MOV.W
MOV.B
LOOPR0: DEC.W
#4140,
R6L,
#1,
R6
;
@FLMCR:8 ; Set VPPE bit
R4
;
BPL
LOOPR0
;
;SET EBR1 or EBR2 bit of block to be erased
MOV.B
MOV.B
PREWRN: SUB.B
MOV.W
PREWRS: MOV.B
#**,
R5H,
R0H,
#a,
#00,
R5H
@EBR*
R0H
E4
R5H
;
; Set EBR*
; R0: prewrite-verify fail count
; Set initial prewrite loop counter value
; Write #00 data
MOV.B
MOV.W
R5H,
@ER1
#A579, R5
;
; Start watchdog timer
MOV.W
R5,
MOV.W
E4,
@TCSR:16 ;
R4
; Set prewrite loop counter
MOV.W
#4140, R6
;
Rev. 7.00 Sep 21, 2005 page 612 of 878
REJ09B0259-0700