GD32W51x User Manual
71
Note:
(1) As long as the wrong key is written to FMC_CTL/FMC_SECCTL, a bus error will be
generated, regardless of whether FMC_PRIV bit in FMC_PRIVCFG is set or not. (2) Write
wrong key to OBKEY does not generate a bus error.
2.4.4.
Page erase
The FMC provides a page erase function which is used to initialize the contents of a main
Flash memory page to a high state. Each page can be erased independently without affecting
the contents of other pages. Operate secure page or non-secure page using secure or non-
secure registers. The following steps show the access sequence of the registers for a page
erase operation.
Unlock the FMC_CTL
/FMC_SECCTL register if necessary.
Check the BUSY/SECBUSY bit in the FMC_STAT/FMC_SECSTAT register to con
firm that no Flash memory operation is in progress (BUSY/SECBUSY equals to
0). Otherwise, wait until the operation has finished.
Set the PER/SECPER bit in the FMC_CTL
/FMC_SECCTL register.
Write the page absolute address (0x08XX XXXX/0x0CXX XXXX) into the FMC_A
DDR/FMC_SECADDR registers.
Send the page erase command to the FMC by setting the START/SECSTART bit
in the FMC_CTL
/FMC_SECCTL register.
Wait until all the operations have finished by checking the value of the BUSY/SE
CBUSY bit in the FMC_STAT/FMC_SECSTAT register.
Read and verify the page using a DBUS access if required.
When the operation is executed successfully, the ENDF/SECENDF bit in the
FMC_STAT/FMC_SECSTAT register is set, and an interrupt will be triggered by FMC if the
ENDIE/SECENDIE bit in the FMC_CTL
/FMC_SECCTL register is set. Note that a correct
target page address must be confirmed. Otherwise, the software may run out of control if the
target erase page is being used to fetch codes or access data. The FMC will not provide any
notification when that happens. Additionally, the page erase operation will be ignored on
erase/program protected pages. In this condition, a Flash operation error interrupt will be
triggered by the FMC if the ENDIE/SECENDIE bit in the FMC_CTL
/FMC_SECCTL register is
set. The software can check the WPERR/SECWPERR bit in the FMC_STAT/FMC_SECSTAT
register to detect this condition in the interrupt handler. The following figure
Process of page erase operation
shows the page erase operation flow.