AT32WB415
Series Reference Manual
2022.04.13
Page 66
Ver 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_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.
Figure 5-3
Flash memory programming process
OBF = 0?
Set the FPRGM bit = 1 in
FLASH_CTRL
Write word/half-word/byte
(32bits/16 bits/8bits) data
No
Yes
Start
Check the OBF bit in
FLASH_STS
No
Check the OBF bit in
FLASH_STS
OBF = 0?
Yes
Read EPPERR bit
、
PRGMERR
bit and ODF bit in FLASH_STS
End