2024-09-06 8:16 AM
Hello.
How can we enable brown out for this processor and the brown out voltage?
Thank you.
Solved! Go to Solution.
2024-09-06 9:43 AM
Some mechanics along the lines of..
// Read the option byte
FLASH_OBProgramInitTypeDef OBInit;
HAL_FLASHEx_OBGetConfig(&OBInit);
// Check bitwise if the brownout level is not 3
if ((OBInit.USERConfig & OB_BOR_LEVEL_3) != OB_BOR_LEVEL_3)
{
// Set the brownout level to 3
OBInit.OptionType = OPTIONBYTE_USER;
OBInit.USERType = OB_USER_BOR_LEV;
OBInit.USERConfig |= OB_BOR_LEVEL_3;
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
HAL_FLASHEx_OBProgram(&OBInit);
// This function needs to be called Unlocked Flash and OB state.
HAL_FLASH_OB_Launch();
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
HAL_FLASH_OB_Launch();
}
2024-09-06 9:34 AM
Perhaps it's covered in the Reference Manual, or there are examples in the code trees of CubeL4 ?
2024-09-06 9:43 AM
Some mechanics along the lines of..
// Read the option byte
FLASH_OBProgramInitTypeDef OBInit;
HAL_FLASHEx_OBGetConfig(&OBInit);
// Check bitwise if the brownout level is not 3
if ((OBInit.USERConfig & OB_BOR_LEVEL_3) != OB_BOR_LEVEL_3)
{
// Set the brownout level to 3
OBInit.OptionType = OPTIONBYTE_USER;
OBInit.USERType = OB_USER_BOR_LEV;
OBInit.USERConfig |= OB_BOR_LEVEL_3;
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
HAL_FLASHEx_OBProgram(&OBInit);
// This function needs to be called Unlocked Flash and OB state.
HAL_FLASH_OB_Launch();
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
HAL_FLASH_OB_Launch();
}
2024-09-06 10:33 AM
You can adjust it in STM32CubeProgrammer along with other option bytes.
2026-01-26 12:35 AM
Is the option byte available in Cube IDE? I can't see it.
I've used the above code after initialisation and think it should be before initialisation, or better still in the option byte without a routine to change it.
2026-01-26 6:26 AM
No. Use STM32CubeProgrammer.
2026-01-26 6:46 AM
I've moved the code posted above to immediately after HAL_Init() and it runs OK. I haven't seen any problems yet from slow powering up that I was seeing before. I'm very surprised ST didn't include that in the IOC section. I will use it from the Cube Programmer unless anyone finds it lurking in the IOC anywhere. Device is STM32L412