# SLEEP or busy-waiting. Which would service an interrupt faster?

I'm programming a PIC microcontroller to service two events via interrupts on a very time constrained environment.

PIC microcontrollers allow a SLEEP mode which wakes the PCU on any external interrupt (INTn) but has a wake delay depending on the selected oscillator mode.

I want to know which option would start servicing the interrupts faster. A main loop like this:

//CPU never goes to sleep, keeps executing a jump
void main(){
while(1){}
}


or a main loop like this:

//CPU goes to sleep (idle), waits for INTn interrupts.
void main(){
while(1){
asm SLEEP;
}
}


Waking from idle sleep seems to take 2 cycles according to the PIC18F4XK22 whereas a jump instruction (of an infinite while loop may take longer and may or may not be interruptible halfway into the execution of the jump.

• Also add that part about "Power consumption, not an issue". I predict that you will get nearly universal agreement to keep the thing awake. Put in 10 NOP instructions (or a hundred) if you want a 90 (or 99) percent chance of catching the interrupt without a JMP instruction annoying you. – User.1 Sep 3 '14 at 22:43