Josh, this has been an interesting topic. Looking back over the data book, it appears that you can wakeup from SLEEP by just setting the related enable Bit (EEIE in this case). If GIE is cleared, execution will continue right after the SLEEP and will not jump to the IRQ address. Since I normally use interrupts for other things I was not aware of this alternative. Note, you still need to clear the Flag Bit (EEIF) after you wakeup. So regarding my earlier remarks, "nevermind" ;-) - Tom At 11:56 AM 4/17/00 -0500, Josh Koffman wrote: >Tom Handley wrote: > >> Josh, the example code on page 43 works exactly as described but they >> don't provide the whole picture as far as the SLEEP Interrupt. If you do not >> want to use interrupts, you can simply replace SLEEP with a 10ms (or longer) >> delay. However, the most efficient and reliable method is the one they >> describe. Execution is resumed right after the SLEEP interrupt. >> >> You need to do the following: >> >> 1. Set INTCON Bit 6 to enable Peripheral Interrupts. >> 2. Set PIE2 Bit 4 (EEIE) to Enable "EEPROM Write Operation Interrupt". >> Note, this register is in bank 1 (RP1 = 0, RP0 = 1). >> >> In your Interrupt Handler, look for PIR2 Bit 4 (EEIF) which is the >> "Write Operation Interrupt" flag Bit. As with most interrupt flags, you >> need to clear the Bit. Note, PIR2 is in bank 0 (RP1 = 0, RP0 = 0). >> >> That's it. Works fine, everytime... >> >> - Tom > >Tom, >Thank you for the response. My original intention was to avoid using the >interrupt handler. I'm not using interrupts elsewhere in my application, and the >handler would have basically just cleared the interrupt flag, then RETFIE. I >thought this was somewhat of a waste. I got another response, and I'm pretty >sure what I can do is enable peripheral interrupts, enable the EEPROM interrupts >(EEIE), but leave GIE disabled. When I put the microcontroller to sleep, and the >write completes, the interrupt will wake the controller up, but not cause it to >vector to 0x04. Am I correct in saying this will happen? > >Thanks for all your help! > >Josh Koffman >joshy@mb.sympatico.ca ------------------------------------------------------------------------ Tom Handley New Age Communications Since '75 before "New Age" and no one around here is waiting for UFOs ;-)