View previous topic :: View next topic |
Author |
Message |
vikraml
Joined: 24 Apr 2007 Posts: 7
|
PIC18F wdt timer problem |
Posted: Sun Jul 22, 2007 5:12 pm |
|
|
Hi all,
I have been playing around with the wdt on the PIC18F4580. The problem I have noticed is that when the fuses for the wdt timer is set and I try to disable the wdt timer using the function setup_wdt(wdt_off), it doesn't make any difference the watchdog timer still continues to reset the processor at the specified time-interval (in this case about 15 sec).
Below is my test code, could someone tell me what I am doing wrong. I basically want to control the start and stop of the watchdog timer within my code.
#include <18F4580.h>
#fuses XT,NOLVP,WDT4096,PUT,NOBROWNOUT
#use delay (clock=4000000)
#include <STDLIB.H>
void main(){
setup_wdt(wdt_off);
while(1){
sleep();
output_toggle(PIN_E0); //CPU HEARTBEAT
}
}
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jul 22, 2007 6:02 pm |
|
|
Post your compiler version. This is a 4-digit number, such as 3.249,
4.013, 4.045, etc. You can find it at the top of the .LST file, which is
in your project directory. Don't post any numbers that come after the
version number. |
|
|
vikraml
Joined: 24 Apr 2007 Posts: 7
|
PIC18F wdt timer |
Posted: Mon Jul 23, 2007 7:53 am |
|
|
The compiler version is 3.249.
Thanks |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Jul 23, 2007 8:17 am |
|
|
Quote: | 24.2.1 CONTROL REGISTER
Register 24-14 shows the WDTCON register. This is a
readable and writable register which contains a control
bit that allows software to override the WDT enable
configuration bit, but only if the configuration bit has
disabled the WDT. | You can only disable (and enable) the watchdog from software when the WDT fuse is set to off. |
|
|
vikraml
Joined: 24 Apr 2007 Posts: 7
|
|
Posted: Mon Jul 23, 2007 8:25 am |
|
|
ckielstra, thanks for your reply. If that's the case then my next question would be how do I set the timeout for the watchdog timer. The only way I can set the time is thru the fuses (eg. WDT256,WDT512, etc ) since this is a PIC18 or PCH part.
Thanks |
|
|
Ttelmah Guest
|
|
Posted: Mon Jul 23, 2007 8:53 am |
|
|
vikraml wrote: | ckielstra, thanks for your reply. If that's the case then my next question would be how do I set the timeout for the watchdog timer. The only way I can set the time is thru the fuses (eg. WDT256,WDT512, etc ) since this is a PIC18 or PCH part.
Thanks |
The enable, is separate from the prescaler.
Just use:
#fuses WDT4096,NOWDT
Which leaves the watchdog _disabled_, allowing software control, but sets up the prescaler.
Best Wishes |
|
|
|