![Hitachi H8/3152 Скачать руководство пользователя страница 92](http://html.mh-extra.com/html/hitachi/h8-3152/h8-3152_hardware-manual_140481092.webp)
89
Page 0
H'FF
Data area
Protection area
Can be written
only once
Page 2
H'FC
H'FF
H'FC
.
.
.
.
.
.
: Write/erase-protected pages
Page 1
Page 263
Figure 8.13 Example of Write/Erase Protection (H8/3153)
8.5.2
Protection Procedure
To protect a page, software must set the EPR and ECR registers, then write the protection code
(H'78) to the protect bits.
The protection procedure is given next. Figure 8.14 shows a flowchart.
1. Set the EWE bit in TCSR of WDT to 1 to enable EPR and ECR writing.
2. Clear the
PBM
bit in EPR to 0 to select the protection area. The OC1 and OC0 bits in ECR will
then be automatically set to 1, disabling EEPROM writing and erasing.
3. Clear the OC1 bit in ECR to 0. The OC0 bit may be set to either 1 or 0.
4. Execute the EEPMOV instruction to write the protection code, H'78, to the protect bits. The
address of the protect bits is the same as the top byte address in the page to be protected.
After the protection code has been written, EPR automatically reverts to select the data area, and
ECR is set to the write/erase-disabled state (OC1 = OC0 = 1).
Steps 1 to 4 must be carried out in that order for each page protected.