View previous topic :: View next topic |
Author |
Message |
eric
Joined: 16 Sep 2003 Posts: 21
|
setting WDT off on 18F252 |
Posted: Thu Jan 08, 2004 7:21 pm |
|
|
I'm under the impression that I can turn off the WDT on 18F252 which would be handy while waiting for user input. Using the EX_WDT18.c example to test this however, does not seem to work for me. WDT still
going:
Just after setup_WDT(WDT_ON);
I inserted -> setup_WDT(WDT_OFF);
but it makes no difference - the WDT still times out in ~2 sec.
//EX_WDT18.C (slightly modified)
#include <18F252.h>
#fuses H4,WDT128,NOPROTECT,NOLVP //WDT128 ~ 2 sec
#use delay(clock=40000000) // 10MHz resonator
#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7)
main() {
switch ( restart_cause() )
{
case WDT_TIMEOUT:
{
printf("\r\n Restarted processor because of watchdog timeout!\r\n");
break;
}
case NORMAL_POWER_UP:
{
printf("\r\n Normal power up!\r\n");
break;
}
}
setup_wdt(WDT_ON); // enable WDT
setup_wdt(WDT_OFF); // THIS SHOULD DISABLE THE WDT ?!!
while(TRUE)
{
// do nothing
}
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 08, 2004 8:20 pm |
|
|
The data sheet says this:
"The Watchdog Timer is enabled/disabled by a device
configuration bit. If the WDT is enabled, software execution
may not disable this function. When the WDTEN
configuration bit is cleared, the SWDTEN bit enables/
disables the operation of the WDT".
So I think you need to change the #fuses statement to this:
#fuses H4, NOWDT, NOPROTECT, NOLVP |
|
|
Guest
|
|
Posted: Thu Jan 08, 2004 10:34 pm |
|
|
Thanks,
Yes I read that too. But some combination, should allow
sw to set up the wdt as WDT128 with the "SWDTEN" bit set so one can have sw control. Otherwise what's the point of the Setup_wdt(off) ?
The example does not say how this is done. I guess I could pre emptively do this but you would think that this should work without poking the chip |
|
|
Guest
|
|
Posted: Thu Jan 08, 2004 10:46 pm |
|
|
Ahh as you said!! "WDT128" AND "NOWDT" works
apperantly the two are not mutually exclusive....
I have to recheck this to see if I missed something
but looks good so far! |
|
|
|