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 support@ccsinfo.com

Quick WDT Question

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



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

Quick WDT Question
PostPosted: Mon Sep 26, 2005 9:16 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Mon Sep 26, 2005 9:32 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Mon Sep 26, 2005 9:33 am     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

Re: Quick WDT Question
PostPosted: Mon Sep 26, 2005 9:48 am     Reply with quote

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: 1903

View user's profile Send private message

PostPosted: Mon Sep 26, 2005 10:16 am     Reply with quote

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.
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