On Thu, 8 Nov 2001 10:27:30 -0800 Andrew Warren writes: > questuk wrote: > > > I wish to put a PIC into sleep mode then have it wake up every 10 > > seconds to check a port for activity, I know how to get PIC into > > sleep mode. I believe you can wake it using the PIC's clock (I > have > > a 4Mhz xtal that runs the PIC) using TMR x and prescaler? > > Gary: > > As Byron pointed out, the oscillator stops when the PIC is in sleep > mode, so that won't work. > > If you don't need precise timing, just enable the watchdog timer, > assign the prescaler to it, and set the prescaler divide-by ratio to > max... You'll end up with a watchdog timer that expires in > approximately two and a half seconds. Every four sleep/wake-up > cycles, therefore, is approximately 10 seconds. > > If you need more precision, you can calibrate your code to the > watchdog timer dynamically... But it doesn't sound as though you > need > anything real precise. > > -Andy > AND, if you did need precise timing, some PICs (like the 16F870) let you hang a low frequency crystal on one of the timers. It keeps running when the PIC is asleep and wakes the PIC on timer interrupt (rollover to 0x00). I chose to still have the watchdog running, waking us up every 2.5 seconds, and having the crystal based timer wake us up every 16 seconds. The watchdog wakeup is very short (just check to see if the other timer has timed out), so power consumption is still low. I wanted to use the watchdog in case the whole thing crashed. One thing on using the timer... Make sure the timer is set to nonsynchronous. If set to synchronize with the PIC core, the synchronizer shuts down when the PIC goes to sleep and the timer will never time out. Only took me a couple days to figure that out... Harold FCC Rules Online at http://hallikainen.com/FccRules Lighting control for theatre and television at http://www.dovesystems.com ________________________________________________________________ GET INTERNET ACCESS FROM JUNO! Juno offers FREE or PREMIUM Internet access for less! Join Juno today! For your FREE software, visit: http://dl.www.juno.com/get/web/. -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics