GD32A50x User Manual
67
Unlock the FMC_CTL1 register if necessary.
Check the BUSY bit in the FMC_STAT1 register to confirm that no flash memory
operation is in progress (BUSY equal to 0). Otherwise, wait until the operation has
finished.
Unlock the option bytes operation bit OBWEN in the FMC_CTL1 register if necessary.
Wait until the OBWEN bit is set in the FMC_CTL1 register.
Set the OB0ER bit in the FMC_CTL1 register.
Send the option bytes 0 erase command to the FMC by setting the START bit in the
FMC_CTL1 register.
Wait until all the operations have been finished by checking the value of the BUSY bit in
the FMC_STAT1 register.
Read and verify the flash memory using a DBUS access if required.
When the operation is executed successful, the ENDF bit in the FMC_STAT1 register is set,
and an interrupt will be generated if the ENDIE bit in the FMC_CTL1 register is set.
2.3.16.
Option bytes programming
Option bytes 0 programming
The FMC provides a 64-bit double word programming function which is used for modifying
the option byte 0 contents. The following steps show the programming operation sequence.
Unlock the FMC_CTL1 register if necessary.
Check the BUSY bit in FMC_STAT1 register to confirm that no flash memory operation
is in progress (BUSY equal to 0). Otherwise, wait until the operation has been finished.
Unlock the OBWEN bit in FMC_CTL1 register if necessary.
Wait until the OBWEN bit is set in the FMC_CTL1 register.
Write the program command into the OB0PG bit in FMC_CTL1 register.
Write the 64-bit data to be programmed by DBUS with desired absolute address.
Wait until all the operations have been completed by checking the value of the BUSY bit
in FMC_STAT1 register.
Read and verify the flash memory if required using a DBUS access.
When the operation is executed successfully, an interrupt will be generated if the ENDIE bit
in the FMC_CTL1 register is set, and the ENDF in FMC_STAT1 register is set. Note that to
check the address that it has been erased before the word programming operation. If the
address has not been erased, PGERR bit in the FMC_STAT1 register will be set when
programming the address even if programming 0x0. The end of this operation is indicated by
the ENDF bit in the FMC_STAT1 register.
Option bytes 1 programming
The following steps show the modify operation sequence.
Unlock the FMC_CTL1 register if necessary.