watchdog timer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

watchdog timer

Jump to solution
1,723 Views
rajiv28
Contributor I

hello....

                    warm wishes of the day.i have 1 query.When our microcontroller gets hang ,is the interrupts are in working condition?If yes than what does hangs mean & if no than how watchdog timer works?help me out.

 

Thanks in advance

Labels (1)
0 Kudos
1 Solution
702 Views
peg
Senior Contributor IV

Hello,

 

When a microcontroller "hangs" it normally doesn't actually stop, it is still executing code, just not in a way that gets anything useful done. So when a interrupt occurs it still happens as normal but when it finishes execution returns right back to where it left off, back in the "hang" loop.

If the code it is executing in the hang condition includes a COP reset then the COP is not going to help at all.

Even if the COP does reset the processor it may simply end up back in the same place anyway.

 

View solution in original post

0 Kudos
6 Replies
702 Views
bigmac
Specialist III

Hello, I am not entirely sure about your query.

 

When an interrupt occurs that is associated with a hardware event, for example a timer interrupt, the ISR code that is executed is entirely independent of any other code.  This code may still execute even if the code within the main loop is not executing correctly.  This is why ISR code must never clear the watchdog timer.

 

Of course, if the ISR code itself should enter an endless loop, no other code will be able to execute, and the watchdog should timeout assuming it is enabled.

 

Regards,

Mac

 

0 Kudos
702 Views
rajiv28
Contributor I

hellooooooo bigmec,

       r u der?Please explain me about my query...plz.

0 Kudos
702 Views
rajiv28
Contributor I

Hi....

 

GM....I beleive you have tried to explain my question but may be i not getting it.......can u please be little bit clearer......what does hangs means it our interrupts are working in hang condition? and how does watchdog works in hanging condition?

thanks..

0 Kudos
702 Views
bigmac
Specialist III

Hello,

 

I can think of a few causes why the MCU might appear to "hang" - there may also be other causes.  The following would be due to coding problems.

 

  1. The main loop code does not properly execute, maybe because an expected condition does not eventuate and a "wait loop" never exits.  The cause may be bad coding, or an undersize stack overwriting global variables.  Hardware interrupts should continue to operate normally.
  2. The code for an ISR never exits a wait loop.  Strictly speaking, ISR code should not contain any wait loop.
  3. ISR code is repeatedly entered so that no other code can execute.  The usual reason is that the interrupt flag for the particular interrupt is not cleared prior to exiting the ISR.
  4. The MCU repeatedly enters reset, which could be a COP reset, or one of the other reset sources.  Maybe the COP timer is not being cleared from within a wait loop, and timeout occurs, or maybe the COP reset occurs due to one of the reasons mentioned above.

It is not the purpose of the COP (watchdog) timer to "fix" any of these problems - you must correct the coding errors.

 

Regards,

Mac

 

0 Kudos
702 Views
rajiv28
Contributor I

Dear my question is whether the interrupts works in hang condtion?if yes than how?

0 Kudos
703 Views
peg
Senior Contributor IV

Hello,

 

When a microcontroller "hangs" it normally doesn't actually stop, it is still executing code, just not in a way that gets anything useful done. So when a interrupt occurs it still happens as normal but when it finishes execution returns right back to where it left off, back in the "hang" loop.

If the code it is executing in the hang condition includes a COP reset then the COP is not going to help at all.

Even if the COP does reset the processor it may simply end up back in the same place anyway.

 

0 Kudos