STM32F072 FlaSh
硬件:STM32F072C8T6
软件:HAL + FreeRTOS + keil
keil仿真时,程序跑着跑着,突然暂停了(未打断点),
每次都是停在HAL写FLASH数据时的这段代码status = FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
暂停时,我看了下status值是OK的,不知道怎么老是暂停,点继续执行,数据可以正常写入,不知道正常不??
以下是HAL库写FLASH的原始代码:
- HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data)
- {
- HAL_StatusTypeDef status = HAL_ERROR;
- uint8_t index = 0U;
- uint8_t nbiterations = 0U;
- /* Process Locked */
- __HAL_LOCK( pFlash);
- /* Check the parameters */
- assert_param(IS_FLASH_TYPEPROGRAM(TypeProgram));
- assert_param(IS_FLASH_PROGRAM_ADDRESS(Address));
- /* Wait for last operation to be completed */
- status = FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
- if(status == HAL_OK)
- {
- if(TypeProgram == FLASH_TYPEPROGRAM_HALFWORD)
- {
- /* Program halfword (16-bit) at a specified address. */
- nbiterations = 1U;
- }
- else if(TypeProgram == FLASH_TYPEPROGRAM_WORD)
- {
- /* Program word (32-bit = 2*16-bit) at a specified address. */
- nbiterations = 2U;
- }
- else
- {
- /* Program double word (64-bit = 4*16-bit) at a specified address. */
- nbiterations = 4U;
- }
- for (index = 0U; index < nbiterations; index++)
- {
- FLASH_Program_HalfWord((Address + (2U*index)), (uint16_t)(Data >> (16U*index)));
- /* Wait for last operation to be completed */
- status = FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
- /* If the program operation is completed, disable the PG Bit */
- CLEAR_BIT(FLASH->CR, FLASH_CR_PG);
- /* In case of error, stop programation procedure */
- if (status != HAL_OK)
- {
- break;
- }
- }
- }
- /* Process Unlocked */
- __HAL_UNLOCK( pFlash);
- return status;
- }
回帖(1)
2024-4-18 09:19:50
是不是曾经这里打过断点,你可以试下去掉全部断点
是不是曾经这里打过断点,你可以试下去掉全部断点
举报
更多回帖