cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L1xx SPL 1.3.0: Bug - FLASH_OB_GetUser() shifts too many bits right

Phil1
Associate II
Posted on December 18, 2014 at 11:40

Yet another bug / gotcha with the SPL...

FLASH_OB_GetUser() shifts the User option bits right 20 bits, which means that if you try to compare against the OB_IWDG_SW/HW, OB_STOP_RST or OB_STDBY_RST constants, you'll never get a comparison match.

The workaround for this one is to do an additional shift of 4 bits before comparing:

// Make sure the IWDG watchdog is enabled on startup

if (((FLASH_OB_GetUser() << 4) & OB_IWDG_SW) == OB_IWDG_SW) {

printf(''OptionBytes: IWDG not enabled, updating...\n'');

// Unlock option bytes and set IWDG, Reset-on-STOP and Reset-on-Standby

FLASH_OB_Unlock();

FLASH_OB_UserConfig(OB_IWDG_HW, OB_STOP_RST, OB_STDBY_RST);

FLASH_OB_Launch();

}

0 REPLIES 0