|
|
View previous topic :: View next topic |
Author |
Message |
Jerry_ch701
Joined: 14 Sep 2008 Posts: 1
|
setup_wdt() placement in code |
Posted: Sun Sep 14, 2008 11:34 pm |
|
|
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
|
|
Posted: Mon Sep 15, 2008 3:03 am |
|
|
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 |
|
|
|
|
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
|