2022-06-08 12:29 PM
I'm running this code in my application and it continuously reboots. I've since moved the writing of the option bytes to the programming stage to avoid it but want to understand what I'm doing wrong.
FLASH_OBProgramInitTypeDef ob;
HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);
HAL_FLASH_OB_Unlock();
HAL_FLASHEx_OBGetConfig(&ob);
if (ob.USERConfig & OB_IWDG_STOP_RUN) {
ob.USERConfig &= ~OB_IWDG_STOP_RUN;
HAL_FLASHEx_OBProgram(&ob);
HAL_FLASH_OB_Launch();
}
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
2022-06-08 04:14 PM
The ob structure is not initialized and that is not correct even for HAL_FLASHEx_OBGetConfig() function.
There is no need to unlock FLASH/OB for reading. Unlocking should be performed only when modifying FLASH/OB.
2022-06-09 06:50 AM
Thanks for the suggestions. Even if change that line to
FLASH_OBProgramInitTypeDef ob = {0};
it still results in the same outcome.