cancel
Showing results for 
Search instead for 
Did you mean: 

Question regarding reset condition with respect to IWDG

Vu.Andy
Associate III
Posted on March 29, 2018 at 23:02

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();

    }

}

1 REPLY 1
Andrew Neil
Evangelist III
Posted on March 30, 2018 at 00:13

You could just try it ... ?

BTW: you can't erase the CPU - you erase (and re-program) the Flash memory.