Skip to main content
Associate III
July 5, 2023
Question

problem while programming Option Bytes to configure brown out

  • July 5, 2023
  • 2 replies
  • 1287 views

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();
}
    This topic has been closed for replies.

    2 replies

    ST Employee
    July 5, 2023

    Hello @DAUSILI 

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

    Regards

    Diane

    DAUSILIAuthor
    Associate III
    July 5, 2023

    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.

    DAUSILIAuthor
    Associate III
    July 6, 2023

    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.