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 support@ccsinfo.com

stoping 16F876 watchdog during sleep

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



Joined: 14 Sep 2004
Posts: 2
Location: London UK

View user's profile Send private message

stoping 16F876 watchdog during sleep
PostPosted: Wed Dec 15, 2004 5:41 am     Reply with quote

Hi,

I am trying to write some code that will put the PIC to sleep (>5 min) until an interrupt on RB0/INT, this works ok but when I enable the watchdog it keeps wakes up.

Can the watchdog timer be disabled during sleep or will I have to stop using it all together Question
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 15, 2004 1:46 pm     Reply with quote

Quote:
Can the watchdog timer be disabled during sleep or will I have to
stop using it all together.
You can't do this with the 16F876.
You will need to use another PIC, such as the 16F88 or the 18F452,
which have the ability to enable or disable the WDT under software
control, with a bit in the WDTCON register. See the data sheets
for details.

One other option is to simply put the PIC back to sleep again.

Read this post for some details on this topic:
http://www.ccsinfo.com/forum/viewtopic.php?t=20869
fa24



Joined: 14 Sep 2004
Posts: 2
Location: London UK

View user's profile Send private message

PostPosted: Wed Dec 15, 2004 2:00 pm     Reply with quote

Ok,
thanks

Tony
Ttelmah
Guest







Re: stoping 16F876 watchdog during sleep
PostPosted: Wed Dec 15, 2004 3:52 pm     Reply with quote

fa24 wrote:
Hi,

I am trying to write some code that will put the PIC to sleep (>5 min) until an interrupt on RB0/INT, this works ok but when I enable the watchdog it keeps wakes up.

Can the watchdog timer be disabled during sleep or will I have to stop using it all together Question

I'd suggest implementing a watchdog 'counter'.
On your wake up, have a 'nop' (remember the 'next' instruction, is 'pre-fetched' when you sleep), then test the interrupt flag. If this is set branch to the handler. If not, increment a counter, and if it has not reached a 'limit' value, loop and sleep again. If the limit value is reached, you can have a handler for the trigger not having appeared. This way the watchdog will recover from certain types of processor 'hang', that can still occur when asleep, and can be left enabled throughout the code.

Best Wishes
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