View previous topic :: View next topic |
Author |
Message |
mindstorm88
Joined: 06 Dec 2006 Posts: 102 Location: Montreal , Canada
|
PIC16F688 WDT !!! |
Posted: Wed May 16, 2007 5:34 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Wed May 16, 2007 6:12 am |
|
|
When you say it "doesn't work for you" what does that mean more specifically? |
|
![](templates/subSilver/images/spacer.gif) |
mindstorm88
Joined: 06 Dec 2006 Posts: 102 Location: Montreal , Canada
|
|
Posted: Wed May 16, 2007 6:41 am |
|
|
does not seem to configure it properly !!! |
|
![](templates/subSilver/images/spacer.gif) |
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Wed May 16, 2007 7:41 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
mindstorm88
Joined: 06 Dec 2006 Posts: 102 Location: Montreal , Canada
|
|
Posted: Wed May 16, 2007 9:32 am |
|
|
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();
|
|
|
![](templates/subSilver/images/spacer.gif) |
Jim Hearne
Joined: 22 Dec 2003 Posts: 109 Location: West Sussex, UK
|
|
Posted: Wed May 16, 2007 9:41 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Wed May 16, 2007 3:32 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
mindstorm88
Joined: 06 Dec 2006 Posts: 102 Location: Montreal , Canada
|
|
Posted: Thu May 17, 2007 4:08 am |
|
|
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; |
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Thu May 17, 2007 4:41 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
mindstorm88
Joined: 06 Dec 2006 Posts: 102 Location: Montreal , Canada
|
|
Posted: Thu May 17, 2007 7:40 am |
|
|
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 !!! |
|
![](templates/subSilver/images/spacer.gif) |
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Thu May 17, 2007 9:34 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Thu May 17, 2007 9:53 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
mindstorm88
Joined: 06 Dec 2006 Posts: 102 Location: Montreal , Canada
|
|
Posted: Thu May 17, 2007 10:01 am |
|
|
You got it right Ttelmah using :
Code: |
setup_counters(RTCC_INTERNAL|RTCC_DIV_256,WDT_18MS|WDT_TIMES_4096);
|
Does set both properly !!
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Thu May 17, 2007 10:09 am |
|
|
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.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
evsource
Joined: 21 Nov 2006 Posts: 129
|
|
Posted: Wed Apr 30, 2008 11:04 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|