
GD32L23x User Manual
54
Read and verify the flash memory using a DBUS access if required.
When the operation is executed successful, the ENDF bit in the FMC_STAT register is set,
and an interrupt will be triggered by FMC if the ENDIE bit in the FMC_CTL register is set.
2.3.10.
Option bytes modify
The FMC provides an erase / program function which is used to modify the option bytes block
in flash. There are 8 pairs of option bytes. The MSB is the complement of the LSB in each
pair. 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_CTL register if necessary.
Check the BUSY bit in the FMC_STAT 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 the FMC_CTL register if necessary.
Wait until the OBWEN bit is set in the FMC_CTL register.
Set the OBPG bit in the FMC_CTL register.
A 32-bit word/16-bit half word write at desired address by DBUS. The write method is
similar to main flash programming.
Wait until all the operations have been finished by checking the value of the BUSY bit in
the FMC_STAT register.
Read and verify the flash memory if required using a DBUS access.
When the operation is executed successfully, the ENDF bit in the FMC_STAT register is set,
and an interrupt will be triggered by FMC if the ENDIE bit in the FMC_CTL register is set.
Note that there programming errors may occur. The PGERR bit and PGAERR bit can be set
which is similar to main flash programming.
The modified option bytes only take effect after a system reset.
2.3.11.
Option bytes description
The option bytes block is reloaded to the FMC_OBSTAT and FMC_WP registers after each
system reset, then the option bytes take effect. The complement option bytes are the opposite
of the option bytes. When reload the option bytes, if the complement option byte and option
byte do not match, the OBERR bit in the FMC_OBSTAT register will be set, and the option
byte will be set to 0xFF. The OBERR bit will not be set if both the option bytes and its
complement bytes are 0xFF.The following table shows the detail of option bytes.
Table 2-7. Option bytes
Address
Name
Description
0x1fff f800
SPC
option bytes security protection value
0xA5 : no security protection
any value except 0xA5 or 0xCC : protection level low
0xCC : protection level high