GD32E23x User Manual
50
only be programed once and cannot be erased.
Note:
It must ensure the OTP programming sequence completely without any unexpected
interrupt, such as system reset or power down. If unexpected interrupt occurs, there
is
very
little
probability
of
corrupt the data stored in flash memory.
2.3.8.
Option byte erase
The FMC provides an erase function which is used for initializing the option byte block in
flash. The following steps show the erase sequence.
Unlock the FMC_CTL register if necessary.
Unlock the OBWEN bit in FMC_CTL register if necessary.
Check the BUSY bit in FMC_STAT 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 option byte erase command into OBER bit in FMC_CTL register.
Send the option byte erase command to the FMC by setting the START bit in FMC_CTL
register.
Wait until all the operations have been completed by checking the value of the BUSY bit
in FMC_STAT register.
Read and verify the flash memory if required using a DBUS access.
When the operation is executed successfully, an interrupt will be triggered by FMC if the
ENDIE bit in the FMC_CTL register is set, and the ENDF in FMC_STAT register is set. The
end of this operation is indicated by the ENDF bit in the FMC_STAT register.
2.3.9.
Option byte programming
The FMC provides a 32-bit word/32-bit double word programming function which is used for
modifying the option byte block contents. The following steps show the programming
operation sequence.
Unlock the FMC_CTL register if necessary.
Unlock the OBWEN bit in FMC_CTL register if necessary.
Check the BUSY bit in FMC_STAT 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 program command into the OBPG bit in FMC_CTL register.
A 32-bit word/16-bit half word write at desired address by DBUS.
Wait until all the operations have been completed by checking the value of the BUSY bit
in FMC_STAT register.