
AT32F413
Series Reference Manual
2022.06.27
Page 70
Rev 2.00
5.2.3
Programming operation
The Flash memory can be programmed with 32 bits, 16 bits or 8 bits at a time.
The following process is recommended:
Check the OBF bit in the FLASH_STS register to confirm that there is no other programming
operation in progress;
Set the FPRGM bit in the FLASH_CTRL register, so that the Flash memory programming
instructions can be received;
Write the data (word/half-word/byte) to be programmed to the designated address;
Wait until the OBF bit in the FLASH_STS register becomes “0”, read the EPPERR, PRGMERR and
ODF bit to verify the programming result.
Note: 1. When the address to be written is not erased in advance, the programming operation is
not executed unless the data to be written is all 0. In this case, a programming error is
reported by the PRGMERR bit in the FLASH_STSx register.
2. Read operation to the Flash memory during tprogramming will halt CPU until the
completion of programming.
Figure 5-5
Flash memory programming process
OBF = 0?
Set the FPRGM bit = 1 in
FLASH_CTRLx
Write word/half-word/byte
(32bits/16 bits/8bits) data
No
Yes
Start
Check the OBF bit in
FLASH_STSx
No
Check the OBF bit in
FLASH_STSx
OBF = 0?
Yes
Read EPPERR bit
、
PRGMERR
bit and ODF bit in FLASH_STSx
End