2018-03-29 02:02 PM
I have my program something like this below.
My question is under which condition (block 1) codes executed and (block 2) codes executed.
1. At board power up, (block 2) executed. (for sure).
2. If I erase the CPU, reprogram the CPU with the power still on, then which block will be executed, 1 or 2?
3. If I do hard reset on the CPU, which block will be executed?
Thanks.
main()
{
//Init clock ...
//Init IWDG
if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET)
{
//block 1 codes executed.
}
else
{
//block 2 codes executed
}
while(1)
{
//some codes.
HAL_IWDG_Refresh();
}
}
2018-03-29 03:13 PM
You could just try it ... ?
BTW: you can't erase the CPU - you erase (and re-program) the Flash memory.