In this course, we will study what is interrupt and its types - hardware and software interrupt, types of software interrupts, and ISR. So let us start.
An interrupt is nothing but the signals generated by the external devices that interrupts the normal flow of the program. Interrupts are generally the requests from the external device to the microprocessor for performing some actions. In case when an interrupt occurs the microprocessor shifts and starts working on a temporary work on a different task, and then later return to its previous task. Interrupts can be internal or external. When the interrupt occurs, the program stops executing and the microcontroller begins to execute the ISR.
There are two basic types of interrupt. The hardware interrupt and the software interrupt.
If the signal for the processor is from the external device or hardware is called hardware interrupts. Example: if we will press a key from the keyboard to do some action. This will generate a signal which is given to the processor to do action, we call such interrupts as hardware interrupts. There are two types of hardware interrupt.
Software interrupts are the interrupts that can be inserted into a desired location in the program. Software interrupts can also be divided into two types. They are
The interrupt address is known to the processor in this kind of interrupt.
The interrupts address is unknown to the processor, so we need to send the interrupt address externally by the device to perform interrupts.
The source of the interrupt is in phase to the system clock is called an asynchronous interrupt. Interrupts are dependent on the system clock. Example: timer service that uses the system clock.
If the interrupts are independent or not in phase to the system clock is called an asynchronous interrupt.
It is a non-maskable interrupt. It has the highest priority among all interrupts. By default, the interrupt is enabled until it gets acknowledged. In case of failure, the interrupt executes as ISR and sends the data to backup memory.
It is a maskable interrupt. It has the second-highest priority among all interrupts. During the execution of this interrupt the processor saves the content of the PC register into the stack and branches to 003CH address.
It is a maskable interrupt. It has the third-highest priority among all interrupts. During the execution of this interrupt the processor saves the content of the PC register into the stack and branches to the 0034H address.
It is a maskable interrupt. During the execution of this interrupt, the processor saves the content of the PC register into the stack and branches to the 002CH address.
It is a maskable interrupt. It has the lowest priority among all interrupts. It can be disabled by resetting the microprocessor.
When the INTR signal goes high, the following events can occur −
ISR (interrupt service routine) which is also known as an interrupt handler. In case if there is an interrupt present then it will immediately trigger the interrupt handler, the handler will stop the instruction which is being processed and its configuration will be saved in a register and will load the program counter of the interrupt from a location which is given by the interrupt vector table.
After the processing of the interrupt by the processor, the interrupt handler will load the instruction and its configuration from the saved register, the process will start its processing where it’s left. This saving the old instruction processing configuration and loading the new interrupt configuration is also called context switching.
The main features of the ISR are