
Rev. 1.00
52 of 576
January 28, 2022
32-Bit Arm
®
Cortex
®
-M0+ MCU
HT32F54231/HT32F54241/HT32F54243/HT32F54253
4 Flash Memory Controller (FMC)
Security Protection
The FMC provides a security protection function to prevent illegal code/data access to the Flash
memory. This function is useful for protecting the software/firmware from illegal users. The
function is activated by setting OB_CP [0] in the Option Byte. Once the function has been enabled,
all the main Flash data access through ICP/Debug mode, programming and page erase operation
will not be allowed except the user’s application. However the mass erase operation will still be
accepted by the FMC in order to disable this security protection function. The following table
shows the access permission of the Flash memory when the security protection is enabled.
Table 10. Access Permission When Security Protection is Enabled
Mode
Operation
User Application
(1)
ICP/Debug Mode
Read
O
X (read as 0)
Programming
O
(1)
X
Page Erase
O
(1)
X
Mass Erase
O
O
Notes:
1. User application means the software that is executed or booted from the main Flash
memory with the SW debugger being disconnected. However, the Option Byte area and
page 0 are still under protection, where the Programming/Page Erase operations are not
accepted.
2. The Mass Erase operation can erase the Option Byte area and disable the security
protection.
The following steps show the register access sequence for the security protection procedure.
1. Check the OPCR register to confirm that no Flash memory operation is in progress (OPM [3:0] is
equal to 0xE or 0x6). Otherwise, wait until the previous operation has been finished.
2. Write the OB_CP address to the TADR register (Set TADR = 0x1FF0_0010).
3. Write data to the WRDR register to set OB_CP [0] to 0.
4. Write the word programming command to the OCMR register (Set CMD [3:0] = 0x4).
5. Commit the word programming command to the FMC by setting the OPCR register (Set OPM =
0xA).
6. Wait until all the operations have been finished by checking the value of the OPCR register (OPM [3:0]
is equal to 0xE).
7. Read and verify the Option Byte if required.
8. The OB_CK field in the Option Byte area must be updated according to the Option Byte
checksum rule.
9. Apply a system reset to active the new OB_CP setting.