Sample Program for Programming One Byte: This program uses the following registers.
R0:
Program-verify fail counter
R1:
Program-verify timing loop counter
ER2: Stores the address to be programmed as long word data. Valid addresses are H'00000000
to H'0001FFFF.
R3H: Stores data to be programmed as byte data
R4:
Sets and clears TCSR and FLMCR
E4:
Stores the initial program loop counter value
R5:
Clears FLMCR
E5:
Stores the program loop counter value
Arbitrary data can be programmed at an arbitrary address by setting the address in ER2 and the
data in R3H.
The values of #a, #b, and #g depend on the clock frequency. They can be calculated as indicated
under table 18-14.
FLMCR: .EQU FFFF40
EBR1: .EQU FFFF42
EBR2: .EQU FFFF43
TCSR: .EQU FFFFA8
PRGM: MOV.W #0001, R0 ;
Program-verify fail count
MOV.W #g, R1 ;
Set program loop counter
MOV.W #4140, R4 ;
MOV.B R4L, @FLMCR:8 ;
Set V
PP
E bit
LOOP0: DEC.W #1, R1 ;
BPL LOOP0
MOV.B #**, R0H ;
MOV.B R0H, @EBR*:8 ;
Set EBR*
MOV.B R3H, @ER2 ;
Dummy write
MOV.W #a, E4 ;
Set initial program loop counter value
PRGMS: MOV.W #A579, R4 ;
Start watchdog timer
MOV.W R4, @TCSR:16 ;
MOV:W E4, E5 ;
Set program loop counter
MOV.W #4140, R4 ;
MOV.B R4H, @FLMCR:8 ;
Set P bit
LOOP1: DEC.W #1, E5 ;
Program
BPL LOOP1 ;
MOV.B R4L, @FLMCR:8 ;
Clear P bit
MOV.W #A500, R4 ;
MOV.W R4, @TCSR:16 ;
Stop watchdog timer
MOV:W #b , R1 ;
Set program-verify loop counter
MOV.B #44, R4H ;
MOV.B R4H, @FLMCR:8 ;
Set PV bit
LOOP2: DEC.W #1, R1 ;
Wait
BPL LOOP2 ;
MOV.B @ER2, R1H ;
Read programmed address
592
www.DataSheet4U.com