flash

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

<title>FLASH Memory Programming functions</title>

FLASH Memory Programming functions
[FLASH_Private_Functions]

FLASH Memory Programming functions. More...

Functions

void FLASH_Unlock (void)
 Unlocks the FLASH control register access.
void FLASH_Lock (void)
 Locks the FLASH control register access.
FLASH_Status FLASH_EraseSector (uint32_t FLASH_Sector, uint8_t VoltageRange)
 Erases a specified FLASH Sector.
FLASH_Status FLASH_EraseAllSectors (uint8_t VoltageRange)
 Erases all FLASH Sectors.
FLASH_Status FLASH_EraseAllBank1Sectors (uint8_t VoltageRange)
 Erases all FLASH Sectors in Bank 1.
FLASH_Status FLASH_EraseAllBank2Sectors (uint8_t VoltageRange)
 Erases all FLASH Sectors in Bank 2.
FLASH_Status FLASH_ProgramDoubleWord (uint32_t Address, uint64_t Data)
 Programs a double word (64-bit) at a specified address.
FLASH_Status FLASH_ProgramWord (uint32_t Address, uint32_t Data)
 Programs a word (32-bit) at a specified address.
FLASH_Status FLASH_ProgramHalfWord (uint32_t Address, uint16_t Data)
 Programs a half word (16-bit) at a specified address.
FLASH_Status FLASH_ProgramByte (uint32_t Address, uint8_t Data)
 Programs a byte (8-bit) at a specified address.

Detailed Description

FLASH Memory Programming functions.

 ===============================================================================
                ##### FLASH Memory Programming functions #####
 ===============================================================================   
    [..]
      This group includes the following functions:
      (+) void FLASH_Unlock(void)
      (+) void FLASH_Lock(void)
      (+) FLASH_Status FLASH_EraseSector(uint32_t FLASH_Sector, uint8_t VoltageRange)
      (+) FLASH_Status FLASH_EraseAllSectors(uint8_t VoltageRange)       
      (+) FLASH_Status FLASH_ProgramDoubleWord(uint32_t Address, uint64_t Data)
      (+) FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data)
      (+) FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data)
      (+) FLASH_Status FLASH_ProgramByte(uint32_t Address, uint8_t Data)
          The following functions can be used only for STM32F42xxx/43xxx devices. 
      (+) FLASH_Status FLASH_EraseAllBank1Sectors(uint8_t VoltageRange)
      (+) FLASH_Status FLASH_EraseAllBank2Sectors(uint8_t VoltageRange)    
    [..]   
      Any operation of erase or program should follow these steps:
      (#) Call the FLASH_Unlock() function to enable the FLASH control register access
 
      (#) Call the desired function to erase sector(s) or program data
 
      (#) Call the FLASH_Lock() function to disable the FLASH control register access
          (recommended to protect the FLASH memory against possible unwanted operation)
    

Function Documentation

FLASH_Status FLASH_EraseAllBank1Sectors ( uint8_t  VoltageRange )

Erases all FLASH Sectors in Bank 1.

Note:
This function can be used only for STM32F42xxx/43xxx devices.
If an erase and a program operations are requested simultaneously, the erase operation is performed before the program one.
Parameters:
VoltageRange,:The device voltage range which defines the erase parallelism. This parameter can be one of the following values:

  • VoltageRange_1: when the device voltage range is 1.8V to 2.1V, the operation will be done by byte (8-bit)
  • VoltageRange_2: when the device voltage range is 2.1V to 2.7V, the operation will be done by half word (16-bit)
  • VoltageRange_3: when the device voltage range is 2.7V to 3.6V, the operation will be done by word (32-bit)
  • VoltageRange_4: when the device voltage range is 2.7V to 3.6V + External Vpp, the operation will be done by double word (64-bit)
Return values:
FLASHStatus: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2.

Definition at line 621 of file stm32f4xx_flash.c.

FLASH_Status FLASH_EraseAllBank2Sectors ( uint8_t  VoltageRange )

Erases all FLASH Sectors in Bank 2.

Note:
This function can be used only for STM32F42xxx/43xxx devices.
If an erase and a program operations are requested simultaneously, the erase operation is performed before the program one.
Parameters:
VoltageRange,:The device voltage range which defines the erase parallelism. This parameter can be one of the following values:

  • VoltageRange_1: when the device voltage range is 1.8V to 2.1V, the operation will be done by byte (8-bit)
  • VoltageRange_2: when the device voltage range is 2.1V to 2.7V, the operation will be done by half word (16-bit)
  • VoltageRange_3: when the device voltage range is 2.7V to 3.6V, the operation will be done by word (32-bit)
  • VoltageRange_4: when the device voltage range is 2.7V to 3.6V + External Vpp, the operation will be done by double word (64-bit)
Return values:
FLASHStatus: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2.

Definition at line 688 of file stm32f4xx_flash.c.

FLASH_Status FLASH_EraseAllSectors ( uint8_t  VoltageRange )

Erases all FLASH Sectors.

Note:
If an erase and a program operations are requested simultaneously, the erase operation is performed before the program one.
Parameters:
VoltageRange,:The device voltage range which defines the erase parallelism. This parameter can be one of the following values:

  • VoltageRange_1: when the device voltage range is 1.8V to 2.1V, the operation will be done by byte (8-bit)
  • VoltageRange_2: when the device voltage range is 2.1V to 2.7V, the operation will be done by half word (16-bit)
  • VoltageRange_3: when the device voltage range is 2.7V to 3.6V, the operation will be done by word (32-bit)
  • VoltageRange_4: when the device voltage range is 2.7V to 3.6V + External Vpp, the operation will be done by double word (64-bit)
Return values:
FLASHStatus: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2.

Definition at line 540 of file stm32f4xx_flash.c.

FLASH_Status FLASH_EraseSector ( uint32_t  FLASH_Sector,
uint8_t  VoltageRange 
)

Erases a specified FLASH Sector.

Note:
If an erase and a program operations are requested simultaneously, the erase operation is performed before the program one.
Parameters:
FLASH_Sector,:The Sector number to be erased.
Note:
For STM32F405xx/407xx and STM32F415xx/417xx devices this parameter can be a value between FLASH_Sector_0 and FLASH_Sector_11.

For STM32F42xxx/43xxx devices this parameter can be a value between FLASH_Sector_0 and FLASH_Sector_23.

For STM32F401xx devices this parameter can be a value between FLASH_Sector_0 and FLASH_Sector_5.

For STM32F411xE and STM32F412xG devices this parameter can be a value between FLASH_Sector_0 and FLASH_Sector_7.

For STM32F410xx devices this parameter can be a value between FLASH_Sector_0 and FLASH_Sector_4.

Parameters:
VoltageRange,:The device voltage range which defines the erase parallelism. This parameter can be one of the following values:

  • VoltageRange_1: when the device voltage range is 1.8V to 2.1V, the operation will be done by byte (8-bit)
  • VoltageRange_2: when the device voltage range is 2.1V to 2.7V, the operation will be done by half word (16-bit)
  • VoltageRange_3: when the device voltage range is 2.7V to 3.6V, the operation will be done by word (32-bit)
  • VoltageRange_4: when the device voltage range is 2.7V to 3.6V + External Vpp, the operation will be done by double word (64-bit)
Return values:
FLASHStatus: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2.

Definition at line 472 of file stm32f4xx_flash.c.

void FLASH_Lock ( void   )

Locks the FLASH control register access.

Parameters:
None
Return values:
None

Definition at line 429 of file stm32f4xx_flash.c.

FLASH_Status FLASH_ProgramByte ( uint32_t  Address,
uint8_t  Data 
)

Programs a byte (8-bit) at a specified address.

Note:
This function can be used within all the device supply voltage ranges.
If an erase and a program operations are requested simultaneously, the erase operation is performed before the program one.
Parameters:
Address,:specifies the address to be programmed. This parameter can be any address in Program memory zone or in OTP zone.
Data,:specifies the data to be programmed.
Return values:
FLASHStatus: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2.

Definition at line 872 of file stm32f4xx_flash.c.

FLASH_Status FLASH_ProgramDoubleWord ( uint32_t  Address,
uint64_t  Data 
)

Programs a double word (64-bit) at a specified address.

Note:
This function must be used when the device voltage range is from 2.7V to 3.6V and an External Vpp is present.
If an erase and a program operations are requested simultaneously, the erase operation is performed before the program one.
Parameters:
Address,:specifies the address to be programmed.
Data,:specifies the data to be programmed.
Return values:
FLASHStatus: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2.

Definition at line 745 of file stm32f4xx_flash.c.

FLASH_Status FLASH_ProgramHalfWord ( uint32_t  Address,
uint16_t  Data 
)

Programs a half word (16-bit) at a specified address.

Note:
This function must be used when the device voltage range is from 2.1V to 3.6V.
If an erase and a program operations are requested simultaneously, the erase operation is performed before the program one.
Parameters:
Address,:specifies the address to be programmed. This parameter can be any address in Program memory zone or in OTP zone.
Data,:specifies the data to be programmed.
Return values:
FLASHStatus: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2.

Definition at line 830 of file stm32f4xx_flash.c.

FLASH_Status FLASH_ProgramWord ( uint32_t  Address,
uint32_t  Data 
)

Programs a word (32-bit) at a specified address.

Note:
This function must be used when the device voltage range is from 2.7V to 3.6V.
If an erase and a program operations are requested simultaneously, the erase operation is performed before the program one.
Parameters:
Address,:specifies the address to be programmed. This parameter can be any address in Program memory zone or in OTP zone.
Data,:specifies the data to be programmed.
Return values:
FLASHStatus: The returned value can be: FLASH_BUSY2, FLASH_ERROR_PROGRAM2, FLASH_ERROR_WRP2, FLASH_ERROR_OPERATION2 or FLASH_COMPLETE2.

Definition at line 788 of file stm32f4xx_flash.c.

void FLASH_Unlock ( void   )

Unlocks the FLASH control register access.

Parameters:
None
Return values:
None

Definition at line 414 of file stm32f4xx_flash.c.