STM32F4 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F4 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
FLASH Memory Programming functions

FLASH Memory Programming functions. More...

Functions

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

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)
   
   Any operation of erase or program should follow these steps:
   1. Call the FLASH_Unlock() function to enable the FLASH control register access

   2. Call the desired function to erase sector(s) or program data

   3. 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_EraseAllSectors ( uint8_t  VoltageRange)

Erases all FLASH Sectors.

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_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_ERROR_OPERATION or FLASH_COMPLETE.
FLASH_Status FLASH_EraseSector ( uint32_t  FLASH_Sector,
uint8_t  VoltageRange 
)

Erases a specified FLASH Sector.

Parameters
FLASH_Sector,:The Sector number to be erased. This parameter can be a value between FLASH_Sector_0 and FLASH_Sector_11
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_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_ERROR_OPERATION or FLASH_COMPLETE.
void FLASH_Lock ( void  )

Locks the FLASH control register access.

Parameters
None
Return values
None
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.
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_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_ERROR_OPERATION or FLASH_COMPLETE.
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.
Parameters
Address,:specifies the address to be programmed.
Data,:specifies the data to be programmed.
Return values
FLASHStatus: The returned value can be: FLASH_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_ERROR_OPERATION or FLASH_COMPLETE.
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.
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_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_ERROR_OPERATION or FLASH_COMPLETE.
FLASH_Status FLASH_ProgramWord ( uint32_t  Address,
uint32_t  Data 
)

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

Parameters
Address,:specifies the address to be programmed. This parameter can be any address in Program memory zone or in OTP zone.
Note
This function must be used when the device voltage range is from 2.7V to 3.6V.
Parameters
Data,:specifies the data to be programmed.
Return values
FLASHStatus: The returned value can be: FLASH_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_ERROR_OPERATION or FLASH_COMPLETE.
void FLASH_Unlock ( void  )

Unlocks the FLASH control register access.

Parameters
None
Return values
None