2021-01-06 12:38 AM
Hi,
for my application, I need to set my BOR threshold to about 2.5 V in my STM32L476RG. My understanding is that the preconfigured threshold is at level 4, which is 2.8 V (see RM0351 Rev 7, page 111).
What is a good strategy for setting the BOR_LEV bits with the HAL (ver. 1.7.0)? I tried to set them with following code, but after that, the L476 does not work anymore.
Also I don't really understand how these registers are organised. First of all, why are there two registers, that are basically the same:
HAL_StatusTypeDef set_BOR_threshold(void)
{
FLASH_OBProgramInitTypeDef FLASH_Handle;
FLASH_Handle.USERConfig = OB_BOR_LEVEL_0;
if (HAL_FLASH_OB_Unlock() != HAL_OK)
{
return HAL_ERROR;
}
if (HAL_FLASHEx_OBProgram(&FLASH_Handle) != HAL_OK)
{
return HAL_ERROR;
}
return HAL_OK;
}
In order for my code to work on first launch, I also would like to use OBL_LAUNCH.
Is there any way on how to achieve that with the HAL 1.7.0? Do I need to write all bits of this register?
Thank you very much in advance for any tips and hints.
2021-01-06 06:16 AM
You should be able to adapt the example:
You need to set the OptionType parameter so it knows which option byte you're changing.
> I need to set my BOR threshold to about 2.5 V in my STM32L476RG.
> FLASH_Handle.USERConfig = OB_BOR_LEVEL_0;
OB_BOR_LEVEL_0 is 1.8V, OB_BOR_LEVEL_3 is 2.5V.