Fast Programming Mode Unlocking; Main Memory Fast Programming; Main Memory Fast Erase - WCH CH32V003 Series Reference Manual

Table of Contents

Advertisement

CH32V003 Reference Manual
2)
Set the MER bit of FLASH_CTLR register to '1' to enable the whole chip erase mode.
3)
Set the STAT bit of FLASH_CTLR register to '1' to start the erase action.
4)
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.
5)
Read the data of the erased page for verification.
6)
Clear the MER bit to 0.

16.4.5 Fast programming mode unlocking

Fast programming mode operation can be unlocked by writing a sequence to the FLASH_MODEKEYR
register. After unlocking, the FLOCK bit of FLASH_CTLR register will be cleared to 0, indicating that fast
erase and programming operations can be performed. The FLASH_CTLR register is locked again by software
setting the "FLOCK" bit to 1.
Unlock sequence.
1)
Write KEY1 = 0x45670123 to the FLASH_MODEKEYR register.
2)
Write KEY2 = 0xCDEF89AB to FLASH_MODEKEYR register.
The above operations must be performed sequentially and consecutively, otherwise they are wrong operations
will be locked and cannot be unlocked again until the next system reset.
Note: Quick programming operation requires unlocking the "LOCK" and "FLOCK" layers.

16.4.6 Main memory fast programming

Fast programming by page (64 bytes).
1)
Check the LOCK bit of FLASH_CTLR register, if it is 1, you need to execute the "Unlock Flash"
operation.
2)
Check the BSY bit of the FLASH_STATR register to confirm that there are no other programming
operations in progress.
3)
Check the FLASH_CTLR register FLOCK bit, if it is 1, you need to execute the "fast programming mode
unlock" operation.
4)
Set the FTPG bit of FLASH_CTLR register to enable the fast programming mode function.
5)
Set the BUFRST bit of FLASH_CTLR register to perform the operation of clearing the internal 64-byte
buffer.
6)
Wait for the BYS bit to become '0' or the EOP bit of FLASH_STATR register to be '1' to indicate the end
of clearing, and clear the EOP bit to 0.
7)
Start writing 4 bytes of data to the specified address (4 bytes/operation), then set the BUFLOAD bit of
FLASH_CTLR register and execute loading to the buffer.
8)
Wait for the BYS bit to become '0' or the EOP bit of FLASH_STATR register to be '1' to indicate the end
of loading, and clear the EOP bit to 0.
9)
Repeat steps 7-8 a total of 16 times to load all 64 bytes of data into the buffer (the main 16 rounds of
operation addresses should be consecutive).
10) Write the first address of the fast programming page to the FLASH_ADDR register.
11) Set the STAT bit of FLASH_CTLR register to '1' to start a fast page programming action.
12) Wait for the BYS bit to become '0' or the EOP bit of FLASH_STATR register to be '1' to indicate the end
of programming, and clear the EOP bit to 0.
13) Query FLASH_STATR register to see if there is an error, or read the programmed address data checksum.
14) Continue the Quick Page programming can repeat steps 5-13 and end the programming to clear the FTPG
bit to 0.

16.4.7 Main memory fast erase

Fast Erase erases by page (64 bytes).
1)
Check the LOCK bit of FLASH_CTLR register, if it is 1, you need to execute the "Unlock Flash"
operation.
V1.3
175
http://wch.cn

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents