Page 318
21. Flash Memory
21.4 Toggle Bit (D6)
TMP89FM42
RA003
21.5.2 Flash memory control in MCU mode
In MCU mode, a write can be performed on the flash memory by executing a control program in RAM or
using a support program (API) provided inside BOOTROM.
21.5.2.1 How to write to the flash memory by transferring a control program to the RAM area
This section describes how to execute a control program in RAM in MCU mode. A control program to
be executed in RAM must be acquired and stored in the flash memory or it must be imported from an out-
side source through a communication pin. (The following procedure assumes that a program copy is pro-
vided inside the flash memory.)
Steps 1 through 5 and 11 shown below concern the control by a program in the flash memory, and other
steps concern the control by a program transferred to RAM. The following procedure is linked with a pro-
gram example to be described later.
1. Set the interrupt master enable flag to "disable (DI)" (IMF
←
"0").
2. Transfer the write control program to RAM.
3. Establish the nonmaskable interrupt vector in the RAM area.
4. After setting both SYSCR3<RAREA> and SYSCR3<RVCTR> to "1", set "0xD4" on FLSCR4.
Then allocate RAM to the code area, and switch the vector area to the RAM area.
5. Invoke the erase processing program in the RAM area by generating a CALL instruction.
6. 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 necessary.)
Then set "0xD5" on FLSCR2<CR1EN>.
7. Execute the erase command sequence.
8. Perform a read on the same address in the flash memory twice consecutively. (Repeat this step
until the read values become the same.)
9. After setting FLSCR1<FLSMD> to "0y010" and FLSCR1<FAREA> to "0y00", set "0xD5" on
FLSCR2<CR1EN>. (This disables the execution of the command sequence and returns FAREA
to the initial state of mapping.)
10. Generate the RET instruction to return to the flash memory.
11. Invoke the write program in the RAM area by generating a CALL instruction.
12. Set FLSCR1<FLSMD> to "0y101", and make the appropriate FLSCR1<FAREA> setting to
specify the area (area erased by performing step 7 above) on which a write is to be performed.
(Make the appropriate FLSCR1<ROMSEL> setting, as necessary.) Then set "0xD5" on
FLSCR2<CR1EN>.
13. Execute the write command sequence.
14. Perform a read on the same address in the flash memory twice consecutively.
(Repeat this step until the read values become the same.)
15. After setting FLSCR1<FLSMD> to "0y010" and FLSCR1<FAREA> to "0y00", set "0xD5" on
FLSCR2<CR1EN>. (This disables the execution of the command sequence and returns FAREA
to the initial state of mapping.)
16. Generate the RET instruction to return to the flash memory.
Note 1: Before writing data to the flash memory from the RAM area in MCU mode, the vector area must be
switched to the RAM area by using SYSCR3<RVCTR>, data must be written to the vector addresses
(INTUNDEF, INTSWI: 0x01F8 to 0x01F9, INTWDT: 0x01FC to 0x01FD) that correspond to non-
maskable interrupts, and the interrupt subroutine (RAM area) must be defined. This allows you to trap
the errors that may occur due to an unexpected nonmaskable interrupt during a write. If
SYSCR3<RVCTR> is set in the flash memory area and if an unexpected interrupt occurs during a
write, a malfunction may occur because the vector area in the flash memory cannot be read properly.
Note 2: Before using a certain interrupt in MCU mode, the vector address corresponding to that interrupt and
the interrupt service routine must be established inside the RAM area. In this case, the nonmaskable
interrupt setting must be made, as explained in Note 1.
Summary of Contents for TLCS-870/C1 Series
Page 1: ...8 Bit Microcontroller TLCS 870 C1 Series TMP89FM42 查询TMP89FM42供应商 捷多邦 专业PCB打样工厂 24小时加急出货 ...
Page 3: ...Revision History Date Revision 2007 10 25 1 First Release 2007 11 3 2 Contents Revised ...
Page 4: ......
Page 14: ......
Page 18: ...1 3 Block Diagram TMP89FM42 1 3 Block Diagram Figure 1 2 Block Diagram ...
Page 22: ...1 4 Pin Names and Functions TMP89FM42 ...
Page 60: ...2 CPU Core 2 5 Revision History TMP89FM42 ...
Page 76: ...3 Interrupt Control Circuit 3 8 Revision History TMP89FM42 ...
Page 86: ...4 External Interrupt control circuit 4 3 Function TMP89FM42 ...
Page 102: ...7 Voltage Detection Circuit 7 5 Revision History TMP89FM42 ...
Page 126: ...8 I O Ports 8 3 I O Port Registers TMP89FM42 Note 2 i 0 to 1 ...
Page 136: ...8 I O Ports 8 5 Revision History TMP89FM42 ...
Page 142: ...9 Special Function Registers 9 3 SFR3 0x0E40 to 0x0EFF TMP89FM42 ...
Page 146: ...10 Low Power Consumption Function for Peripherals TMP89FM42 ...
Page 149: ...TMP89FM42 11 3 Revision History Rev Description RA001 Deleted SLEEP2 description ...
Page 150: ...11 Divider Output DVO 11 3 Revision History TMP89FM42 ...
Page 220: ...15 Real Time Clock RTC 15 4 Real Time Clock Operation TMP89FM42 ...
Page 250: ...16 Asynchronous Serial Interface UART 16 15 Revision History TMP89FM42 ...
Page 302: ...18 Serial Bus Interface SBI 18 7 Revision History TMP89FM42 ...
Page 338: ...21 Flash Memory 21 4 Toggle Bit D6 TMP89FM42 ...
Page 384: ...22 Serial PROM Mode 22 15 Revision History TMP89FM42 ...
Page 388: ...24 Input Output Circuit 24 1 Control Pins TMP89FM42 ...
Page 404: ...25 Electrical Characteristics 25 11 Revision History TMP89FM42 ...
Page 406: ...26 Package Dimensions TMP89FM42 ...
Page 408: ......