Skip to content

Setting/getting brownout reset (BOR) level. #2251

Closed Answered by bobemoe
bobemoe asked this question in Q&A
Discussion options

You must be logged in to vote

I think I figured it out:

uint8_t Get_BOR_Level(void)
{
    FLASH_OBProgramInitTypeDef OBInit;
    HAL_FLASHEx_OBGetConfig(&OBInit);
    return OBInit.BORLevel;
}

void Set_BOR_Level(uint8_t BOR_Level) {
    FLASH_OBProgramInitTypeDef OBInit;

    // Unlock the Flash to enable the flash control register access
    HAL_FLASH_Unlock();

    // Clear any existing option bytes error flags
    __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPERR);

    // Unlock the Options Bytes
    HAL_FLASH_OB_Unlock();

    // Get the current option bytes configuration including other settings
    HAL_FLASHEx_OBGetConfig(&OBInit);

    // Modify only the BOR Level
    OBInit.OptionType = OPTIONBYTE_BOR;
    OBInit.BORL…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by fpistm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant