cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_FLASH_Program behavior

Curt Black
Associate II
Posted on April 24, 2018 at 17:35

I came across a rare issue where a previously failed flash operation would cause a subsequent operation to fail as well.  I tracked it down to stm32f4xx_hal_flash.c::HAL_Flash_Program()

When the function calls FLASH_WaitForLastOperation(), that function can return HAL_ERROR if a previous program operation failed.  This causes the current operation to fail due to the subsequent check:  if(status == HAL_OK)

I realize any previous call should clear the error bits after attempting to program, but this isn't guaranteed

I feel like the better check would be 

if(status != HAL_TIMEOUT), indicating the flash is still busy therefore the current operation cannot begin.

thoughts?

thanks,

Curt

#flash-api #stm32-f4
0 REPLIES 0