Skip to main content
arthurg
Associate II
December 14, 2016
Question

Trying to set BOR threshold without success

  • December 14, 2016
  • 1 reply
  • 629 views
Posted on December 14, 2016 at 23:55

I am trying to write code to set the BOR Level under program control for the STM32L151 but cannot get the result I need. I have the following:

if ((FLASH_GetUserOptionByte() & 0x0F) != OB_BOR_LEVEL4)

{

      FLASH_UnlockOptionByte();

     FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR |

           FLASH_FLAG_PGAERR | FLASH_FLAG_SIZERR | FLASH_FLAG_OPTVERR);

                                 

     FLASH_SetBORResetLevel(OB_BOR_LEVEL4);

     FLASH_LockOptionByte();

     FLASH_OBLLaunch();

If I have a current BOR level 3, it remains at level 3. The attempt to write level 4 fails. I am using IAR and single step. I see the bits reset in the PECR register, and the attempt to write OBR register with level 4, but it does not update with the correct value.

What am I doing wrong in the code? 

    This topic has been closed for replies.

    1 reply

    Walid FTITI_O
    Visitor II
    December 15, 2016
    Posted on December 15, 2016 at 10:20

    Hi ,

    Please, try always to create one only thread for the same subject. Redirection to this

    https://community.st.com/0D50X00009XkagYSAR

    -Walid F-