Skip to main content
ckim.2390
Associate II
June 3, 2021
Solved

MCU crashes after using HAL_OB function.

  • June 3, 2021
  • 1 reply
  • 815 views

I have tried the HAL_OB function.

No change was good.

So I ran the code below.

After that, ST LINK connection is not possible.

MCU is not responding.

Is there no way to get it back?

MCU : STM32G07x

CODE :

        FLASH_OBProgramInitTypeDef OBInit;

        if(HAL_FLASH_Unlock() == HAL_OK) 

        {

          if(HAL_FLASH_OB_Unlock() == HAL_OK) 

          {

            PRINT("HAL_FLASH_OB_Unlock OK\r\n");

            OBInit.OptionType = OPTIONBYTE_USER;

            // OBInit.USERType = OB_USER_nRST_STDBY|OB_USER_IWDG_STOP|OB_USER_nRST_STOP;

            OBInit.USERType = OB_USER_ALL;

            OBInit.USERConfig = 0;

            PRINT("HAL_FLASH_Unlock OK\r\n");

            HAL_FLASHEx_OBProgram(&OBInit); 

            if(HAL_FLASH_OB_Lock() == HAL_OK) 

            {

                HAL_FLASH_Lock(); 

                HAL_FLASH_OB_Launch(); 

            }

            else

              PRINT("HAL_FLASH_OB_Lock ERROR\r\n");

          }

          else

            PRINT("HAL_FLASH_OB_Unlock ERROR\r\n");

        }

        else

          PRINT("HAL_FLASH_Unlock ERROR\r\n");

This topic has been closed for replies.
Best answer by TDK

Try connecting under reset, or connecting with BOOT0 held high. Probably your code is crashing shortly after the code starts and is causing connection issues with the debugger.

Locking prior to calling HAL_FLASH_OB_Launch will stop the function from working.

1 reply

TDK
TDKBest answer
June 3, 2021

Try connecting under reset, or connecting with BOOT0 held high. Probably your code is crashing shortly after the code starts and is causing connection issues with the debugger.

Locking prior to calling HAL_FLASH_OB_Launch will stop the function from working.

"If you feel a post has answered your question, please click ""Accept as Solution""."