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 At 05:45 PM 4/16/00 -0500, Josh Koffman wrote: >Greetings, >I am going to be using the EEPROM on the 16F877 for the first time and >I'm somewhat confused by the data book about putting the microcontroller >to sleep during an EEPROM write cycle. Basically my question is, can I >put the microcontroller to sleep, and have the EEIE EEPROM Write >interrupt wake the microcontroller up, but not vector to 0x04? I just >want code execution to continue from the instruction after the sleep >command. The book seems somewhat confusing, but if I disable Global >Interrupts and enable the EEPROM Write Operation Interrupt > will this accomplish what I describe? Will I need to enable >Peripheral Interrupts ? >I am not using interrupts anywhere else in my program so I'd like to >stay away from them if possible. If there is no way to wake the >microcontroller without having it vector to 0x04, can I just have RETFIE >as the only instruction in my interrupt routine and have it accomplish >what I need? I know the book says something about all this, but it seems >so unclear. It is on page 134 - Section 12.13.2 Wake-up Using >Interrupts, of the PIC16F87X Data Book. >Any and all help is appreciated! Thank you in advance! > >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 ;-)