
CH32V003
Reference Manual
V1.3
174
Figure 16-2 FLASH Page Erase
Read the LOCK bit of
FLASH_CTRL
BSY bit=1
?
Perform "Unlock Flash
Memory" operation
Set FLASH_CTLR
的
PER bit=1
Set FLASH_CTLR STRT bit=1
Read out erase page data
verification
Continue
erasing?
Over
,
PEG bit=0
LOCK bit=1?
YES
NO
NO
YES
YES
NO
Write the erased page header
address in FLASH_ADDR register
(erase 8 pages at a time)
1)
Check the LOCK bit of FLASH_CTLR register, if it is 1, you need to execute the "Unlock Flash"
operation.
2)
Set the PER bit of FLASH_CTLR register to '1' to enable the standard page erase mode.
3)
Write the page header address of the selected erase to FLASH_ADDR register.
4)
Set the STAT bit of FLASH_CTLR register to '1' to initiate an erase action.
5)
Wait for the BYS bit to become '0' or the EOP bit of FLASH_STATR register to be '1' to indicate the end
of erase, and clear the EOP bit to 0.
6)
Read the data of the erased page for verification.
7)
Continue the standard page erase can repeat steps 3-5 and end the erase to clear the PEG bit to 0.
Figure 16-3 FLASH whole chip erase
Read the LOCK bit of
FLASH_CTRL
BSY bit=1
?
Perform "Unlock Flash
Memory" operation
Set FLASH_CTLR MER bit=1
Set FLASH_CTLR STRT bit=1
Read out all pages of data to
verify
Over
,
MEG
bit=0
LOCK bit=1?
YES
NO
YES
NO
1)
Check the LOCK bit of FLASH_CTLR register, if it is 1, you need to execute the "Unlock Flash"
operation.