I wrote a simple watch dog timer program. First I light up a LED, and I want to see if watch dog timer will reset the chip and the LED would be turned off(I didn't feed the watch dog).

#include <reg51.h>
sfr WDTRST = 0xa6;

    P1 = ~0x01; //Light up the LED

    //Initialize the watch dog timer
    WDTRST = 0x1e;
    WDTRST = 0xe1;

I use Proteus to simulate, but the LED light is on(and it wouldn't be turned off afterwards) after I ran the program, I can't verify if the watch dog has reset the chip.

The circuit is exactly same as this one:

enter image description here (Due to some error I cannot upload the image)

Did I miss something important? Or reset wouldn't cause the LED be turned off?

  • \$\begingroup\$ A Proteus Isis screenshot is not the ideal way to upload a schematic. Use File --> Export Graphics --> Export Bitmap instead, then resize the image to a reasonable 500-550 pixel on the longest side. \$\endgroup\$ – Anindo Ghosh Apr 6 '13 at 7:25

In the given code, the LED is lit up as soon as the microcontroller starts operating. Thus, even if the watchdog timer were to reset the MCU, the LED would be off for an infinitesimal time, if at all.

Consider turning the LED off at start up, then after a delay of a few hundred milliseconds or so, turn it on.

If the MCU resets, it will turn the LED off again at that time.

Also, what is the watchdog time-out defined for your processor of choice? If it is too small to allow for that brief delay, this entire discussion is moot.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.