
21.5 Access to the Flash Memory Area
A read or a program fetch cannot be performed on the whole of the flash memory area if data is being written to
the flash memory, if data in flash memory is being erased or if a security setting is being made in the flash memory.
When performing these operation on the flash memory area, the flash memory cannot be directly accessed by using
a program in the flash memory; the flash memory must be accessed using a program in the BOOTROM area or the
RAM area.
Data can be written to and read from the flash memory area in units of one byte. Data in the flash memory can be
erased in units of 4 kbytes, and all data in the flash memory can be erased at one stroke. A read can be performed
using one memory transfer instruction. A write or erase, however, must be performed using more than one memory
transfer instruction because the command sequence method is used. For information on the command sequence, refer
Note 1: To allow a program to resume control on the flash memory area that is rewritten, it is recommended that you let
the program jump (return) after verifying that the program has been written properly.
Note 2: Do not reset the MCU (including a reset generated due to internal factors) when data is being written to the flash
memory, data is being erased from the flash memory or the security command is being executed. If a reset occurs,
there is the possibility that data in the flash memory may be rewritten to an unexpected value.
21.5.1
Flash memory control in serial PROM mode
The serial PROM mode is used to access the flash memory by using a control program provided in the BOOT-
ROM area. Since almost all operations relating to access to the flash memory can be controlled simply using data
supplied through the serial interface (UART or SIO), it is not necessary to operate the control register for the
user. For details of the serial PROM mode, see "Serial PROM Mode".
To access the flash memory in serial PROM mode by using a user-specific program or peripheral functions
other than UART and SIO, it is necessary to execute a control program in the RAM area by using the RAM loader
21.5.1.1
How to transfer and write a control program to the RAM area in RAM loader mode of the serial
PROM mode
How to execute a control program in the RAM area in serial PROM mode is described below. A control
program to be executed in the RAM area must be generated in the Intel-Hex format and be transferred using
the RAM loader of the serial PROM mode.
Steps 1 and 2 shown below are controlled by a program in the BOOTROM, and other steps are controlled
by a program transferred to the RAM area. The following procedure is linked with a program example to be
explained later.
1. Transfer the write control program to the RAM area in RAM loader mode.
2. Jump to the RAM area.
3. Set a nonmaskable interrupt vector in the RAM area.
4. Set FLSCR1<FLSMD> to "0y101", and specify the area to be erased by making the appropriate
FLSCR1<FAREA> setting. (Make the appropriate FLSCR1<ROMSEL> setting as required.)
Then set "0xD5" on FLSCR2<CR1EN>.
5. Execute the erase command sequence.
6. Read the same flash memory address twice consecutively.
(Repeat step 6 until the read values become the same.)
7. Specify the area (area erased in step 5 above) to which data is written by making the appropriate
FLSCR1<FAREA> setting. (Make the appropriate FLSCR1<ROMSEL> setting as required.)
Then set "0xD5" on FLSCR2<CR1EN>.
8. Execute the write command sequence.
9. Read the same flash memory address twice consecutively.
(Repeat step 9 until the read values become the same.)
TMP89FM42
Page 333
RA005