English
Language : 

UM0116 Datasheet, PDF (17/27 Pages) STMicroelectronics – STR7 family Flash programming
UM0116
Read/program the STR7 embedded Flash
Bit 3
Bit 2
Bit 1
Bit 0
10ER. 1 over 0 Error.
This bit is automatically set when trying to program to 1 bits previously
programmed to 0 (this does not happen when programming the Protection
bits). This error is not due to a failure of the Flash cell, but only flags that the
desired data has not been written. This bit has to be cleared by software.
PGER: Program Error.
This bit is automatically set when a Program error occurs during a Flash write
operation. This error is due to a real failure of a Flash cell, that can no longer
be programmed. The word where this error occurred must be discarded. This
bit has to be cleared by software.
ERER: Erase Error.
This bit is automatically set when an Erase error occurs during a Flash write
operation. This error is due to a real failure of a Flash cell, that can no longer
be erased. This kind of error is fatal and the sector where it occurred must be
discarded. This bit has to be cleared by software.
ERR: Write Error.
This bit is automatically set when an error occurs during a Flash write
operation or due to a bad write operation setup. Once the error has been
discovered and understood, ERR bit must be cleared by software.
2.5
2.5.1
2.5.2
Note:
2.5.3
Write Operation Examples
Word Program
Example: Word Program of data 0xAAAAAAAA at address 0x05554 in the Flash Module.
FLASH_CR0 |= 0x20000000; /*Set WPG in FLASH_CR0*/
FLASH_AR = 0x00005554; /*Load Add in FLASH_AR*/
FLASH_DR0 = 0xAAAAAAAA; /*Load Data in FLASH_DR0*/
FLASH_CR0 |= 0x80000000; /*Operation start*/
Double Word Program
Example: Double Word Program of data 0x55AA55AA at address 0x05558 and data
0xAA55AA55 at address 0x0555C in the Flash Module.
FLASH_CR0 |= 0x10000000;/*Set DWPG*/
FLASH_AR = 0x00005558;/*Load Add in FLASH_AR*/
FLASH_DR0 = 0x55AA55AA; /*Load Data in FLASH_DR0*/
FLASH_DR1 = 0xAA55AA55; /*Load Data in FLASH_DR1*/
FLASH_CR0 |= 0x80000000; /*Operation start*/
Double Word Program is always performed on the Double Word aligned on a even Word: bit
ADD2 of FLASH_AR is ignored.
Sector Erase
Example: Sector Erase of sectors B0F1 and B0F0 of Bank 0 in the Flash Module.
FLASH_CR0 |= 0x08000000; /*Set SER in FLASH_CR0*/
FLASH_CR1 |= 0x00000003; /*Set B0F1, B0F0*/
FLASH_CR0 |= 0x80000000; /*Operation start*/
17/27