Skip to main content
MBand.3
Associate III
Nov 17, 2020 4:43 PM UTC
Question

HAL_FLASH_OB_Launch() Hangs STM32L5

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

DHobl.1
Visitor II
Jul 16, 2021 9:52 AM UTC

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();

RPG
Associate III
Jan 13, 2023 8:07 AM UTC

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

Piranha
Principal III
Jan 14, 2023 5:52 PM UTC

> 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().