你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

flash写入数据暂停异常

[复制链接]
jyl518-283289 提问时间:2019-9-18 08:26 /
硬件:STM32F072C8T6
软件:HAL + FreeRTOS + keil

keil仿真时,程序跑着跑着,突然暂停了(未打断点),
每次都是停在HAL写FLASH数据时的这段代码
status = FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
暂停时,我看了下status值是OK的,不知道怎么老是暂停,点继续执行,数据可以正常写入,不知道正常不??
以下是HAL库写FLASH的原始代码:
  1. HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data)
  2. {
  3.   HAL_StatusTypeDef status = HAL_ERROR;
  4.   uint8_t index = 0U;
  5.   uint8_t nbiterations = 0U;
  6.   
  7.   /* Process Locked */
  8.   __HAL_LOCK(&pFlash);

  9.   /* Check the parameters */
  10.   assert_param(IS_FLASH_TYPEPROGRAM(TypeProgram));
  11.   assert_param(IS_FLASH_PROGRAM_ADDRESS(Address));

  12.     /* Wait for last operation to be completed */
  13.     status = FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
  14.   
  15.   if(status == HAL_OK)
  16.   {
  17.     if(TypeProgram == FLASH_TYPEPROGRAM_HALFWORD)
  18.     {
  19.       /* Program halfword (16-bit) at a specified address. */
  20.       nbiterations = 1U;
  21.     }
  22.     else if(TypeProgram == FLASH_TYPEPROGRAM_WORD)
  23.     {
  24.       /* Program word (32-bit = 2*16-bit) at a specified address. */
  25.       nbiterations = 2U;
  26.     }
  27.     else
  28.     {
  29.       /* Program double word (64-bit = 4*16-bit) at a specified address. */
  30.       nbiterations = 4U;
  31.     }

  32.     for (index = 0U; index < nbiterations; index++)
  33.     {
  34.       FLASH_Program_HalfWord((Address + (2U*index)), (uint16_t)(Data >> (16U*index)));

  35.         /* Wait for last operation to be completed */
  36.         status = FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
  37.    
  38.         /* If the program operation is completed, disable the PG Bit */
  39.         CLEAR_BIT(FLASH->CR, FLASH_CR_PG);
  40.       /* In case of error, stop programation procedure */
  41.       if (status != HAL_OK)
  42.       {
  43.         break;
  44.       }
  45.     }
  46.   }

  47.   /* Process Unlocked */
  48.   __HAL_UNLOCK(&pFlash);

  49.   return status;
  50. }
复制代码





无标题.png
66.png
收藏 评论4 发布时间:2019-9-18 08:26

举报

4个回答
00-405686 回答时间:2019-9-18 10:49:46
是不是曾经这里打过断点,你可以试下去掉全部断点
wenyangzeng 回答时间:2019-9-18 11:22:14
C++优化等级降低点试看看
哀歌与世无争 回答时间:2019-9-18 15:57:35
要是没调试能运行正常,那可能断点没清掉,去掉所有断点,重新拔插仿真器再试一下
jyl518-283289 回答时间:2019-9-18 16:02:26
所有断点都去掉的,优化等级是Leve 0(-O 0),问题是几十次出现一次自动暂停

所属标签

相似问题

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
微信公众号二维码 微信公众号
手机版二维码 手机版