cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L - can't change Brownout level

juergen23
Associate II
Posted on January 26, 2015 at 11:25

Hey there,

today i wanted to change the brownout level from 1 to 4, but i failed. I'm using the STM32L151VDT6 and the following code at startup

if
((FLASH_OB_GetBOR() & 0x0F) != OB_BOR_LEVEL4){
/* Unlocks the option bytes block access */
FLASH_OB_Unlock();
/* Clears the FLASH pending flags */
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | 
 FLASH_FLAG_PGAERR | FLASH_FLAG_SIZERR | FLASH_FLAG_OPTVERR);
/* Select The Desired V(BOR) Level------------------------*/
FLASH_OB_BORConfig(OB_BOR_LEVEL4);
/* Launch the option byte loading and generate a System Reset */
FLASH_OB_Launch();
}

It seems that i cannot change the BOR level this way so i tried the ST-Link Utility in which i can access the Option Bytes, too. Result: ''Could not set Option bytes'' In the description of the controller i found this: ''Low power, ultrasafe BOR (brownout reset) with 5 selectable thresholds'' but in reference manual in section ''Status register'' i found at the end of the ''User option byte'' the note ''These bits are read only''... so now i'am a little #confused Is it possible to change the brownout level or not? If possible, what am i doing wrong? #help #stm32l #brownout-level #brownout
3 REPLIES 3
juergen23
Associate II
Posted on February 02, 2015 at 18:34

No one using/changing the brownout level? #helpless

Posted on February 02, 2015 at 19:48

Apparently not...

You've got an FLASH_Unlock(); in there prior, right?

Tips, Buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
juergen23
Associate II
Posted on February 04, 2015 at 17:02

Uh, shame on me. #oops

The following code works fine for setting the brownout level to level 4:

if ((FLASH_OB_GetBOR() & 0x0F) != OB_BOR_LEVEL4){
FLASH_Unlock();
/* Unlocks the option bytes block access */
FLASH_OB_Unlock();
/* Clears the FLASH pending flags */
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR |
FLASH_FLAG_PGAERR | FLASH_FLAG_SIZERR | FLASH_FLAG_OPTVERR);
/* Select The Desired V(BOR) Level------------------------*/
FLASH_OB_BORConfig(OB_BOR_LEVEL4);
/* Launch the option byte loading and generate a System Reset */
FLASH_Lock();
FLASH_OB_Launch();
}

@clive1: Thank you very much for your help.