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

Watchdog Timer of ADUC842

Dear sir,

I am using ADUC842 for my design.
I want to set watchdog timer of 2 sec for any errorneous condition.

In my main function, i have enabled all interrupts already...

I need to configure watchdog timer.

But before that i should disable all the interrupts,set the watchdog timer and again enable the interrupts.
since i have enabled all interrupts,i cant configure watchdog timer in the main function.

where should i configure the watchdog timer
? pls help.

Regards,
Mayuri G

Parents
  • CLR EA //disable interrupts while writing

    SETB WDWR //allow write to WDCON

    MOV WDCON,#72H //enable WDT for 2.0s timeout

    SETB EA //enable interrupts again (if rqd)

    this is what i am supposed to write in my main function if i am using watchdog.

    but if i clear my interrupts,den my ISRs wont be executed.

    i need to keep my interrupts on always

Reply
  • CLR EA //disable interrupts while writing

    SETB WDWR //allow write to WDCON

    MOV WDCON,#72H //enable WDT for 2.0s timeout

    SETB EA //enable interrupts again (if rqd)

    this is what i am supposed to write in my main function if i am using watchdog.

    but if i clear my interrupts,den my ISRs wont be executed.

    i need to keep my interrupts on always

Children
  • CLR EA         //disable interrupts while writing
    SETB WDWR      //allow write to WDCON
    MOV WDCON,#72H //enable WDT for 2.0s timeout
    SETB EA        //enable interrupts again (if rqd)
    

    How long, exactly, do you think that code sequence takes to execute?

    You only need to do it once- at startup.

    Do you really think that it will make any significant difference if you do this immediately before you enable your other interrupts??

    "if i clear my interrupts,den my ISRs wont be executed"

    Until you enable them again!!

    "i need to keep my interrupts on always"

    See above - you only need to do this once, and only at the very start of your code - where is the problem in that?!

  • Note that there is a big difference between disabling and clearing interrupts.

    Disabling interrupts means devices with interrupt support will detect events and latch the interrupt state. But the device isn't allowed to kick the processor core to switch to the ISR. When the interrupts are enabled again, any pending interrupts will be serviced.

    Clearing interrupts is telling peripherials that any pending interrupts should be permanently forgotten. A completely different thing.

    Your play with CLR EA is disabling interrupts. It is not clearing any interrupts. So any interrupts detected before or during this critical section will trig after you enable interrupts again.