GD32VF103 User Manual
38
When the operation is executed successful, the ENDF in 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.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 pair 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_CTL register if necessary.
Check the BUSY bit in 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 FMC_CTL register if necessary.
Wait until OBWEN bit is set in FMC_CTL register.
Set 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 finished 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, the ENDF in 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
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_STAT 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
system reset, and the option bytes take effect. The complement option bytes are the opposite
of option bytes. When option bytes reload, if the complement option byte and option byte do
not match, the OBERR bit in FMC_OBSTAT register is set, and the option byte is set to 0xFF.
The OBERR bit is not set if both the option byte and its complement byte are 0xFF.
shows the detail of option bytes.
Table 2-2. Option byte
Address
Name
Description
0x1fff f800
SPC
option byte Security Protection value
0xA5 : no security protection
any value except 0xA5 : under security protection
0x1fff f801
SPC_N
SPC complement value
0x1fff f802
USER
[7:4]: reserved
[3]: BB