
GD32A50x User Manual
60
following steps show the register access sequence of the programming operation.
Unlock the FMC_CTLx register if necessary.
Check the BUSY bit in FMC_STATx 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 word program command into the PG bit in FMC_CTLx register.
Write the data to be programed by DBUS with desired absolute address (0x08XX XXXX).
The DBUS write twice to form a 64-bit data and then the 64-bit data program to flash
memory. The data to be programed must double-
word alignment.
Wait until all the operations have been completed by checking the value of the BUSY bit
in FMC_STATx 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_CTLx register is set, and the ENDF in FMC_STATx register is set. Note
that before the double word programming operation you should check the address that it has
been erased. If the address has not been erased, PGERR bit will set when programming the
address even if programming 0x0. Additionally, the program operation will be ignored on
protected pages. Flash operation error interrupt will be triggered by the FMC if the ERRIE bit
in the FMC_CTLx register is set. The software can check the PGERR bit in the FMC_STATx
register to detect this condition in the interrupt handler.
In the following cases, the PGAERR bit in the FMC_STATx register will be set.
The DBUS program do not use 32-bit write.
The DBUS write is not alignment. If DBUS program is 32-bit, the second DBUS write must
double-word alignment and belong to same double-word address.
Note:
If the program is not write total 64bits, the data is not program to the flash memory
without any notice.
In these conditions, a flash operation error interrupt will be triggered by the FMC if the ERRIE
bit in the FMC_CTLx register is set. The software can check the PGERR bit, PGAERR bit or
WPERR bit in the FMC_STATx register to detect which condition occurred in the interrupt
handler. The
Figure 2-3. Process of word program operation
programming operation flow.