FLASH MEMORY VERSION
7902 Group User’s Manual
20-17
20.2 Flash memory CPU reprogramming mode
20.2.3 Data protect function
Each block of the internal flash memory is provided with a nonvolatile lock bit and can individually be
inhibited from being programmed or erased (i.e. be locked) according to the state of the corresponding lock
bit. Thus, this function prevents data from being inadvertently programmed or erased. The block states are
described below according to the contents of their lock bits:
When lock bit = “0”
Locked state. The corresponding block cannot be programmed or erased.
When lock bit = “1”
Unlocked state. The corresponding block can be programmed or erased.
Each lock bit is cleared to “0” (locked state) by executing the lock bit programming command and set to
“1” (unlocked state) by erasing the corresponding block. The lock bit cannot be set to “1” by any software
command.
The state of a lock bit can be read out with the read lock bit status command.
Setting the lock bit invalidity select bit (bit 2 at address 9E16) to “1” invalidates the functions of each lock
bit to put all the blocks into the unlocked state. (The contents of all lock bits do not change.) On the other
hand, clearing the lock bit invalidity select bit to “0” validates the functions of each lock bit. (The contents
of all lock bits are maintained.)
When the block erase or the erase all unlocked block command is executed with the lock bit invalidity
select bit = “1,” the corresponding block or all the blocks are erased regardless of the contents of their lock
bits. Upon completion of this erasure, the corresponding lock bit is set to “1” (unlocked state).
For details of each command, refer to section “20.2.5 Software commands.”
20.2.4 Setting and Terminate procedure for flash memory CPU reprogramming mode
Figure 20.2.2 shows the setting and terminate procedures for the flash memory CPU reprogramming mode.
In the flash memory CPU reprogramming mode, opcodes cannot be fetched for the internal flash memory.
Therefore, be sure to transfer the reprogramming control software to an area other than the internal flash
memory and then execute the software in that area.
Moreover, in order to prevent any interrupt occurrence during the flash memory CPU reprogramming mode,
the following procedures must be taken before selecting this mode:
Set the interrupt disable flag (I) to “1” or set the interrupt priority level to “0002” (interrupts disabled)
Apply the Vcc level voltage to pin NMI; or open pin NMI with the pin NMI pullup select bit (bit 7 at address
9216) = “0.”
Even in the flash memory CPU reprogramming mode, periodically writing to the watchdog timer is required
in order to prevent the watchdog timer interrupt occurrence.
At the same time, it is necessary to write to the watchdog timer before executing the page programming,
block erase, erase all unlocked block, or lock bit programming command in order to prevent the watchdog
timer interrupt occurrence during the automatic programming and erase operation.
Interrupt requests or resets generated in the flash memory CPU reprogramming mode bring about the
following results:
Maskable interrupts make program runaway. If a program runaway has occurred, be sure to push the
microcomputer into the power-on reset state.
Each of NMI and watchdog timer interrupts pushes the built-in flash memory control circuit and flash
memory control register into the reset state. This enables any of these interrupt requests to be accepted.
Each of hardware and software resets pushes the built-in flash memory control circuit and flash memory
control register into the reset state. Additionally, this causes the microcomputer to be reset. (Refer to
“CHAPTER 4. RESET.”)
When the above interrupts or resets are generated during the programming or erase operation, the contents
of the corresponding block becomes invalidated.