cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_FLASH_OB_Launch() Hangs STM32L5

MBand.3
Associate III

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?

3 REPLIES 3
DHobl.1
Associate

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
Senior

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

Piranha
Chief II

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