cancel
Showing results for 
Search instead for 
Did you mean: 

FLASH status register BSY1 vs. CFGBSY flag. Which one to watch for finished flash programming/erase operation?

end
Associate

During self flash programming (IAP - InApplicationProgramming) the STM32 reference manual states that a clear BSY1 flag indicates the end of erasing/programming cycle.

Carefully examining the HAL library: it uses FLASH_WaitForLastOperation function that contains waiting for both of BSY1 and CFGBSY flags to be clear.

Examining the behavior of both flags with scope (flag state copied to a portpin), it shows that both flags works the same.

SO, what is the real difference between the two flags, and which one to use to be sure flash erasing/programming done?

5 REPLIES 5
MSmczek
Associate II

Good question asked but without the answer..

No part or reference manual is cited, so fantastic question, STM32 that narrows it down to a few thousand parts, give or take.

If both track each other, does it matter which? Does something break if you follow BSY1

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

And the software uses both, is there some problem with that? Is it failing? Or just that there's some deeper insight the HAL authors seem to have. Both bits need to be zero to modify the control register, do you have a situation where that's not true? Or just that they are imperceptibly different from your vantage point of a synchronous status register latch? Or that FLASH_WaitForLastOperation() should test both at the front-end?

https://github.com/STMicroelectronics/stm32wbxx_hal_driver/blob/21e01a8c608005706c6cd5a0a4d194bf3789f682/Src/stm32wbxx_hal_flash.c#L604

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MSmczek
Associate II

Thank you for your input.

We don't use HAL implementation.

From my point of view both do the same. From the description the implementation could use either of them