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