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

Watch dog timer

I am using LPC2132 (NXP). when I am feeding the watch dog timer from main loop, and in main loop, i am sending data continuosly to uart-1 at 38.4kbps. then my controller is resetting some time. while debugging i found that the reset is happening at the time of feeding the watch dog timer. At the time of the reset the watch dog timer is not expired. my watch dog interrupt was at highest priority, compared to uart1, and uart is interrupt based (both tranmission and reception). I think the problem is of feeding. in feeding i am writing 0xAA and 0x55.
Then i changed the program, and set one flag in the main loop, and in timer interrupt (higher priority compared to uart1 interrupt) iam feeding the watch dog, then the reset is not happening. and working fine.
my feeding time is 400msec, and timeout value is 600msec.
if any body have idea about it, please help.

  • Have you read the Philips application notes about handling spurious interrupts, and to protect the feed writes to the watchdog?

    There are a number of useful application notes on www.nxp.com/.../LPC2132FBD64.html

  • When you feed watchdog in your program loop and your interrupts are enabled their is possibility that interrupt occurs in between your feed sequence.
    The watchdog sequence has to be feed in continuation like a monotonous action. Sodisable the interrupts before feeding the sequence and reenable after feeding.

    In your timer interrupt the seq. is feed properly as its not interrupted.

    Suvidh

  • I needs to give I2C interrupt higher priority compared to timer. So if iam feeding in timer, wnd in between if i2c interrupt came, the same problem will come. So I needs to disable all the interrupt before the feeding. So i written like this

    void WDT_vFeed(void)
    {
     unsigned long ulIntrpt;
    
      ulIntrpt = VICIntEnable;
      VICIntEnClr = ulIntrpt;
      WDFEED = 0xAA;
      WDFEED = 0x55;
      VICIntEnable = ulIntrpt;
    }
    

    If i am disabling and enabling the interrupts by this way, Is there any chance to lose any interrupts. Is there is any other problem while doing this method.
    If there is any other good method to do this, please help me out.

  • There's at least one potentially serious problem with it: it takes two separate instructions to save interrupt state, then disable interrupts. That means an interrupt can conceivably arrive between the two, and invalidate the saved interrupt status. You want to read up on atomic instructions and semaphores.

  • I solve exactly same problem (eg. wdog feeding) with SWI function, placing wdog feeding sequence inside.
    Instructions in SWI are atomic, because (core, not VIC) interrupts are disabled.

    void __swi(8) WDRefresh (void);
    void __SWI_8 (void)
    {

    WDFEED = 0xAA; // Feeding sequence WDFEED = 0x55;
    }

    Don't forget to modify file "SWI_Table.s".