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.