I develop a C application with atmega168a-pu and interrupts. I use the following interrupts:
ISR(TIMER0_COMPA_vect);
ISR(TIMER0_COMPB_vect);
ISR (TIMER2_COMPA_vect);
ISR(SPI_STC_vect);
ISR(TIMER1_COMPA_vect);
ISR (PCINT1_vect);
and my code looks like
int main(void){
///initialization etc.
sei();
while(1){
///do some stuff and wait the interrupts
}
return 0;
}
I want to block all other interrupts when an interrupt occurs and enable the interrupts just before exiting the interrupt function.
Could you please explain it on a code snippet how I can do it?
EDIT: http://www.nongnu.org/avr-libc/user-manual/optimization.html#optim_code_reorder states that such usage cause reodering problem.
function(){
cli();
..
sei();
}