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

setup_wdt() placement in code

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



Joined: 14 Sep 2008
Posts: 1

View user's profile Send private message

setup_wdt() placement in code
PostPosted: Sun Sep 14, 2008 11:34 pm     Reply with quote

Why does the setup_wdt command have to be in the while loop, let alone main()?
Does turning on the WDT with setup_wdt(wdt_on) reset it's timer?


Code:

#include <12F683.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT, default 4Mhz clock

void main()

   while(true)
   { 
      output_toggle(pin_A2);
      setup_wdt(WDT_1152MS|WDT_TIMES_1|WDT_ON); //Turn on WDT here not in CONFIG
      sleep();                                  //WDT timeout wakes unit and resets WDT timer
   }
}


Jerry
Ttelmah
Guest







PostPosted: Mon Sep 15, 2008 3:03 am     Reply with quote

Answer to first line. It doesn't.
All that is needed, is for this function to be called _once_, before the code that wants the watchdog operating. It can be in the main, or in a subroutine called from the main, ahead of where watchdog functionality is used.
Answer to second, no....
It will clear the counter, if you use WDT_OFF, and then on the next line use WDT_ON. Clearing the SWDTEN bit, resets the counter, but as shown, it won't clear the counter.

Best Wishes
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