
LD
(SYSCR3),0x00
; Set RAREA and RVCTR to "0"
LD
(SYSCR4),0xD4
; Enable Code
:
J
XXXX
; #### Program to be executed in RAM ####
sRAMprogStart:
; Interrupt subroutine
sINTWDT:
sINTSWI:
LD
IX,0xF000
LD
A,(IX)
CMP
A,(IX)
J
NZ,sINTWDT
; Loop until the read values become the same
LD
(SYSCR2),0x10
; Generate system clock reset
RETN
sRAMprogEnd:
NOP
Note 1: It is not necessary to add DI instruction for above example program, because the support program include it.
However, the support program does not include EI instruction. Therefore, if interrupt process is used, enable IMF
after finishing all above process.
21.5.2.3
How to set the security program by using a support program (API) of BOOTROM
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 "0xD5" to A register as enable code.
6. Set "0x00" to C register.
7. Call address (0x1016). (After processing, security program state returns to A register.)
8. If A register is not "0xFF", jump to sSKIP because security program is already set.
9. Set "0xD5" to A register as enable code.
10. Set "0x00" to C register.
11. Call address (0x1016). (Security program is performed.)
12. Set "0xD5" to FLSCR2 after setting FLSCR1<BAREA> to "0".
13. Set "0xD4" to SYSCR4 after setting SYSCR3<RAREA, RVCTR> to "0".
Example: Whether the security program is enabled or disabled is checked. If it is disabled, it is enabled.
.BTWrite
equ 0x1010
; Write data to the flash memory
.BTEraseSec
equ 0x1012
; Sector Erase
.BTEraseChip equ 0x1014
; Chip Erase
.BTGetRP
equ 0x1016
; Check the status of the security program
.BTSetRP
equ 0x1018
; Enable the security program
cRAMStartAdd equ 0x0200
; RAM start address
main section code abs = 0xF000
; #### Transfer the program to RAM ####
LD
HL,cRAMStartAdd
LD
IX,sRAMprogStart
sRAMLOOP:
LD
A,(IX)
; Transfer the program from sRAMprogStart to
TMP89FM42
21. Flash Memory
21.5 Access to the Flash Memory Area
Page 342
RA005