Watchdog timer to check inputs?

Thread Starter

skybox

Joined Mar 2, 2009
68
Hi guys,

I want to minimize power consumption on my pic (an 18 series). Can I use a watchdog timer to check for any changes on some of the inputs I am monitoring and go back to sleep?

I want to monitor a pin every 15 ms, check the state, if high, increment a counter than go back to sleep. Do this over and over.

Thanks! i will be using the C18 compiler.
 

RiJoRI

Joined Aug 15, 2007
536
Hi guys,

I want to minimize power consumption on my pic (an 18 series). Can I use a watchdog timer to check for any changes on some of the inputs I am monitoring and go back to sleep?

I want to monitor a pin every 15 ms, check the state, if high, increment a counter than go back to sleep. Do this over and over.

Thanks! i will be using the C18 compiler.
The WDog should reset the system. It's used for runaway code, which implies something has gone wrong, you don't know what it is, so, as we said in my childhood, "Do-Over!", so it will re-initialize the counter you are trying to use.

It would be better to use a timer and its interrupt to do what you want. (Also, it's "better form" to do it that way.)

--Rich
 

AlexR

Joined Jan 16, 2008
732
The WDog should reset the system. It's used for runaway code, which implies something has gone wrong, .............
--Rich
True, that is one use for the watchdog timer, however if you put the processor to sleep the watchdog timer can be used to wake it up after a predetermined period. In this case the program will simply resume from where it left off and no reset will be issued.
 

Thread Starter

skybox

Joined Mar 2, 2009
68
Thanks for the replies guys. From my reading and research, yes the watchdog timer can reset a PIC if it goes in an infinite loop depending on the WDT bit settings; however,it can also be used to wake up the processor after a pre-determined time like AlexR mentioned.

My first design was to use an external interrupt; however, it was determined that using a WD timer to wake up after every 20 ms, check any inputs for changes, if there are changes add to a counter, if counter goes over a specific value, do something would be the best way to go for power saving.

I'll give this technique a try and let everyone know how it goes. Thanks for all the replies!
 
Top