I'm stumped. I'm using the PIC C compiler (CCS) I have a 16C63 which runs some initialise code and part of a while loop and then does a sleep. The chip is woken up by either a change in level on the RB0 or edge on RB6 or RB7. The code works perfectly on our emulator but when I burn windowed version it runs and goes to sleep and then when the wakeup signal is given there is a delay and then the code runs from the start again instead of carrying on in the loop. If i burn the EPROM and power up the code works perfectly the first time without doing the second run from start but when I turn the power off start again it does the second "reboot". The bare bones code is: #fuses WDT main(){ initialise(); while(1){ statements... restart_wdt(); sleep() #asm NOP #endasm //go back to sleep if just watchdog wakeup while (restart_cause() == WDT_FROM_SLEEP){ restart_wdt(); sleep(); #asm NOP #endasm } more statements } The NOPs are because the instruction after SLEEP is discarded. Can anybody spot any glaring mistakes? By putting in some printf statements I can see that the code runs to where it goes to sleep but when the RB0,6 or 7 is "stimulated" the uP runs from the start and the "more statements" code isn't executed. Paul Gaastra pgaastra@hort.cri.nz Technology Development Group, Hort Research Private Bag 3123 phone +64 7 8584745 Hamilton, NEW ZEALAND fax +64 7 8584705