
21.5.2.2
How to write to the flash memory by using a support program (API) of BOOTROM
TMP89FH46L has following support program (API) inside BOOTROM.
Address
Contents
Using
Stack
(Note2)
Working
Register
(Note1)
Argument
Return value
Register
Setting Value
Register
Contents
0x1010
(.BTWrite)
Writing the data to speci-
fied address of one byte.
7bytes
WA
BC
DE
IX
WA
Specify the address to be
written.
-
C
0x00
E
Specify the data to be writ-
ten.
(SP-)
0xD5 (Enable Code)
0x1012
(.BTEraseSec)
Erasing the specified one
sector.
4bytes
WA
BC
DE
IX
A
Specify the address to be
erased.
-
C
0xD5 (Enable Code)
0x1014
(.BTEraseChip)
Executing the Chip
Erase.
6bytes
WA
BC
DE
IX
A
0xD5 (Enable Code)
-
C
0x00
0x1016
(.BTGetRP)
Getting the status of Se-
curity Program.
6bytes
WA
BC
DE
IX
A
0xD5 (Enable Code)
A
0xFF
Security Program
disabled.
C
0x00
Other
than
0xFF
Security Program
enabled.
0x1018
(.BTSetRP)
Setting the Security Pro-
gram.
6bytes
WA
BC
DE
IX
A
0xD5 (Enable Code)
-
C
0x00
Note 1: Working register is rewritten by support program.
Note 2: While the support program is executed, some bytes are used as stack.
This section describes how to perform an erase and a write on the flash memory by using a support program
(API) of BOOTROM in MCU mode.
Steps 1 through 16 shown below concern the control by a program in the flash memory.
1. Transfer the subroutine program of nonmaskable interrupt (INTSWI, INTWDT) to RAM.
2. Establish the nonmaskable interrupt vector in the RAM area.
3. After setting both SYSCR3<RAREA> and SYSCR3<RVCTR> to "1", set "0xD4" on SYSCR4.
Then allocate RAM to the code area, and switch the vector area to the RAM area.
4. Set "0xD5" on FLSCR2<CR1EN> after setting FLSCR1<BAREA> to "1".
5. Set the erasing address range to A register. For example, to erase sector area from 0xE000 through
0xEFFF, set 0x0E to register.To erase sector area from 0x1F000 through 0x1FFFF, set 0x1F to
register.
6. Set "0xD5" to C register as enable code.
7. Call address (0x1012). (Sector erase is performed. It is not necessary from 2 through 4 steps, if
programing area is already erased beforehand.)
8. Set "0x00" to C register.
9. Set A[15:0] of address for programing to WA register.
10. Set programing data to E register.
11. Set "0xD5" to (SP-) as enable code.
12. Call address (0x1010). (Byte program is performed)
13. If programing is continued for other address, return to step 8.
14. Set "0xD5" to FLSCR2 after setting FLSCR1<BAREA> to "0".
15. Set "0xD4" to SYSCR4 after setting SYSCR3<RAREA, RVCTR> to "0".
TMP89FH46L
21. Flash Memory
21.5 Access to the Flash Memory Area
Page 338
RA005