/[avr-libc]/avr-libc/doc/api/interrupts.dox
ViewVC logotype

Diff of /avr-libc/doc/api/interrupts.dox

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by joerg_wunsch, Sat Sep 3 22:03:08 2005 UTC revision 1.7 by joerg_wunsch, Sun Sep 4 18:57:18 2005 UTC
# Line 23  Line 23 
23     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24     POSSIBILITY OF SUCH DAMAGE. */     POSSIBILITY OF SUCH DAMAGE. */
25    
26    /* $Id$ */
27    
28  /** \defgroup avr_interrupts <avr/interrupt.h> <avr/signal.h>: Interrupts and Signals  /** \defgroup avr_interrupts <avr/interrupt.h> <avr/signal.h>: Interrupts and Signals
29    
30  \note This discussion of interrupts and signals was taken from Rich Neswold's  \note This discussion of interrupts and signals was taken from Rich Neswold's
31  document. See \ref acks.  document. See \ref acks.
32    
33    <h3>Introduction to avr-libc's interrupt handling</h3>
34    
35  It's nearly impossible to find compilers that agree on how to handle interrupt  It's nearly impossible to find compilers that agree on how to handle interrupt
36  code. Since the C language tries to stay away from machine dependent details,  code. Since the C language tries to stay away from machine dependent details,
37  each compiler writer is forced to design their method of support.  each compiler writer is forced to design their method of support.
# Line 63  SIGNAL(SIG_ADC) Line 67  SIGNAL(SIG_ADC)
67  Refer to the chapter explaining \ref ass_isr "assembler programming" for an  Refer to the chapter explaining \ref ass_isr "assembler programming" for an
68  explanation about interrupt routines written solely in assembler language.  explanation about interrupt routines written solely in assembler language.
69    
70    <h3>Catch-all interrupt vector</h3>
71    
72  If an unexpected interrupt occurs (interrupt is enabled and no handler is  If an unexpected interrupt occurs (interrupt is enabled and no handler is
73  installed, which usually indicates a bug), then the default action is to reset  installed, which usually indicates a bug), then the default action is to reset
74  the device by jumping to the reset vector. You can override this by supplying  the device by jumping to the reset vector. You can override this by supplying
# Line 78  SIGNAL(__vector_default) Line 84  SIGNAL(__vector_default)
84  }  }
85  \endcode  \endcode
86    
87    <h3>Nested interrupts</h3>
88    
89    The AVR hardware clears the global interrupt flag in SREG before
90    entering an interrupt vector.  Thus, normally interrupts will remain
91    disabled inside the handler until the handler exits, where the RETI
92    instruction (that is emitted by the compiler as part of the normal
93    function epilogue for an interrupt handler) will eventually re-enable
94    further interrupts.  For that reason, interrupt handlers normally do
95    not nest.  For most interrupt handlers, this is the desired behaviour,
96    for some it is even required in order to prevent infinitely recursive
97    interrupts (like UART interrupts, or level-triggered external
98    interrupts).  In rare circumstances though it might be desired to
99    re-enable the global interrupt flag as early as possible in the
100    interrupt handler, in order to not defer any other interrupt more than
101    absolutely needed.  This could be done using an sei() instruction
102    right at the beginning of the interrupt handler, but this still leaves
103    few instructions inside the compiler-generated function prologue to
104    run with global interrupts disabled.  The compiler can be instructed
105    to insert an SEI instruction right at the beginning of an interrupt
106    handler by declaring the handler the following way:
107    
108    \anchor attr_interrupt
109    \code
110    void SIG_XXX(void) __attribute__((interrupt));
111    void SIG_XXX(void) {
112      ...
113    }
114    \endcode
115    
116    where \c SIG_XXX is the name of a valid interrupt vector for the MCU
117    type in question, as explained below.
118    
119    <h3>Chosing the vector: Signal names</h3>
120    
121  The interrupt is chosen by supplying one of the symbols in following table.  The interrupt is chosen by supplying one of the symbols in following table.
122  Note that every AVR device has a different interrupt vector table so some  Note that every AVR device has a different interrupt vector table so some
123  signals might not be available. Check the data sheet for the device you are  signals might not be available. Check the data sheet for the device you are

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26