GD32F10x User Manual
51
The following steps show the erase sequence.
Unlock the FMC_CTL0 register if necessary.
Check the BUSY bit in FMC_STAT0 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 bits in FMC_CTL0 register if necessary.
Wait until OBWEN bit is set in FMC_CTL0 register.
Set OBER bit in FMC_CTL0 register.
Send the option bytes erase command to the FMC by setting the START bit in
FMC_CTL0 register.
Wait until all the operations have been finished by checking the value of the BUSY bit in
FMC_STAT0 register.
Read and verify the flash memory if required using a DBUS access.
When the operation is executed successful, the ENDF in FMC_STAT0 register is set, and an
interrupt will be triggered by FMC if the ENDIE bit in the FMC_CTL0 register is set.
2.3.8.
Option bytes modify
The FMC provides an erase and then program function which is used to modify the option
bytes block in flash. There are 8 couples option bytes. The MSB is the complement of the
LSB in each pair. And when the option bytes are modified, the MSB is generated by FMC
automatically, not the value of input data. The following steps show the erase sequence.
Unlock the FMC_CTL0 register if necessary.
Check the BUSY bit in FMC_STAT0 register to confirm that no Flash memory operation
is in progress (BUSY equals to 0). Otherwise, wait until the operation has finished.
Unlock the option bytes operation bits in FMC_CTL0 register if necessary.
Wait until OBWEN bit is set in FMC_CTL0 register.
Set the OBPG bit in FMC_CTL0 register.
A 32-bit word/16-bit half word write at desired address by DBUS.
Wait until all the operations have been finished by checking the value of the BUSY bit in
FMC_STAT0 register.
Read and verify the flash memory if required using a DBUS access.
When the operation is executed successfully, the ENDF in FMC_STAT0 register is set, and
an interrupt will be triggered by FMC if the ENDIE bit in the FMC_CTL0 register is set. Note
that the word/half word programming operation checks the address if it has been erased. If
the address has not been erased, PGERR bit in the FMC_STAT0 register will set when
program the address except programming 0x0.
The modified option bytes only take effect after a system reset is generated.
2.3.9.
Option bytes description
The option bytes block is reloaded to FMC_OBSTAT and FMC_WP registers after each
Summary of Contents for GD32F10 Series
Page 63: ...GD32F10x User Manual 63 programmed during the chip production ...
Page 117: ...GD32F10x User Manual 117 010 1 0 011 0 9 ...
Page 416: ...GD32F10x User Manual 416 shadow register updates every update event ...
Page 427: ...GD32F10x User Manual 427 value ...
Page 518: ...GD32F10x User Manual 518 These bits are not used in SPI mode ...