![](http://datasheet.mmic.net.cn/390000/SAB88C166W-5M_datasheet_16832339/SAB88C166W-5M_25.png)
SAB 88C166(W)
Semiconductor Group
24
G
Enter writing mode via unlock sequence
(prerequisite for any programming or erase
operation).
MOV
MOV
CALL
FCR, Rw
n
[Rw
n
], Rw
n
cc_UC, WAIT_10
; Dummy write to the FCR
; Both operands use the same GPR
; Delay for 10
μ
s
G
Program the FCR register
with a value that selects erase mode. Note that this does not yet start
the erase operation itself.
MOV
R15, #1000 00XX 0110 0011B
; #xxxx xxxx xxxx xxx1: FWE=’1’:
; #xxxx xxxx xxxx xx1x: FEE=’1’:
; #xxxx xxxx x11x xxxx: CKCTL=’11’:
; #xxxx xxXX xxxx xxxx: BE=’xx’:
; #1xxx xxxx xxxx xxxx: FWMSET=’1’:
DPP1:pof FCR, R15
Enable Flash write operations
Select erase mode
10 ms erase pulse (fCPU = 20 MHz)
Select the desired bank (3...0)
Stay in writing mode
; Write Value to the FCR using 16-bit access
MOV
G
Initialize target pointer
with the start address of the selected Flash memory bank. The Flash
memory must be accessed indirectly and uses the pointer FLASH_PTR. This pointer will apply
to DPP0 or DPP1, which are expected to select data pages 4 or 5, respectively.
G
Test for correct V
PP
margin at pin V
PP
/EBC1
before an erase operation is started. If bit
VPPREV reads ‘1’, the erase voltage is correct and the algorithm can be continued. Otherwise,
the erase routine could wait in Flash writing mode until V
PP
reaches its correct value and resume
erasing then, or it could exit writing mode.
MOV
JB
…
Vpp_OK2:
R15, DPP1:pof FCR
R15.4, Vpp_OK2
; Read FCR contents using 16-bit access
; Test V
PP
via bit VPPREV (= FCR.4)
; VPPREV=’0’: Exit erase procedure
; VPPREV=’1’: Test Okay! Continue
G
Initialize loop counter
(PCOUNT) with the maximum number of erase trials (ENmax) to be
performed before exiting the routine with a failure. Each trial means applying a pulse of 10 ms to
the selected Flash memory bank. According to the maximum cumulated erase time of 30 s
allowed per cell, ENmax must be ‘3000’ here.
G
Erase selected Flash memory bank
by writing to a Flash memory location using the target
address as write data.
MOV
[FLASH_PTR], FLASH_PTR
; Write address to Flash, starts erasing
G
Wait until erase time elapsed
, which depends on bit field CKCTL in the FCR register and on the
CPU clock frequency (10 ms in this example). End of erasing is detected by polling the FBUSY
flag in the FCR register. The Flash memory switches to EVM mode automatically.