
Rev. 1.00
48 of 576
January 28, 2022
32-Bit Arm
®
Cortex
®
-M0+ MCU
HT32F54231/HT32F54241/HT32F54243/HT32F54253
4 Flash Memory Controller (FMC)
Mass Erase
The FMC provides a mass erase function which is used to initialize all the main Flash memory
contents to a high state. The following steps show the mass erase operation register access
sequence.
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 mass erase command to the OCMR register (Set CMD [3:0] = 0xA).
3. Commit the mass erase command to the FMC by setting the OPCR register (Set OPM [3:0] =
0xA).
4. Wait until all the operations have been finished by checking the value of the OPCR register (OPM [3:0]
is equal to 0xE).
5. Read and verify the Flash memory if required.
Since all Flash data will be reset as 0xFFFF_FFFF, the mass erase operation can be implemented
by the program that runs on the SRAM or by the debugging tool that accesses the FMC registers
directly. The application program that is executed on the Flash memory will not trigger a mass
erase operation. The following figure shows the mass erase operation flow.
Is OPM equal to 0xE or 0x6 ?
Set OCMR = 0xA
Commit command
by setting OPCR
Is OPM equal to 0xE ?
Finish
Start
Yes
No
Yes
No
Figure 11. Mass Erase Operation Flowchart