Embedded Flash memory
The Flash memory interface preliminarily reads the value at the addressed main Flash
memory location and checks that it has been erased. If not, the program operation is
skipped and a warning is issued by the PGERR bit in FLASH_SR register. The only
exception to this is when 0x0000 is programmed. In this case, the location is correctly
programmed to 0x0000 and the PGERR bit is not set.
If the addressed main Flash memory location is write-protected by the FLASH_WRPR
register, the program operation is skipped and a warning is issued by the WRPRTERR bit in
the FLASH_SR register. The end of the program operation is indicated by the EOP bit in the
FLASH_SR register.
The main Flash memory programming sequence in standard mode is as follows:
1.
Check that no main Flash memory operation is ongoing by checking the BSY bit in the
FLASH_SR register.
2.
Sett the PG bit in the FLASH_CR register.
3.
Perform the data write (half-word) at the desired address.
4.
Wait until the BSY bit is reset in the FLASH_SR register.
5.
Read the programmed value and verify.
Note:
The registers are not accessible in write mode when the BSY bit of the FLASH_SR register
is set.
Flash memory erase
The Flash memory can be erased page by page or completely (Mass Erase).
Page Erase
To erase a page, the procedure below should be followed:
1.
Check that no Flash memory operation is ongoing by checking the BSY bit in the
FLASH_CR register
2.
Set the PER bit in the FLASH_CR register.
3.
Program the FLASH_AR register to select a page to erase.
4.
Set the STRT bit in the FLASH_CR register.
5.
Wait for the BSY bit to be reset.
6.
Read the erased page and verify.
46/742
Doc ID 018940 Rev 1
RM0091
Need help?
Do you have a question about the STM32F05 series and is the answer not in the manual?
Questions and answers