AVR Interrupt, is the one of the important feature in microcontroller. Interrupts concepts , are perhaps one of the most important pieces that everyone need to understand for completing in every micro-controller projects
What is the interrupt in microcontroller ( interrupt definition)
Interrupt in microcontroller, if an event or process in microcontroller needs immediate attention, then a signal is generated by hardware or software this signal ( interrupt signal ) alerts the processor and serves as a request for the processor to interrupt the currently executing event/task and give immediate attention for a special task…
In I/O devices one of the bus control lines is dedicated for this purpose and is called the Interrupt Service Routine (ISR).
.in microcontrollers, Interrupt may be generated by a hardware device (hardware interrupt / external interrupt) or a software program ( software interrupt/internal interrupt). A hardware interrupt ( external interrupt ) in AVR microcontrollers is often created by an input device such as sensors
The term interrupt latency refers to the delay between the start of an Interrupt Request (IRQ) and the start of the respective. Interrupt Service Routine (ISR – ISR interrupt).
The sequence of events involved in handling an Interrupt Request in Avr microcontroller:
- hardware device/software program raises an Interrupt Request ( IRQ).
- The processor interrupts the program currently being executed.
- The device is informed that its request has been recognized and the device deactivates the request signal.
- The requested action is performed.
- An interrupt is enabled and the interrupted program is resumed.
AVR microcontroller Interrupt Sources
With AVR Microcontrollers, can configure AVR interrupts on various sources such as:
- Port Pins: INT0, INT1, and INT2
- Analog Comparator
- TWI or I2C
The vector table below shows the mapping of various AVR interrupts. Notice that the RESET AVR interrupt has an address of $000, the first address of the program memory indeed.
Interrupt vector table
AVR Interrupt vector table contains the memory addresses of the code for each type of hardware or software interrupt of interrupt . in Interrupt vector table ,“Vector” in this context means a direction or pointer to something.
Now you want to know if you configure various AVR interrupts and two or more interrupts happen at the same time, which device to be considered first? The answer is it depends on the interrupt priority. For AVR architecture it is simple. The lower the AVR interrupt vector address, the higher the priority. Have a look again RESET has the highest priority as might expect and other units later.
Handling Multiple Devices:
When more than one device raises an interrupt request signal, additional information is needed to decide which device to be considered first. The following methods are used to decide which device to select: Polling, Vectored Interrupts, and Interrupt Nesting. These are explained as follows below.
In polling, the first device encountered with an IRQ bit set is the device that is to be serviced first. Appropriate ISR is called to service the same. It is easy to implement but a lot of time is wasted by interrogating the IRQ bit of all devices.
In vectored interrupts, a device requesting an interrupt identifies itself directly by sending a special code to the processor over the bus. This enables the processor to identify the device that generated the interrupt. The special code can be the starting address of the ISR or where the ISR is located in memory and is called the interrupt vector.
In this method, I/O device is organized in a priority structure. Therefore, interrupt request from a higher priority device is recognized whereas a request from a lower priority device is not. To implement this each process/device (even the processor). The processor accepts interrupts only from devices/processes having priority more than it.