View previous topic :: View next topic |
Author |
Message |
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
Quick WDT Question |
Posted: Mon Sep 26, 2005 9:16 am |
|
|
Compiler: 3.18
Part: 18F4620
Standard Run Mode
Target Voltage: 3.3V
Osc Speed: 20MHz
I'm using a keypad for the first time and I've started with Newguy's interrupt driven code from the code library. His code uses the WDT so by default now I'm using the WDT (for the first time.)
Here is a link to Newguy's code:
http://www.ccsinfo.com/forum/viewtopic.php?t=19726
The problem I've run into is, I rely on delays and they cause the WDT to reset. (I imagine the solution is to use timers and I'll work on that next, but I still have questions.)
Questions:
When I enable the WDT in the FUSES it appears that there is no way to turn it off. Even a SETUP_WDT(WDT_OFF) doesn't disable the WDT. What am I missing? (I was going to kludge the code initially by turning the WDT off prior to a delay, and then back on afterwords.)
(This one maybe for you Newguy.) What does the WDT do for you in the keypad routine?
In the mean time I'll try to move towards timer driven delays.....
Thanks for the help,
John |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Mon Sep 26, 2005 9:32 am |
|
|
Check if you are restarting because of wdt
look at the restart_cause() function.
fprintf(debug,"restart from %u",restart_cause())
and look up the code
also look at
#use delay (clock=32000, RESTART_WDT)
which restarts the wdt in when using delays. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Sep 26, 2005 9:33 am |
|
|
Take a look at this
Code: | #use delay(clock=speed, restart_wdt)
|
If you are using the delay_?s() statements, this will handle the wdt for you. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
Re: Quick WDT Question |
Posted: Mon Sep 26, 2005 9:48 am |
|
|
jecottrell wrote: |
Questions:
When I enable the WDT in the FUSES it appears that there is no way to turn it off. Even a SETUP_WDT(WDT_OFF) doesn't disable the WDT. What am I missing? (I was going to kludge the code initially by turning the WDT off prior to a delay, and then back on afterwords.)
John |
There are two ways of enabling the WDT. One is by the #fuse and the other is via software. The software mechanism can be turned on and off via SW control _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Mon Sep 26, 2005 10:16 am |
|
|
The only reason I use the watchdog is because I always use it. You don't have to - just turn it off by setting the appropriate fuse and remove any other references to it in the code.
I use it because I like the peace of mind it brings. I've written code that has never hung, but occasionally something like a power line surge will cause the pic to go off into la-la land. Then the watchdog does its duty and brings the pic back into flawless operation.
And if you keep it in, the previous suggestion regarding the addition of "restart_wdt" to the #use delay line will cure your troubles. |
|
|
|