
ML66525 Family User’s Manual
Chapter 20
Flash Memory
20 - 12
20.6.4 User Mode Programming Example
(1)
User mode programming flowchart example
Figure 20-10 shows a flowchart for user mode programming of flash memory.
Since an auto-erase function is prepared, flash memory does not have to be erased prior to
programming.
Set the CPU operating clock
to 1/2 OSCCLK
1)
Set FLAADRS with the upper 10 bits (FA7 to FA16) of the address
desired to write to in 128-byte units.
Write a “0” and a “1” to bit 7 and bit 6 of the standby control register
(SBYCON) respectively.
2)
Using serial I/O or external memory access, set the programming
data in internal RAM addresses 300H through 37FH.
3)
Write the consecutive values of n5H, nAH (n = 0 to F) to FLAACP to
set the flash memory acceptor to “1”.
After completion of flash
memory programming, the flash memory acceptor is reset to “0” by a
16-bit timer 0 interrupt.
Set the PRG flag
4)
Set the program (PRG) flag of FLACON.
A 16-bit timer 0 interrupt
causes the PRG flag to be reset to “0”.
5)
Since the flash memory programming time is managed by the 16-bit
timer 0, enable 16-bit timer 0 interrupts only.
Disable all the other
interrupts.
6)
The microcontroller enters the HALT mode at the beginning of the
next instruction.
7)
When the CPU enters the HALT mode, data in internal RAM
addresses 300H through 37FH is transferred to the flash memory,
and programming (with the auto-erase function) is performed.
8)
After completion of flash memory programming, release the HALT
mode by a 16-bit timer 0 interrupt.
9)
10)
11)
1)
2)
3)
4)
5)
6)
7)
8)
9)
10) Verify that data has been written to the flash memory.
ROM table
reference instructions may be used to verify the data.
11) Return the CPU operating clock to the clock used by the program.
Start
Set the programming address
in FLAADRS
Set programming data in internal
RAM addresses 300H to 37FH
Write the count value into the
16-bit
Set the microcontroller to
the HALT mode
Programming execution
Verify the programmed data
Release the HALT mode by
a 16-bit timer 0 interrupt
Return the CPU operating clock
to the original state
Programming complete
Set the flash memory acceptor
(Note) It is impossible to write data or verify the written data using an
external program.
Figure 20-10
Programming Flowchart Example