Chinaunix首页 | 论坛 | 博客
  • 博客访问: 128495
  • 博文数量: 64
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 10
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-26 18:44
文章分类

全部博文(64)

文章存档

2014年(64)

我的朋友

分类: C/C++

2014-04-26 19:05:06

原文地址:STM32之Flash 作者:

1. 在默认情况下,只有执行FLASH设置(延迟,预取指,半周期)的函数式允许执行的。 
如果想要执行FLASH编写/擦除/保护函数,必须在文件“stm32f10x_conf.h”中定义_FLASH_PROG如下: 
#define _FLASH_PROG 
2.按照不同容量,存储器组织成32个1K字节/页(小容量)、128个1K字节/页(中容量),万利板子是中容量
       #define FLASH_PAGE_SIZE    ((u16)0x400)      //一页为1024个字节
3.

点击(此处)折叠或打开

  1. /* Get pages write protection status */
  2. WRPR_Value = FLASH_GetWriteProtectionOptionByte();
  3. ProtectedPages = WRPR_Value & 0x000000C0; //后面要对24页到27页,28页到31页进行操作,所以要获得其对应的写保护状态

  4. #ifdef WriteProtection_Disable
  5.   if (ProtectedPages == 0x00)
  6.   {/* Pages are write protected */

  7.     /* Disable the write protection */
  8.     FLASHStatus = FLASH_EraseOptionBytes();

  9.     /* Generate System Reset to load the new option byte values */
  10.     NVIC_GenerateSystemReset();
  11.   }
  12. #else
  13.  #ifdef WriteProtection_Enable
  14.   
  15.   if (ProtectedPages != 0x00)
  16.   {/* Pages not write protected */
  17.     
  18.     /* Enable the pages write protection */
  19.     FLASHStatus = FLASH_EnableWriteProtection(FLASH_WRProt_Pages24to27 |FLASH_WRProt_Pages28to31);    
  20.     
  21.     /* Generate System Reset to load the new option byte values */
  22.     NVIC_GenerateSystemReset();
  23.   }
  24.  #endif
  25. #endif

阅读(988) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~