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

setting WDT off on 18F252

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



Joined: 16 Sep 2003
Posts: 21

View user's profile Send private message

setting WDT off on 18F252
PostPosted: Thu Jan 08, 2004 7:21 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 08, 2004 8:20 pm     Reply with quote

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








PostPosted: Thu Jan 08, 2004 10:34 pm     Reply with quote

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








PostPosted: Thu Jan 08, 2004 10:46 pm     Reply with quote

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