Question
problem while programming Option Bytes to configure brown out
Hi,
after I try to program option byte to configure brown out I can't anymore reach the micro.
I'm working with a STM32G071KBU3.
I also try to connect to the micro using CUBE programmer. I get the error "target not found". Below my code.
The instruction that cause the fault was HAL_FLASH_OB_Launch();
How can I get my micro out of this fault? Which is the error on the code below.
Thankyou
static void BrownOut_Init(void)
{
FLASH_OBInitStruct.WRPArea = OB_WRPAREA_ZONE_A;
HAL_FLASHEx_OBGetConfig(&FLASH_OBInitStruct);
// unlock FLASH control register access
HAL_FLASH_Unlock();
// unlock FLASH Option Bytes Registers access
HAL_FLASH_OB_Unlock();
FLASH_OBInitStruct.OptionType = OPTIONBYTE_USER;
FLASH_OBInitStruct.USERType = OB_USER_BOR_EN | OB_USER_BOR_LEV;
FLASH_OBInitStruct.USERConfig = OB_BOR_ENABLE | OB_BOR_LEVEL_FALLING_0 | OB_BOR_LEVEL_RISING_0;
HAL_FLASHEx_OBProgram(&FLASH_OBInitStruct);
/* Launch the option byte loading */
HAL_FLASH_OB_Launch();
// lock del FLASH Option Bytes Registers access
HAL_FLASH_OB_Lock();
// lock del FLASH control register access
HAL_FLASH_Lock();
}