RM0444 Rev 5 79/1390
RM0444 Embedded Flash memory (FLASH)
118
Programming and cache
If an erase operation in Flash memory also concerns data in the instruction cache, the user
has to ensure that these data are rewritten before they are accessed during code execution.
Note: The cache should be flushed only when it is disabled (ICEN = 0).
3.3.9 Read-while-write (RWW) function
Dual-bank devices support read-while-write function that allows reading from one bank
while erasing or programming within the other bank.
Note: Write-while-write operation, such as erasing within one bank while programming the other,
is not allowed.
Reading while page erasing
To erase a page in one bank while executing the code in the other bank, proceed as follows:
1. Check that the busy flag of the bank to erase (BSY1 or BSY2) in the FLASH status
register (FLASH_SR) is low (no erase/programming in progress).
2. Set up the page erase, by setting the PER, PSB, and BKER bitfileds of the FLASH
control register (FLASH_CR).
3. Trigger the erase operation by setting the STRT bit of the FLASH control register
(FLASH_CR). This sets the corresponding busy flag BSY1 or BSY2.
The erase operation is completed when the corresponding busy flag (BSY1 or BSY2) is
back to low. The EOP interrupt can be used to indicate that event to the application
software.
Reading while bank erasing
To erase a bank while executing the code in the other bank, proceed as follows:
1. Check that the busy flag of the bank to erase (BSY1 or BSY2) in the FLASH status
register (FLASH_SR) is low (no erase/programming in progress).
2. Set the mass-erasure bit of the bank to erase (MER1 or MER2) in the FLASH control
register (FLASH_CR).
3. Trigger the erase operation by setting the STRT bit of the FLASH control register
(FLASH_CR). This sets the corresponding busy flag BSY1 or BSY2.
The erase operation is completed when the corresponding busy flag (BSY1 or BSY2) is
back to low. The EOP interrupt can be used to indicate that event to the application
software.
Reading while programming
To program a bank while executing the code in the other bank, proceed as follows:
1. Check that the busy flag of the bank to program (BSY1 or BSY2) in the FLASH status
register (FLASH_SR) is low (no erase/programming in progress).
2. Set the PG bit of the FLASH control register (FLASH_CR).
3. Write a word at a desired address within the bank to program. This sets the
corresponding busy flag (BSY1 or BSY2).
4. When the corresponding busy flag (BSY1 or BSY2) is back to low an there is more data
to write, go to the step 3