UM10147_2
© NXP B.V. 2008. All rights reserved.
User manual
Rev. 02 — 28 April 2008
110 of 134
NXP Semiconductors
UM10147
P89LPC952/954 User manual
An assembly language routine to load the page register and perform an erase/program
operation is shown below.
;**************************************************
;*
pgm user code
*
;**************************************************
;*
*
;* Inputs:
*
;* R3 = number of bytes to program (byte)
*
;* R4 = page address MSB(byte)
*
;* R5 = page address LSB(byte)
*
;* R7 = pointer to data buffer in RAM(byte)
*
;* Outputs:
*
;* R7 = status (byte)
*
;* C = clear on no error, set on error
*
;**************************************************
LOAD
EQU
00H
EP
EQU
68H
PGM_USER:
MOV
FMCON,#LOAD
;load command, clears page register
MOV
FMADRH,R4
;get high address
MOV
FMADRL,R5
;get low address
MOV
A,R7
;
MOV
R0,A
;get pointer into R0
LOAD_PAGE:
MOV
FMDAT,@R0
;write data to page register
INC
R0
;point to next byte
DJNZ
R3,LOAD_PAGE
;do until count is zero
MOV
FMCON,#EP
;else erase & program the page
MOV
R7,FMCON
;copy status for return
MOV
A,R7
;read status
ANL
A,#0FH
;save only four lower bits
JNZ
BAD
;
CLR
C
;clear error flag if good
3
HVA
R
High voltage abort. Set if either an interrupt or a brown-out is detected during a program or
erase cycle. Also set if the brown-out detector is disabled at the start of a program or erase
cycle.
FMCMD.3
W
Command byte bit 3.
4:7
-
R
reserved
4:7
FMCMD.4
W
Command byte bit 4.
4:7
FMCMD.5
W
Command byte bit 5.
4:7
FMCMD.6
W
Command byte bit 6.
4:7
FMCMD.7
W
Command byte bit 7.
Table 100. Flash Memory Control register (FMCON - address E4h) bit description
…continued
Bit Symbol
Access
Description