CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

O.T. - WDT timeout

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Doug
Guest







O.T. - WDT timeout
PostPosted: Mon Mar 01, 2004 11:13 am     Reply with quote

Where in the program should I put restart_wdt()? I need the prescaler for timer0 and my program loop is 35ms. Would it be a bad idea to put a restart_wdt() instruction inside a delay loop which lasts 25ms? If the program gets stuck in the loop it will never time out. What should I do?

Thanks,
Doug
agrj



Joined: 26 Sep 2003
Posts: 48

View user's profile Send private message

PostPosted: Mon Mar 01, 2004 11:27 am     Reply with quote

Hi,

which PIC are you using? how are you doing this loop?

thanks

Dinho
Ttelmah
Guest







Re: O.T. - WDT timeout
PostPosted: Mon Mar 01, 2004 11:53 am     Reply with quote

Doug wrote:
Where in the program should I put restart_wdt()? I need the prescaler for timer0 and my program loop is 35ms. Would it be a bad idea to put a restart_wdt() instruction inside a delay loop which lasts 25ms? If the program gets stuck in the loop it will never time out. What should I do?

Thanks,
Doug

You speak as though you are waiting for an 'event', that happens at 35mSec intervals?.
If so, then consider using a counter inside your wait loop. Something like:
Code:

counter=65000;
while (TRUE) {
    if (counter) {
       --counter;
       restart_wdt();
    }
    if (check_for_event()) break;
}
//The code will arrive here, if the 'check_for_event' test has returned true


If the counter gets to zero before the 'check_for_event' test returns true, the watchdog will stop resetting, and 18mSec latter the watchdog will trigger. The 'event' is still tested in this time.

Best Wishes
Doug
Guest







PostPosted: Mon Mar 01, 2004 12:39 pm     Reply with quote

I'm using a 12c672 (I would like to use a 12F675 but my compiler version does not do them.)

Here is the loop:
Code:

no_pulse = TRUE;                      // set no_pulse flag
time_out = MAX_OFF_TIME;            // number of times to loop
do{
   if (!input(PULSE_IN)) {          // test PULSE_IN pin
      disable_interrupts(GLOBAL);     
      edge_detect();           // call routine to measure pulse
      enable_interrupts(GLOBAL);
      if (!no_pulse)             // if no_pulse is cleared,
         break;                  // jump out of loop
   }
} while(--time_out);

It loops the number of times in time_out and if PULSE_IN pin goes low it calls edge_detect() which will measure the length of the pulse and make no_pulse FALSE. When time_out reaches 0 it will exit the loop with no_pulse set to TRUE.

Thanks,
Doug
Doug
Guest







PostPosted: Mon Mar 01, 2004 12:45 pm     Reply with quote

Can just I add a restart_wdt() into the loop? or is it better to have it outside the loop.

How many of you actually use the WDT?

Thanks,
Doug
dyeatman



Joined: 06 Sep 2003
Posts: 1939
Location: Norman, OK

View user's profile Send private message

automatic Delay Watchdog restart
PostPosted: Mon Mar 01, 2004 1:20 pm     Reply with quote

You might read the user manual about #use delay(xxxxxxx, restart_wdt) to see if this might help.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 01, 2004 1:36 pm     Reply with quote

There are lots of articles on how to use a watchdog timer
over at Embedded.com. Here is one:
http://www.embedded.com/story/OEG20010920S0064
Doug
Guest







PostPosted: Mon Mar 01, 2004 2:58 pm     Reply with quote

Thank you, that cleared up a few questions.

Doug
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group