
Rev. 1.00
49 of 576
January 28, 2022
32-Bit Arm
®
Cortex
®
-M0+ MCU
HT32F54231/HT32F54241/HT32F54243/HT32F54253
4 Flash Memory Controller (FMC)
4 Flash Memory Controller (FMC)
Word Programming
The FMC provides a 32-bit word programming function which is used to modify the Flash memory
contents. The following steps show the word programming 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 word address to the TADR register. Write the word data to the WRDR register.
3. Write the word programming command to the OCMR register (Set CMD [3:0] = 0x4).
4. Commit the word programming command to the FMC by setting the OPCR register (Set OPM [3:0]
= 0xA).
5. Wait until all the operations have been finished by checking the value of the OPCR register (OPM [3:0]
is equal to 0xE).
6. Read and verify the Flash memory if required.
Note that the word programming operation cannot be successively applied to the same address
twice. Successive word programming operation to the same address must be separated by a page
erase operation. Additionally, the word programming 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 word programming operation flow.
Is OPM equal to 0xE or 0x6 ?
Set TADR, WRDR
and OCMR
Commit command
by setting OPCR
Is OPM equal to 0xE ?
Finish
Start
Yes
No
Yes
No
Figure 12. Word Programming Operation Flowchart