
GD32F403xx User Manual
44
2.3.6.
Main flash programming
The FMC provides a 32-bit word/16-bit half word/bit programming function which is used to
modify the main f lash memory contents. The f ollowing steps show the register access
sequence of the word programming operation.
1.
Unlock the FMC_CTLx registers if necessary;
2.
Check the BUSY bit in FMC_STATx registers to confirm that no flash memory operation
is in progress (BUSY equals to 0). Otherwise, wait until the operation has finished;
3.
Set the PG bit in FMC_CTLx registers;
4.
Write a 32-bit word/16-bit half word to desired absolute address (0x08XX XXXX) by
DBUS;
5.
Wait until all the operations have been finished by checking the value of the BUSY bit in
FMC_STATx registers;
6.
Read and verify the Flash memory if required using a DBUS access.
When the operation is executed successfully, the ENDF in FMC_STATx registers is set, and
an interrupt will be triggered by FMC if the ENDIE bit in the FMC_CTLx registers is set. Note
that the word/half word programming operation checks the address if it has been erased. If
the address has not been erased, PGERR bit in the FMC_STATx registers will be set when
program the address except programming 0x0. Note that the PG bit must be set before the
word/half word programming operation. Additionally, the program operation will be ignored on
erase/program protected pages and WPERR bit in FMC_STATx is set. In these conditions, a
f lash operation error interrupt will be triggered by the FMC if the ERRIE bit in the FMC_CTLx
registers is set. The sof tware can check the PGERR bit or WPERR bit in the FMC_STATx
registers to detect which condition occurred in the interrupt handler.
displays the word programming operation flow.