cancel
Showing results for 
Search instead for 
Did you mean: 

MCU crashes after using HAL_OB function.

ckim.2390
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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".

View solution in original post

1 REPLY 1
TDK
Guru

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".