This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Easy WatchDog Timer Questions

Other Parts Discussed in Thread: CODECOMPOSER

Hi TI:

I have a few questions about WatchDog Timer Driver.

I do not think I have a clear understanding of how this works.

I am running TI-RTOS 1.10.0.23 & CodeComposer 5.5.0.

I wrote a pretty simple program trying to emulate the WatchDog example that currently exists.

 

Watchdog_Params_init(&Params_WatchDog);    

Params_WatchDog.callbackFxn = WatchDog_CallBack;  (2)  

Params_WatchDog.resetMode = Watchdog_RESET_ON;    

Params_WatchDog.debugStallMode = Watchdog_DEBUG_STALL_ON;

Handle_Watchdog = Watchdog_open(Board_WATCHDOG, &Params_WatchDog);    

 

/* Watchdog objects in EK_TM4C123GXL.c */

WatchdogTiva_Object watchdogTivaObjects[EK_TM4C123GXL_WATCHDOGCOUNT];

/* Watchdog configuration structure */

const WatchdogTiva_HWAttrs watchdogTivaHWAttrs[EK_TM4C123GXL_WATCHDOGCOUNT] = {  

/* EK_TM4C123GXL_WATCHDOG0 with 1 sec period at default CPU clock freq */

    {WATCHDOG0_BASE, INT_WATCHDOG, 80000000},};  (1)

 

I am stuck in a few places.

(1), It looks like the WatchDog Timer is set to 80 million or 1 Second before something happens.  Correct?  Essentially, this is the CPU frequency of the Clock.

(2), I really do not understand what is supposed to happen. 

Under what Circumstance does WatchDog_CallBack get called? 

Can it be called multiple times?

It seems that I have to have .resetMode set to WatchDog_RESET_ON in order for that to happen.  Correct?

(3). What I'm trying to accomplish seems pretty simple; but, I am just not getting it.

If the code state is healthy, I could periodically "feed the dog" and make the WDT start counting down again before it hits 0.

Of course, if the code state was hung, the dog could not be fed and a recovery function would be invoked (when the counter hit 0) so that I could gain control again.  (reboot if possible)

If this is how it can work, I am not seeing it.  Any help would be great.

Thanks

Rick

 

 

  • Hi Rick,

    Rick Faszold said:

    Under what Circumstance does WatchDog_CallBack get called? 

    Can it be called multiple times?

    The Watchdog callback function is a function that will be called whenever the Watchdog causes an interrupt.  So, it can be called multiple times.  I think it may be a useful exercise to put a breakpoint on the callback function and note the times that it is called in the example.

    Unfortunately the TI-RTOS documentation itself is a bit lacking on Watchdog.  In case you haven't seen it, I first wanted to point out the following API doc, which has details on how Watchdog is used with TI-RTOS (as well as other modules):

    C:\ti\tirtos_1_10_00_23\docs\doxygen\html\index.html

    But to get the further details on Watchdog that you are looking for, I think the following document will help you:

    TivaWare™ Peripheral Driver Library User's Guide

    This document is included with your TI-RTOS installation:

    tirtos_1_10_00_23\products\TivaWare_C_Series-1.0\docs\SW-DRL-UG-1.0.pdf

    From that document, I saw a couple of useful details on the reload value ("28 Watchdog Timer" on page 401):

    "The watchdog timer module generates the
    first timeout signal when the 32-bit counter reaches the zero state after being enabled"

    "After the first timeout event, the 32-bit counter is
    reloaded with the value of the watchdog timer load register, and the timer resumes counting down
    from that value"

    Steve

  • Hi Steve:

    I think I'm just looking at all of this the wrong way.

    How about a few more simple questions? 

    1. When Watchdog_RESET_ON is set, does this actually mean that the board does a hard reset like ctrl,alt,delete?  And processing goes back to main() and start all over?  If not, what does Reset do in this case?

    2. Watchdog_clear seems be associated with Watchdog_RESET_ON, does this function act like "feeding the dog"?  Or, shall I say, resetting the "Count Down Timer or WatchDog Timer" before a RESET is triggered?  So, let's say I have a Watchdog_Timer set to 3 seconds, as long as I call Watchdog_clear every 2 seconds, an Interrupt or reset will never be triggered.  Correct?

    3. Watchdog_clear has the effect of clearing Interrupts.  This would also mean that if I am using Watchdog_RESET_OFF that, it would clear the Interrupt.. and that is about it.  If the Watchdog threshold was exceeded, I could check the Interrupt flag, see if was set and do something if I wanted to.  Correct?

    4. The Callbacks... I have a line in my code that looks like: 

         Params_WatchDog.callbackFxn = WatchDog_CallBack;    

    When should I expect this function to get called?  My expectation was about 80M clock ticks or once a second.  So, I'm not really sure how/why this gets called.

    I have a Task that is: while(1) { print junk to console }

    I'm expecting WatchDog_CallBack to get called; but, I don't.   That behavior is interesting to me.

    Thanks for helping.  I really appreciate it.   The documentation could use a bit of clarity.  I typically read it well before I post.  Again, thank you.

    Rick

     

  • Hi Rick,

    Rick Faszold said:
    1. When Watchdog_RESET_ON is set, does this actually mean that the board does a hard reset like ctrl,alt,delete?  And processing goes back to main() and start all over?  If not, what does Reset do in this case?

    According to the docs, the Watchdog timer will reset the processor.

    Rick Faszold said:
    2. Watchdog_clear seems be associated with Watchdog_RESET_ON, does this function act like "feeding the dog"?  Or, shall I say, resetting the "Count Down Timer or WatchDog Timer" before a RESET is triggered?  So, let's say I have a Watchdog_Timer set to 3 seconds, as long as I call Watchdog_clear every 2 seconds, an Interrupt or reset will never be triggered.  Correct?

    3. Watchdog_clear has the effect of clearing Interrupts.  This would also mean that if I am using Watchdog_RESET_OFF that, it would clear the Interrupt.. and that is about it.  If the Watchdog threshold was exceeded, I could check the Interrupt flag, see if was set and do something if I wanted to.  Correct?

    That's what it sounds like to me, but I would recommend that you try it.  From what I can see, Watchdog_clear() (I believe WatchdogTiva_clear for your case) just calls the Tivaware API WatchdogIntClear(), which clears the interrupt so that it no longer asserts.

    Rick Faszold said:

    4. The Callbacks... I have a line in my code that looks like: 

         Params_WatchDog.callbackFxn = WatchDog_CallBack;    

    When should I expect this function to get called?  My expectation was about 80M clock ticks or once a second.  So, I'm not really sure how/why this gets called.

    I have a Task that is: while(1) { print junk to console }

    I'm expecting WatchDog_CallBack to get called; but, I don't.   That behavior is interesting to me.

    The callback function should be called when the Watchdog causes an interrupt ... can you please try the standard Watchdog example and see if you are hitting the callback function in the example?

  • Hi Steven:

    This is helpful....  OK, let me go back and see if I can make this work in a way that is meaningful to me.

    I'll either ask a few more questions or I'll verify.  Need a few days to get into this.

    Thanks

    Rick

     

     

  • Hi Stephen:

    I have it figured out. 

    The documentation could have been a bit more helpful and I was making a simple problem too difficult.

    Thanks for helping.

    Rick