GD32A50x User Manual
57
The unlocking sequence includes two write operations, which are writing 0x45670123 and
0xCDEF89AB to FMC_OBKEY register, then the OBWEN bit in FMC_CTL1 register is set by
hardware. The software can clear OBWEN bit to protect the OB0PG bit and OB0ER bit in
FMC_CTL1 register again.
2.3.6.
Page erase
The FMC provides a page erase function which is used for initializing 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. The following steps show the access sequence of the register
for a page erase operation.
Unlock the FMC_CTLx register if necessary.
Check the BUSY bit in FMC_STATx register to confirm that no flash memory operation
is in progress (BUSY equal to 0). Otherwise, wait until the operation has been finished.
Write the page address into the FMC_ADDRx register.
Write the page erase command into PER bit in FMC_CTLx register.
Send the page erase command to the FMC by setting the START bit in FMC_CTLx
register.
Wait until all the operations have been completed by checking the value of the BUSY bit
in FMC_STATx register.
Read and verify the page if required using a DBUS access.
When the operation is executed successfully, the ENDF in FMC_STATx register will be set.
An interrupt will be triggered by FMC if the ENDIE bit in the FMC_CTLx 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 for fetching codes or accessing data. The
FMC will not provide any notification when it occurs. Additionally, the page erase operation
will be ignored on protected pages. Flash operation error interrupt will be triggered by the
FMC if the ERRIE bit in the FMC_CTLx register is set. The software can check the WPERR
bit in the FMC_STATx register to detect this condition in the interrupt handler. The
Process of page erase operation
shows the page erase operation flow.