FLASH Memory Programming functions.
More...
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:
(#) 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)
===============================================================================
##### FLASH Memory Programming functions #####
===============================================================================
[..] This group includes the following functions:
(+) void FLASH_Unlock(void);
(+) void FLASH_Lock(void);
(+) FLASH_Status FLASH_ErasePage(uint32_t Page_Address);
(+) FLASH_Status FLASH_EraseAllPages(void);
(+) FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);
(+) FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);
[..] Any operation of erase or program should follow these steps:
(#) Call the FLASH_Unlock() function to enable the FLASH control register
program memory access.
(#) Call the desired function to erase page 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).
Erases all FLASH pages.
- Note
- To correctly run this function, the FLASH_Unlock() function must be called before. all the FLASH_Lock() to disable the flash memory access (recommended to protect the FLASH memory against possible unwanted operation)
- Parameters
-
- Return values
-
FLASH | Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. |
Definition at line 298 of file stm32f30x_flash.c.
Erases all FLASH Sectors.
- Note
- If an erase and a program operations are requested simustaneously, 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
-
FLASH | Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_ERROR_OPERATION or FLASH_COMPLETE. |
Definition at line 432 of file stm32f4xx_flash.c.
Erases a specified page in program memory.
Erases a specified FLASH page.
- Note
- To correctly run this function, the FLASH_Unlock() function must be called before.
-
Call the FLASH_Lock() to disable the flash memory access (recommended to protect the FLASH memory against possible unwanted operation)
- Parameters
-
Page_Address | The page address in program memory to be erased. |
- Note
- A Page is erased in the Program memory only if the address to load is the start address of a page (multiple of 1024 bytes).
- Return values
-
FLASH | Status: The returned value can be: FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. |
Definition at line 260 of file stm32f30x_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 simustaneously, the erase operation is performed before the program one.
- Parameters
-
FLASH_Sector | The Sector number to be erased. For STM32F40xx/41xx devices this parameter can be a value between FLASH_Sector_0 and FLASH_Sector_11. For STM32F427x/437x devices this parameter can be a value between FLASH_Sector_0 and FLASH_Sector_23. |
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
-
FLASH | Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_ERROR_OPERATION or FLASH_COMPLETE. |
Definition at line 364 of file stm32f4xx_flash.c.
Locks the FLASH control register access.
- Parameters
-
- Return values
-
Definition at line 332 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 simustaneously, 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
-
FLASH | Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_ERROR_OPERATION or FLASH_COMPLETE. |
Definition at line 631 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 simustaneously, 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
-
FLASH | Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_ERROR_OPERATION or FLASH_COMPLETE. |
Definition at line 504 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.
Programs a half word 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 simustaneously, 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
-
FLASH | Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_ERROR_OPERATION or FLASH_COMPLETE. |
- Note
- To correctly run this function, the FLASH_Unlock() function must be called before. Call the FLASH_Lock() to disable the flash memory access (recommended to protect the FLASH memory against possible unwanted operation)
- Parameters
-
Address | specifies the address to be programmed. |
Data | specifies the data to be programmed. |
- Return values
-
FLASH | Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. |
Definition at line 589 of file stm32f4xx_flash.c.
FLASH_Status FLASH_ProgramWord |
( |
uint32_t |
Address, |
|
|
uint32_t |
Data |
|
) |
| |
Programs a word (32-bit) at a specified address.
Programs a word 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 simustaneously, 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
-
FLASH | Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PROGRAM, FLASH_ERROR_WRP, FLASH_ERROR_OPERATION or FLASH_COMPLETE. |
- Note
- To correctly run this function, the FLASH_Unlock() function must be called before. Call the FLASH_Lock() to disable the flash memory access (recommended to protect the FLASH memory against possible unwanted operation)
- Parameters
-
Address | specifies the address to be programmed. |
Data | specifies the data to be programmed. |
- Return values
-
FLASH | Status: The returned value can be: FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. |
Definition at line 547 of file stm32f4xx_flash.c.
void FLASH_Unlock |
( |
void |
| ) |
|
Unlocks the FLASH control register access.
- Parameters
-
- Return values
-
Definition at line 317 of file stm32f4xx_flash.c.