Skip to main content
Visitor II
May 23, 2023
Question

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

  • May 23, 2023
  • 3 replies
  • 1397 views

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?

    This topic has been closed for replies.

    3 replies

    Visitor II
    November 24, 2023

    Good question asked but without the answer..

    Graduate II
    November 24, 2023

    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

    Graduate II
    November 29, 2023

    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

    Visitor II
    November 30, 2023

    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