Embedded Flash memory
RM0365
63/1080
DocID025202 Rev 7
1.
Check that no main Flash memory operation is ongoing by checking the BSY bit in the
FLASH_SR register.
2. Set 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. Check the EOP flag in the FLASH_SR register (it is set when the programming
operation has succeeded), and then clear it by software.
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 (see below note)
5. Wait for the BSY bit to be reset
6. Check the EOP flag in the FLASH_SR register (it is set when the erase operation has
succeeded), and then clear it by software.
7. Clear the EOP flag.
Note:
The software should start checking if the BSY bit equals ‘0’ at least one CPU cycle after
setting the STRT bit.