Skip to main content
Vu.Andy
Associate III
March 29, 2018
Question

Question regarding reset condition with respect to IWDG

  • March 29, 2018
  • 1 reply
  • 610 views
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();

    }

}

    This topic has been closed for replies.

    1 reply

    Andrew Neil
    Super User
    March 29, 2018
    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.

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.