External Interrupts in AVR Microcontroller
Microcontrollers can accept inputs from I/O ports, interrupts are used for accepting inputs generated by external events. Interrupt event directs the flow of program execution with a totally independent piece of code, known as "Interrupt Sub-Routine". There are many sources of interrupts that are available for a microcontroller. Most of them are generated by internal modules and are called as internal interrupts.
For running an interrupt subroutine following requirements are necessary:
Writing an Interrupt Subroutine in AVR Studio:
It is tricky to use an interrupt subroutine into a C code of a microcontroller. Therefore the AVR GCC developers use a few symbols to represent the interrupts and macros that minimized the code size in many programs.
The interrupt subroutine for External Interrupt 0 and External Interrupt 1 is given below:
Registers Associated with External Interrupts:
The table showing microcontroller unit control register is given below:
The table showing Interrupt Sense Control truth table is: