
RM0453 Rev 2
107/1454
RM0453
Embedded Flash memory (FLASH)
153
2. Check and clear all error programming flags due to a previous programming. If not,
PGSERR is set.
3. Set MER in FLASH_CR or FLASH_C2CR.
4. Set STRT in FLASH_CR or FLASH_C2CR.
5. Wait for BSY to be cleared in FLASH_SR or FLASH_C2SR.
Note:
The internal oscillator HSI16 (16 MHz) is enabled automatically when the STRT bit is set,
and disabled automatically when the STRT bit is cleared, except if the HSI16 is previously
enabled with HSION in the RCC_CR register.
4.3.8
Flash main memory programming sequences
The Flash memory is programmed with 72 bits at a time (a double-word of 64 bits plus 8 bits
ECC).
Programming in a previously programmed double-word is only allowed when programming
an all 0 value. It is not allowed to program any other value in a previously programmed
double-word. Any attempt sets PROGERR flag in FLASH_SR or FLASH_C2SR, except
when programming an already programmed double-word with an all 0 value.
It is only possible to program a double-word (2 x 32-bit data), otherwise:
•
Any attempt to write a byte (8 bits) or half-word (16 bits) sets SIZERR in FLASH_SR or
FLASH_C2SR.
•
Any attempt to write a double-word that is not aligned with a double-word address sets
the PGAERR flag in FLASH_SR or FLASH_C2SR
.
When the system is secure (ESE = 1), only the secure CPU2 is able to download
programming data into the secure part of the memory. When the system is secure
(ESE = 1), a Flash memory programming by the CPU1 in the secure Flash memory area is
ignored and an illegal access event is generated. Also unprivileged programming of a
privileged location is ignored.
When access rights between programming two word address is changed, the double-word
programming fails and the flags controller is blocked in the programming sequence (no error
flags are set). A system reset is needed to overcome this situation.
Note:
For correct operation, the firmware must guarantee that the Flash page access protection is
not changed during the programming sequence.
Standard programming
The Flash memory programming sequence in standard mode is as follows:
1.
Check that no Flash main memory operation is ongoing by checking BSY in
FLASH_SR or FLASH_C2SR.
2. Check that Flash program and erase operation is allowed by checking PESD in
FLASH_SR or FLASH_C2SR (these checks are recommended even if status may
change due to Flash operation requests by the other CPU, to limit the risk of receiving
a bus error when starting programming).