This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Usage of wachdog timer in P89V51RD2

Hi, I am using P89V51RD2 Controller keil softare and flash magic for my application .I am using three timers(T0,T1,T2),Srial interrupt,External 0 & 1 interrupts in my program.The code size is about 40k.While communicating with gateway through serial port it is getting struct few times in day .I have taken care of enabling interrupts, loops at all cost. Now I want to include watch dog timer in my code.Kindly tell me how to use watch dog timer.I am not able to implement it information providded in the data sheet. kindly give me example codes .I am in urgent to solve my probalam .please help me.
With regards,
A.Bhaskar Reddy,
abreddy1990@yahoo.com

  • Bhaskar,

    Its very easy.

    WDT - WatchDog Timer

    WDRE should be set to enable WDT.

    then Load count(WDT time period) into WDTD using formula.

    Period = (255 - WDTD) x 344064 x 1 / fCLK(XTAL1)

    for fclk = 11.0592 MHz and WDTD = 254 gives time period of 31.11 ms and WDTD = 221 gives
    time period of 1 second that means you have to refresh WDT within 1 second. if controller failed to do so and this time period overflows then WDT will reset the controller.

    SWDT should be set to start the WDT.

    // WDT Initialization code

    WDTC = 0x08;
    WDTD = 0xDD;
    WDTC |= 0x02;
    WDTC |= 0x01;

    // WDT refresh code (This code should be execute before every 1 sec or WDT will reset controller)

    WDTD = 0xDD;
    WDTC |= 0x02;

    // You can check if reset has occured in code using WDTS flag bit. this bit is not cleared automatically It can be cleared in software.

    :)

  • Hi, Thank you very much.I have tried with above information.It is working well.
    With Regards,
    Bhaskar Reddy,
    abreddy1990@yahoo.com