|For compensation, in order to get a somehow decent precision |during sleep, the basic stamp and its clones, for example, utilize a |permanent recalibratation, by measuring a full WDT timeout period |(~2,8 s) against the clock, every ten minutes or so. It's a bit |complicated, and costs a few percent more power down current, |but I believe there is no other way to get what you want. How about something interesting like this? Start: ; Do whatever code you want to identify watchdog-based ; wakeups... if watchdog goto Bark. When you want your ; ten minutes to start, load the time registers with: ; Time2: 01000110 ; Time1: 01111100 ; Time0: 00100110 Bark: btfsc WasNap goto DoTiming bsf WasNap clrwdt sleep ; Assumes prescale still at 1:128 DoTiming: bcf WasNap clrwdt movlw 0 option ; Turn off watchdog prescalar WaitLoop: decf Time0,f movf Time1,w ; Make Time1.0 match Time0.7 btfsc Time0,7 xorlw 1 decf Time0,f andlw 1 btfss Z decf Time1,f decf Time0,f movf Time2,w ; Make Time2.0 match Time1.7 btfsc Time1,7 xorlw 1 decf Time0,f andlw 1 btfss Z decf Time2,f decf Time0,f btfss Time2,7 goto WaitLoop ; When we get here, our time is up! Note that the multi-byte decrement is handled in a rather unusual way. In particular, bit 7 of each stage is checked against bit 0 of the next stage; if different, the next stage is decremented. The decrement was done in this way because [A] it allows 4us resolution, and [B] more sig- nificantly, the count value will survive asynchronous watchdog events. Had a more traditional counter been used, a watchdog that occured between an underflow on one stage and the decrement of the next would have caused the loss of 256 or 65536 counts. Unacceptable. Otherwise, the operation of the code is remarkably simple. It spends 1/129 of the time executing code and the other 128/129 of the time napping. When it's awake, it just runs a timer loop which, if left uninterrupted, would time out in 1/129 of the desired time. In practice, the 1/129 fraction isn't quite perfect due to various factors, but tweaking the initial values of the time variables should allow your 10 minutes to be generated reasonably accur- ately. One caveat, though: you need to put 7 bits of the timer value into each of Time0..Time2, and set the MSB of each stage iff the LSB of the next higher stage is set. Cute, eh? Attachment converted: wonderland:WINMAIL.DAT (????/----) (0002055C)