admin管理员组文章数量:1126098
As for STM32H563 MCU, will it result in a system reset after executing the function HAL_FLASH_OB_Launch? From my experiment, before executing HAL_FLASH_OB_Launch, I can read data from MCU via I2C while all returned data become 0xFF(i.e. invalid data) after executing this function. It seems that the MCU is suspended or reset. When I tried to trace the code through Debugger Section in Keil, the code can run smoothly to subsequent routines.
Here is my code below.
void EnableWriteProtect(uint8_t image)
{
FLASH_OBProgramInitTypeDef OBInit = {0};
FLASH_OBProgramInitTypeDef sOBPrev = {0};
uint32_t WRPSector;
/* Unlock the User Flash area */
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
/* Get the boot configuration status */
HAL_FLASHEx_OBGetConfig(&OBInit);
WRPSector = OBInit.WRPSector | BIT(0);
OBInit.Banks = FLASH_BANK_2;
OBInit.OptionType = OPTIONBYTE_WRP;
OBInit.WRPState = OB_WRPSTATE_ENABLE;
OBInit.WRPSector = WRPSector;
HAL_FLASHEx_OBProgram(&OBInit);
/* Launch Option bytes loading */
HAL_FLASH_OB_Launch();
/* Unlock the User Flash area */
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
}
From my experiment, before executing HAL_FLASH_OB_Launch, I can read data from MCU via I2C while all returned data become 0xFF(i.e. invalid data) after executing this function. It seems that the MCU is suspended or reset. When I tried to trace the code through Debugger Section in Keil, the code can run smoothly to subsequent routines.
My expectation: I hope to implement write protection for specific MCU flash areas normally without resetting the MCU.
版权声明:本文标题:flash - Does executing the function HAL_FLASH_OB_Launch cause a system reset on STM32H563 MCU? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736679753a1947361.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论