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

PIC16F688 WDT !!!
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mindstorm88



Joined: 06 Dec 2006
Posts: 102
Location: Montreal , Canada

View user's profile Send private message

PIC16F688 WDT !!!
PostPosted: Wed May 16, 2007 5:34 am     Reply with quote

Any body has ever used the Watchdog WDT with this controller , it seems that simply using
Code:

setup_wdt(WDT_1152MS);
..
..
..
restart_wdt();


does not work for me !!!! using ver 4.023
dyeatman



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

View user's profile Send private message

PostPosted: Wed May 16, 2007 6:12 am     Reply with quote

When you say it "doesn't work for you" what does that mean more specifically?
mindstorm88



Joined: 06 Dec 2006
Posts: 102
Location: Montreal , Canada

View user's profile Send private message

PostPosted: Wed May 16, 2007 6:41 am     Reply with quote

does not seem to configure it properly !!!
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed May 16, 2007 7:41 am     Reply with quote

Do you mean that it does not compile or that the PIC's WDT is not functioning properly? Make sure you have your #FUSES set to WDT and not NOWDT.

Ronald
mindstorm88



Joined: 06 Dec 2006
Posts: 102
Location: Montreal , Canada

View user's profile Send private message

PostPosted: Wed May 16, 2007 9:32 am     Reply with quote

the wdt is working , but not properly using these command !!!

Right now it is working ok , but i had to setup manually the WDTCON register this way :
Code:

#fuses INTRC_IO,WDT,PUT,NOPROTECT,BROWNOUT,NOMCLR
..
..

#byte WDTCON= 0x18
..
..
WDTCON = 0x0E;
..
..
restart_wdt();
Jim Hearne



Joined: 22 Dec 2003
Posts: 109
Location: West Sussex, UK

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

PostPosted: Wed May 16, 2007 9:41 am     Reply with quote

Thanks for that post, i've got code running on the 16F688 with the WDT fuse set.
But the code was migrated from a 16F88 and i'd not noticed the F688 had an enhanced wdt till you mentioned it.

The code currently just has the WDT fuse set but no setup_wdt() function.
I wonder what timeout the compiler defaults to.

Jim
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed May 16, 2007 3:32 pm     Reply with quote

The spec. sheet states what the WDTCON register defaults to under the different reset states. If you don't insert a setup_WDT() command then it should default to one of those states.

Ronald
mindstorm88



Joined: 06 Dec 2006
Posts: 102
Location: Montreal , Canada

View user's profile Send private message

PostPosted: Thu May 17, 2007 4:08 am     Reply with quote

Yes WDTCON has a reset value , but if you set a timer
Code:

setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);

as in my application the WDTCON get reset to all 0 even if it has nothing to do with RTCC , WDTCON is a prescaler dedicated to WDT only !!! So i have to set that register just after !!
Code:

setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
WDTCON = 0x0E;   
Ttelmah
Guest







PostPosted: Thu May 17, 2007 4:41 am     Reply with quote

Read about 'setup_counters'. Unfortunately, this is appallingly documented, but the syntax you need to use, is:

setup_counters(RTCC_INTERNAL|RTCC_DIV_256,WDT_1152MS);

The 'setup_timer_0' function, is an alias for 'setup_counters', and this function, updates both the RTCC values, and the WDT values,from the _second_ value. Using it with just one value, results in zero being put into the WDT register. It is 'descibed' in the .h file for the processor, but the effects are not made very clear at all...

Best Wishes
mindstorm88



Joined: 06 Dec 2006
Posts: 102
Location: Montreal , Canada

View user's profile Send private message

PostPosted: Thu May 17, 2007 7:40 am     Reply with quote

Ttelmah ,
using the setup_counters you posted , it sets the RTCC prescaler to the WDT!!! in that controller the WDTCON is dedicated only to WDT but doesn't get set by the setup_counters !!! just tried in SIM!!
the goal is to set RTCC with its own prescaler and WDT with its !! up to now i succeeded with what i've posted earlier , But can't find any way with CCS function !!!
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Thu May 17, 2007 9:34 am     Reply with quote

Timer0 is shared with the WDT. You can only use it with ONE configuration. If you look at the spec. sheet you will notice that they are shared resources. If you have Timer0 setup as a timer/counter then you cannot use the WDT function. If you setup the WDT you cannot use Timer0 for any counting/timing. This is where you are running into confusion. If you want to use WDT then you will need to use a different timer/counter for whatever timing/counting function.

Ronald
Ttelmah
Guest







PostPosted: Thu May 17, 2007 9:53 am     Reply with quote

Not quite. Look at figure 5.1 on the data sheet. On this particular chip, you can select to feed the watchdog, from the timer0 prescaler, and the master clock, or from the internal 31KHz oscillator, and it's own prescaler. The connection combinations are limited by the PSA bit. If the prescaler you want, can't be provided by the internal 16bit prescaler from the 31KHz source, then PSA is set to '1', and the 8bit timer0 prescaler gets used as well.
The problem is selecting WDT_1152MS. This implies using the timer0 prescaler. To get 1152ms, you actually have to use the 18ms watchdog option, with the *64 watchdog divider (which then doesn't use the timer0 prescaler).

Best Wishes
mindstorm88



Joined: 06 Dec 2006
Posts: 102
Location: Montreal , Canada

View user's profile Send private message

PostPosted: Thu May 17, 2007 10:01 am     Reply with quote

You got it right Ttelmah using :
Code:

setup_counters(RTCC_INTERNAL|RTCC_DIV_256,WDT_18MS|WDT_TIMES_4096);

Does set both properly !!

Thanks
Ttelmah
Guest







PostPosted: Thu May 17, 2007 10:09 am     Reply with quote

As I said, the documentation on this is appalling!...
I knew it can set both values correctly (had managed it for one of my projects), but had forgotten that selecting anything other than the 18mSec option, used the timer0 prescaler...
Glad you got there. Smile

Best Wishes
evsource



Joined: 21 Nov 2006
Posts: 129

View user's profile Send private message

PostPosted: Wed Apr 30, 2008 11:04 pm     Reply with quote

It's a good thing I found this post in the forum - I was about to go crazy when the WDT and timer0 wouldn't work when I had them both in code. However, trying the suggestion here hasn't worked. For one thing, the 16F88 doesn't recognize the WDT_TIMS_4096...

mindstorm88 wrote:
You got it right Ttelmah using :
Code:

setup_counters(RTCC_INTERNAL|RTCC_DIV_256,WDT_18MS|WDT_TIMES_4096);

Does set both properly !!

Thanks


I tried this, and things still don't work right. I imagine you'll want to know what it did - I'm away from the hardware setup right now, but was hoping to get any insight as to why this line of code wouldn't work for me.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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