On May 11, 2005 11:32 am, peiserma@ridgid.com wrote: > I need a sanity check on WDT wake-up from sleep. I thought I > understand it, but MPSIM is giving different results. > > I'm working with a 12F675. I want it to power down via the sleep > instruction, but periodically wake up, perform some work, and then go > back to sleep. The exact timing between wake-ups is not critical. > > I interpret table 10-6 in conjunction with the STATUS register to say > if WDT occurs after the SLEEP instruction was issued, then both /TO > and /PD bits should be cleared (***). In the simulator, the /TO bit > is actually set after the WDT, not cleared as I interpreted from the > datasheet. TO should be "1" after power-up, CLRWDT or Sleep. TO is a poor indicator since you do not know if it was a sleep or reset that triggered it. Therefore leave TO out of your program. If you let your program run-away, then the WDT is going to reset your micro and PD would be 1. If your micro was powered-up, then PD is 1. If you performed a Sleep, then PD is 0. Since you are doing a sleep, then use PD to differentiate between a reset-power-up and a sleep-power-up. If your program is overly complicated, you may want to insert a pair of checksum bytes in RAM, let's say AAh:55h and if you didn't find those there, then you are fairly sure you are dealing with a power-up and not a WDT type of reset. If your program is fairly simple and rather impossible to get stuck in a forever-loop of any sort, then just testing PD should be adequate. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist