cancel
Showing results for 
Search instead for 
Did you mean: 

problem while programming Option Bytes to configure brown out

DAUSILI
Associate II

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();
}
3 REPLIES 3
Diane POMABIA
ST Employee

Hello @DAUSILI 

What was state of BOOT_LOCK before trying to programm your OB?

Regards

Diane

Hi Diane,

the Flash memory address: 0x1FFF 7870 where is located BOOT_LOCK was 0x0000 0000 (as ST production value).
thank you for your support.

DAUSILI
Associate II

Hi,

any other suggestions please?

Reading in other forum thread about this topic someone suggest to use ST-link Utility tool to reload the option bytes to their default value. But also with this tool I can't reach the micro.

Despite this my main problem now is to have a BOR config procedure working.
In my application I haven't an extern reset circuit.
what could I have done wrong on my code?
Regards.