AT32F425
Series Reference Manual
2022.03.30
Page 69
Ver 2.01
Figure 5-2
Flash memory mass erase process
Start
No
Check the OBF bit in FLASH_STSx
OBF = 0?
Yes
Set BANKERS = 1 and ERSTR =1
in FLASH_CTRLx
OBF = 0 ?
Check the OBF bit in FLASH_STSx
Read EPPERR bit and ODF bit in
FLASH_STSx
No
Yes
End
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_STS register.
2. Read operation to the Flash memory during tprogramming halts CPU and waits until the
completion of programming.
3. Internal HICK must be enabled prior to programming.