18-15
MSM66573 Family User's Manual
Chapter 18 Flash Memory
18
(2)
User mode programming program example
Listed below is an example program that programs data to flash memory addresses 5500H
through 557FH (128 bytes) and then verifies the data of those 128 bytes.
It is assumed that the data to be programed has already been stored in internal RAM
addresses 300H through 37FH.
MOV
FLAADRS,#5500H
Set the start address (5500H) for programming.
MOVB
FLAACP,#05H
MOVB
FLAACP,#0AH
Set the flash memory acceptor.
MOVB
FLACON,#11H
Set the PRG flag.
NOP
After execution of one instruction, the hold state
is entered and programming begins.
When
programming is complete, the hold state is
released.
MOV
DP,#300H
Set the internal RAM address in DP.
MOV
ER0,#5500H
Set the flash memory address in ER0.
SDD
Set the data descriptor.
LOOP:
LC
A, [ER0]
Load flash memory data into the accumulator.
CMP
A, [DP+]
Compare accumulator and internal RAM data,
then increment the internal RAM address by +2.
JC
NE,ERR
If they are not equal, jump to the error routine.
ADDB
R0,#02H
Increment the flash memory address by +2.
JBR
R0.7,LOOP
If verification of the 128 bytes is not complete,
jump to LOOP.
ERR:
Perform error processing.
18.6.5 Notes on Use of User Mode
Note the following items when generating a program to be used with the user mode.
If an interrupt occurs during programming of the flash memory, processing of the interrupt
is put on hold. The interrupt is processed after programming is completed.
If reset is initiated by input to the
RES pin during programming of the flash memory, the
reset is processed. However, the flash memory area that was in the process of being
programmed will have been incorrectly programmed.
If reset is initiated during
programming, reprogram the flash memory area that was in the process of being
programmed.
Do not program to the flash memory area that contains the programming program being
executing. (After programming is completed, the CPU program control will run out of
control.)
Development tools (emulator) cannot evaluate programming or erasing.