Several events can make the device wake up from the sleep mode:
1. Any device reset.
2. Watchdog Timer Wake-up (if WDT was enabled).
3. Any peripheral module which can set its interrupt flag while in sleep, such as:
- External INT pin
- Change on port pin
- Comparators
- A/D conversion
- Timer1
- LCD
- SSP
- Capture, etc.
The first event (device reset) will reset the device upon wake-up. However the latter two events will wake the device and then resume program execution. When the SLEEP instruction is being executed, the next instruction (PC + 1) is pre-fetched, so that on wake-up the processor could execute the next instruction after the SLEEP command. For the device to wake-up through an interrupt event, the corresponding interrupt enable bit must be set (enabled). Wake-up is regardless of the state of the GIE bit. If the GIE bit is clear (disabled), the device will just wake up from sleep and continues executing the program from the instruction right after the SLEEP command. If the GIE bit is set (enabled), the processor will execute the instruction after the SLEEP instruction and then branches to the interrupt address (0004h). Therefore, if an interrupt is to be used just to wake up the PIC microcontroller, the GIE bit must be cleared before the sleep instruction.