
GD32F403xx User Manual
41
2.3.4.
Page erase
The FMC provides a page erase f unction which is used to initialize the contents of a main
f lash memory page to a high state. Each page can be erased independently without affecting
the contents of other pages. The f ollowing steps show the access sequence of the registers
f or a page erase 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 PER bit in FMC_CTLx registers;
4.
Write the page absolute address (0x08XX XXXX) into the FMC_ADDRx registers;
5.
Send the page erase command to the FMC by setting the START bit in FMC_CTLx
registers;
6.
Wait until all the operations have f inished by checking the value of the BUSY bit in
FMC_STATx registers;
7.
Read and verify the page 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 a correct target page address must be confirmed. Or the software may run out of control
if the target erase page is being used to f etch codes or to access data. The FMC will not
provide any notif ication when this occurs. Additionally, the page erase operation will be
ignored on erase/program protected pages. In this condition, a f lash operation error interrupt
will be triggered by the FMC if the ERRIE bit in the FMC_CTLx registers is set. The software
can check the WPERR bit in the FMC_STATx registers to detect this condition in the interrupt
handler.
Figure 2-1. Process of page erase operation
shows the page erase operation flow.