
Rev. 1.00
38 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
The FMC provides a page erase function which is used to reset partial content of Flash memory.
Any page can be erased independently without affecting others. The following steps show the
access sequence of the register for page erase.
▄
Check the 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 the page address to TADR register.
▄
Write the page erase command to OCMR register (Set CMD [3:0] = 0x8).
▄
Commit page erase command to FMC by setting OPCR register (Set OPM [3:0] = 0xA).
▄
Wait until all the operations have been completed by checking the value of OPCR register (OPM
[3:0] equals to 0xE).
▄
Read and verify the page if required.
Note that a correct target page address must be confirmed. The software may run out of control
if the target erase page is being used to fetch code or access data. The FMC will not provide
any notification when this happens. Additionally, the page erase operation will be ignored on
the protected pages. When this occurs, the OREF bit will be set by the FMC and then a Flash
Operation Error interrupt will be generated if the OREIEN bit in the OIER register is set. The
software can check the PPEF bit in the OISR register to detect this condition in the interrupt
handler. The following figure shows the page erase operation flow.
Is OPM equal to 0xE or 0x6 ?
Set TADR, OCMR
Commit command
by setting OPCR
Is OPM equal to 0xE ?
Finish
Start
Yes
No
Yes
No
Figure 8. Page Erase Operation Flowchart