Skip to main content
Visitor II
November 17, 2020
Question

HAL_FLASH_OB_Launch() Hangs STM32L5

  • November 17, 2020
  • 3 replies
  • 2344 views

I'm attempting to enable the SRAM2 parity bits on an STM32L552, and any time I call HAL_FLASH_OB_Launch, the chip hangs. I've also tried directly setting the OBL_LAUNCH bit in the NCSR register with the same results.

I've looked through some of the L5 examples, but none of them show a different order of operations than what I'm doing:

HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
FLASH->OPTR &= ~((1 << 24) | (1 << 25));
HAL_FLASH_OB_Launch();
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();

Is there something I'm missing?

    This topic has been closed for replies.

    3 replies

    Visitor II
    July 16, 2021

    For the STM32F303 I got the answer from STM-Suport that the OB has to be erased before it can be written (probably it might be useful then to read it first and save the settings read out).

    Also, the OB_Launch command triggers a reset, so OB_Lock and Lock will never be reached in code (reset will also occur by manually setting the OBL_LAUNCH-Bit in NCSR-register ).

    Try it this way:

    HAL_FLASH_Unlock();

    HAL_FLASH_OB_Unlock();

    HAL_FLASH_OB_Erase();

    FLASH->OPTR &= ~((1 << 24) | (1 << 25));

    HAL_FLASH_OB_Launch();

    Explorer II
    January 13, 2023

    It seems that HAL_FLASH_OB_Erase() doesn't exist. Have you tried it before?

    Graduate II
    January 14, 2023

    > L5 examples, but none of them show a different order of operations

    Except those examples use HAL_FLASHEx_OBProgram(), which you just ignored. The FLASH_OPTR is not just an ordinary register - read the reference manual.

    > HAL_FLASH_OB_Erase() doesn't exist

    There is a HAL_FLASHEx_OBErase().