打印

STM32如何检测FLASH写保护

[复制链接]
2608|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
Miltonliu2010|  楼主 | 2012-8-30 17:19 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
以前做过STM32的IAP,没有能发现一些问题。可是今天再读IAP的软件包。不明白下面这段代码的原理。
  /* Get the number of block (4 or 2 pages) from where the user program will be loaded */
  BlockNbr = (FlashDestination - 0x08000000) >> 12;

  /* Compute the mask to test if the Flash memory, where the user program will be
     loaded, is write protected */
#if defined (STM32F10X_MD) || defined (STM32F10X_MD_VL)
  UserMemoryMask = ((uint32_t)~((1 << BlockNbr) - 1));
#else /* USE_STM3210E_EVAL */
  if (BlockNbr < 62)
  {
    UserMemoryMask = ((uint32_t)~((1 << BlockNbr) - 1));
  }
  else
  {
    UserMemoryMask = ((uint32_t)0x80000000);
  }
#endif /* (STM32F10X_MD) || (STM32F10X_MD_VL) */


  /* Test if any page of Flash memory where program user will be loaded is write protected */
  if ((FLASH_GetWriteProtectionOptionByte() & UserMemoryMask) != UserMemoryMask)
  {
    FlashProtection = 1;
  }
  else
  {
    FlashProtection = 0;
  }
沙发
Miltonliu2010|  楼主 | 2012-8-31 11:46 | 只看该作者
为什么每次我提出来的问题最后都是自己解决的?:Q

使用特权

评论回复
板凳
airwill| | 2012-9-1 09:19 | 只看该作者
两种可能性
1. 说明你的问题太专业, 层次太高了. 无人能参加.
2. 说明你太钻研了, 人家还没有弄明白, 你就搞定了.
总之, 这里有个潜力不小的高人, 即将或者已经诞生.

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

20

主题

87

帖子

3

粉丝