Langue Rodriguez wrote: > As I understand (from F84 specs) if I send the PIC to sleep to > conserve power, I can wake it up with a change in state in PORT B > or pin RB0. Now I would like to know if the following code would > work w/o having to go into ASM. I'm using PBC and don't need to > know the time it takes between pwr-down and wake-up. > > pwr_dwn: > Input 0 > poke INTEDG 0 > poke GIE 0 > poke INTF 0 > poke INTE 1 > zzz: > sleep 540 'sleep for 9min > peek INTF I0 'read RB0 flag into I0 > if I0 = 0 then zzz 'if event hasn't happened go back to sleep > int_clr: > poke INTF 0 > poke INTE 0 Langue: The good news is that you've got all the bits set properly. The bad news -- this is a guess, since I've never used PBC, but it's an educated one -- is that the "sleep 540" command doesn't really put the PIC to sleep for 9 minutes. Instead (I'm guessing), it puts the PIC to sleep, then uses the Watchdog Timer to wake itself up at least every 2.5 seconds. At each wakeup, it decrements its 9-minute counter and goes back to sleep unless the counter has expired. This has serious negative implications for your battery life, since a) the Watchdog Timer is always active, and b) the PIC is fully awake for some fraction of the time that you're expecting it to be asleep. Your PBC code is almost identical to the assembly code that would perform the same function; if you used assembly, there'd be hardly any more effort involved AND you'd have much greater control over what the PIC actually does. -Andy P.S. Here's the assembly code: pwr_dwn: bsf status,1 ;Input 0 bsf trisb^0x80,0 ; bcf status,1 ; bcf INTEDG ;poke INTEDG 0 bcf GIE ;poke GIE 0 bcf INTF ;poke INTF 0 bsf INTE ;poke INTE 1 zzz: sleep ;SLEEP UNTIL INT. nop ;peek INTF I0 NOT NECESSARY nop ;if I0 = 0 then zzz NOT NECESSARY int_clr: bcf INTF ;poke INTF 0 bcf INTE ;poke INTE 0 === Andrew Warren - fastfwd@ix.netcom.com === Fast Forward Engineering - San Diego, California === http://www.geocities.com/SiliconValley/2499 -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu