/**
******************************************************************************
* @file stm32f10x_flash.c
* @author MCD Application Team
* @version V3.5.0
* @date 11-March-2011
* @brief This file provides all the FLASH firmware functions.
******************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x_flash.h"
/** @addtogroup STM32F10x_StdPeriph_Driver
* @{
*/
/** @defgroup FLASH
* @brief FLASH driver modules
* @{
*/
/** @defgroup FLASH_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup FLASH_Private_Defines
* @{
*/
/* Flash Access Control Register bits */
#define ACR_LATENCY_Mask ((uint32_t)0x00000038)
#define ACR_HLFCYA_Mask ((uint32_t)0xFFFFFFF7)
#define ACR_PRFTBE_Mask ((uint32_t)0xFFFFFFEF)
/* Flash Access Control Register bits */
#define ACR_PRFTBS_Mask ((uint32_t)0x00000020)
/* Flash Control Register bits */
#define CR_PG_Set ((uint32_t)0x00000001)
#define CR_PG_Reset ((uint32_t)0x00001FFE)
#define CR_PER_Set ((uint32_t)0x00000002)
#define CR_PER_Reset ((uint32_t)0x00001FFD)
#define CR_MER_Set ((uint32_t)0x00000004)
#define CR_MER_Reset ((uint32_t)0x00001FFB)
#define CR_OPTPG_Set ((uint32_t)0x00000010)
#define CR_OPTPG_Reset ((uint32_t)0x00001FEF)
#define CR_OPTER_Set ((uint32_t)0x00000020)
#define CR_OPTER_Reset ((uint32_t)0x00001FDF)
#define CR_STRT_Set ((uint32_t)0x00000040)
#define CR_LOCK_Set ((uint32_t)0x00000080)
/* FLASH Mask */
#define RDPRT_Mask ((uint32_t)0x00000002)
#define WRP0_Mask ((uint32_t)0x000000FF)
#define WRP1_Mask ((uint32_t)0x0000FF00)
#define WRP2_Mask ((uint32_t)0x00FF0000)
#define WRP3_Mask ((uint32_t)0xFF000000)
#define OB_USER_BFB2 ((uint16_t)0x0008)
/* FLASH Keys */
#define RDP_Key ((uint16_t)0x00A5)
#define FLASH_KEY1 ((uint32_t)0x45670123)
#define FLASH_KEY2 ((uint32_t)0xCDEF89AB)
/* FLASH BANK address */
#define FLASH_BANK1_END_ADDRESS ((uint32_t)0x807FFFF)
/* Delay definition */
#define EraseTimeout ((uint32_t)0x000B0000)
#define ProgramTimeout ((uint32_t)0x00002000)
/**
* @}
*/
/** @defgroup FLASH_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup FLASH_Private_Variables
* @{
*/
/**
* @}
*/
/** @defgroup FLASH_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup FLASH_Private_Functions
* @{
*/
/**
@code
This driver provides functions to configure and program the Flash memory of all STM32F10x devices,
including the latest STM32F10x_XL density devices.
STM32F10x_XL devices feature up to 1 Mbyte with dual bank architecture for read-while-write (RWW) capability:
- bank1: fixed size of 512 Kbytes (256 pages of 2Kbytes each)
- bank2: up to 512 Kbytes (up to 256 pages of 2Kbytes each)
While other STM32F10x devices features only one bank with memory up to 512 Kbytes.
In version V3.3.0, some functions were updated and new ones were added to support
STM32F10x_XL devices. Thus some functions manages all devices, while other are
dedicated for XL devices only.
The table below presents the list of available functions depending on the used STM32F10x devices.
***************************************************
* Legacy functions used for all STM32F10x devices *
***************************************************
+----------------------------------------------------------------------------------------------------------------------------------+
| Functions prototypes |STM32F10x_XL|Other STM32F10x| Comments |
| | devices | devices | |
|----------------------------------------------------------------------------------------------------------------------------------|
|FLASH_SetLatency | Yes | Yes | No change |
|----------------------------------------------------------------------------------------------------------------------------------|
|FLASH_HalfCycleAccessCmd | Yes | Yes | No change |
|----------------------------------------------------------------------------------------------------------------------------------|
|FLASH_PrefetchBufferCmd | Yes | Yes | No change |
|----------------------------------------------------------------------------------------------------------------------------------|
|FLASH_Unlock | Yes | Yes | - For STM32F10X_XL devices: unlock Bank1 and Bank2. |
| | | | - For other devices: unlock Bank1 and it is equivalent |
| | | | to FLASH_UnlockBank1 function. |
|----------------------------------------------------------------------------------------------------------------------------------|
|FLASH_Lock | Yes | Yes | - For STM32F10X_XL devices: lock Bank1 and Bank2. |
| | | | - For other devices: lock Bank1 and it is equivalent |
| | | | to FLASH_LockBank1 function. |
|----------------------------------------------------------------------------------------------------------------------------------|
|FLASH_ErasePage | Yes | Yes | - For STM32F10x_XL devices: erase a page in Bank1 and Bank2 |
| | | | - For other devices: erase a page in Bank1 |
|----------------------------------------------------------------------------------------------------------------------------------|
|FLASH_EraseAllPages | Yes | Yes | - For STM32F10x_XL devices: erase all pages in Bank1 and Bank2 |
| | | | - For other devices: erase all pages in Bank1 |
|----------------------------------------------------------------------------------------------------------------------------------|
|FLASH_EraseOptionBytes | Yes | Yes | No change |
|--------------------------------------------------------------------
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
STM32使能防读写保护后,可以在RAM中运行解锁代码,去掉读保护功能。附加是基于IAR的STM32F103 在SRAM中运行清除读保护工程 代码。 int main(void) { // read_data=FLASH_Read_Word(0x8008000); FLASH_Unlock(); FLASH_ReadOutProtection(DISABLE); while (1) { }; }
资源推荐
资源详情
资源评论
收起资源包目录
Sram_proj_v1.rar (40个子文件)
Sram_proj_v1
IAR_STM32_SRAM
Debug
Obj
List
Exe
IAR_STM32_SRAM.out 33KB
IAR_STM32_SRAM.ewp 49KB
IAR_STM32_SRAM.dep 6KB
IAR_STM32_SRAM.ewd 51KB
IAR_STM32_SRAM.eww 168B
settings
IAR_STM32_SRAM.dni 937B
IAR_STM32_SRAM.dbgdt 4KB
IAR_STM32_SRAM.cspy.bat 1KB
IAR_STM32_SRAM_Debug.jlink 650B
IAR_STM32_SRAM.wsdt 3KB
Sram_src
stm32f10x_conf.h 3KB
stm32f10x.h 619KB
stm32f10x_it.c 22KB
Linkfile
STM32F10x_FLASH - 副本.icf 2KB
STM32F10x_FLASH.icf 2KB
compiler.h 10KB
library
core_cm3.h 68KB
inc
stm32f10x_usart.h 16KB
stm32f10x_pwr.h 4KB
cortexm3_macro.h 2KB
stm32f10x_gpio.h 20KB
stm32f10x_rcc.h 30KB
stm32f10x_wwdg.h 3KB
misc.h 9KB
stm32f10x_spi.h 17KB
stm32f10x_nvic.h 16KB
stm32f10x_flash.h 25KB
core_cmFunc.h 15KB
core_cmInstr.h 16KB
src
stm32f10x_flash.c 61KB
stm32f10x_rcc.c 50KB
stm32f10x_wwdg.c 6KB
stm32f10x_spi.c 29KB
misc.c 7KB
stm32f10x_usart.c 37KB
stm32f10x_gpio.c 22KB
cortexm3_macro.s 9KB
stm32f10x_vector.c 3KB
stm32f10x_it.h 3KB
main.c 2KB
共 40 条
- 1
资源评论
- CyberNinja2023-07-24这个文件对于想在STM32上清除读保护的人来说是一份非常有帮助的指南。
- 贼仙呐2023-07-24里面的内容不仅详细,而且表达清晰,让人很容易理解。
- 杜拉拉到杜拉拉2023-07-24对于我来说,这个文件提供了解决问题的实用步骤,让我省去了很多研究的时间。
- lirumei2023-07-24如果你是一个STM32开发者,这个文件一定会是你的得力工具,它为你提供了解决各种问题的思路和方法。
- 山林公子2023-07-24我喜欢这个文件的风格,它没有过多的华丽辞藻,而是直接切入主题,给出了准确的解决方案。
沙沙等待
- 粉丝: 2
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功