
Rev. 1.00
42 of 486
July 31, 2018
32-Bit Arm
®
Cortex
®
-M0+ MCU
HT32F50231/HT32F50241
4 Flash Memory Controller (FMC)
4 Flash Memory Controller (FMC)
Page Erase / Program Protection
FMC provides functions of page erase / program protection to prevent unexpected operation of Flash
memory. The page erase (CMD [3:0] = 0x8 in the OCMR register) or word programming (CMD [3:0]
= 0x4) command will not be accepted by FMC on the protected pages. When the page erase or word
programming command aimed at the protected pages is sent to the FMC, the PPEF bit in the OISR
register will then be set by the FMC and the Flash operation error interrupt will be triggered to inform
the CPU if the OREIEN bit in the OIER register is set. The page protection function can be enabled for
each page independently by setting the OB_PP registers of the Option Byte. The following table shows
the access permission of the main Flash page when the page protection is enabled.
Table 7. Access Permission of Protected Main Flash Page
Mode
Operation
ISP / IAP
ICP / Debug Mode
Read
O
O
Program
X
X
Page Erase
X
X
Mass Erase
O
O
Notes:
1. Note that the setting of write protection is based on page. The above access permission only
affects the pages that enable protection function. Other pages are not affected.
2. Main Flash page protection is configured by OB_PP [127:0]. Option Byte is physically
located at the last page of main Flash Option Byte page protection is configured by the
OB_CP [1] bit.
3. The page erase on Option Byte area can disable the page protection of main Flash.
4. The page protection of Option Byte can only be disabled by a mass erase operation.
The following steps show the register access sequence for page erase / program protection procedure.
▄
Check OPCR register to confirm that no Flash memory operation is in progress (OPM [3:0]
equals to 0xE or 0x6). Otherwise, wait until the previous operation has been finished.
▄
Write OB_PP address to TADR register (TADR = 0x1FF0_0000).
▄
Write the data, which indicates the protection function of corresponding page is enabled or
disabled, to the WRDR register (0: Enabled, 1: Disabled).
▄
Write word programming command to the OCMR register (Set CMD [3:0] = 0x4).
▄
Commit word programming command to FMC by setting the OPCR register (Set OPM [3:0] = 0xA).
▄
Wait until all operations have been finished by checking the value of the OPCR register (OPM [3:0]
equals to 0xE).
▄
Read and verify the Option Byte if required.
▄
The OB_CK field in the Option Byte must be updated according to the Option Byte checksum rule.
▄
Apply a system reset to active the new OB_PP setting.