cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, I am implementing the bank switching logic for STM32L476 Environment: Eclipse for code development : ST-Link/V2 Debugger for flashing and debugging binaries: Why below code gets stuck at the HAL_FLASH_OB_Launch(); ?

Neel
Associate III

   FLASH_OBProgramInitTypeDef   OBInit;

   /* Set BFB2 bit to enable boot from Flash Bank2 */

   /* Allow Access to Flash control registers and user Flash */

   HAL_FLASH_Unlock();

   /* Clear OPTVERR bit set on virgin samples */

   __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);

   /* Allow Access to option bytes sector */

   HAL_FLASH_OB_Unlock();

   /* Get the Dual boot configuration status */

   HAL_FLASHEx_OBGetConfig(&OBInit);

   /* Enable/Disable dual boot feature */

   OBInit.OptionType = OPTIONBYTE_USER;

   OBInit.USERType  = OB_USER_BFB2;

   if (((OBInit.USERConfig) & (OB_BFB2_ENABLE)) == OB_BFB2_ENABLE) {

      OBInit.USERConfig = OB_BFB2_DISABLE;

   } else {

      OBInit.USERConfig = OB_BFB2_ENABLE;

   }

HAL_FLASHEx_OBProgram(&OBInit)

HAL_FLASH_OB_Launch();

HAL_NVIC_SystemReset();

0 REPLIES 0