Interrupt Tutorial

Introduction

What is mean by Interrupt?

Interrupt means stop the continuous progress of (an activity or process).

What is mean by interrupt in Microcontroller?

Same here also. It will stop the process which is running currently and then execute the process in ISR. So it is a signal which may be disturb or alter the sequence of execution of the processor. In other words, An interrupt is a signal to the processor emitted by hardware or software indicating an event that needs immediate attention.

What is ISR?

ISR means Interrupt Service Routine.  Whenever an interrupt occurs, the controller completes the execution of the current instruction and starts the execution of an Interrupt Service Routine (ISR) or Interrupt Handler.

What is Polling?

Polling method simply uses a code section which checks a particular flag or flags, to know the status of operations. Polling method is always part of the main code and not part of an ISR. The microcontroller keeps checking the status of other devices.

Polling is a simpler method to execute, and is recommended for the early stages of design where the working of a peripheral is to be verified. It does not involve any priority. Also the code segment will always execute within a fixed time and in a fixed sequence. It is easy to debug and has no effect on the execution of other sections of code. There are no big memory management issues. There are no issues with stack.

Interrupt vs Polling

Here is an analogy that differentiates an interrupt from polling −

InterruptPolling
An interrupt is like a shopkeeper. If one needs a service or product, he goes to him and apprises him of his needs. In case of interrupts, when the flags or signals are received, they notify the controller that they need to be serviced.The polling method is like a salesperson. The salesman goes from door to door while requesting to buy a product or service. Similarly, the controller keeps monitoring the flags or signals one by one for all devices and provides service to whichever component that needs its service.

Program Execution Without Interrupts

So it only executes main function and some functions which are called in main function.

interrupt-embetronicx2 Interrupt Tutorial

Program Execution With Interrupts

In this method it will executes main function. When interrupt signal comes, it will stop the main function execution and suddenly it will go to ISR function and executes that. After execution of ISR and again it will come to main function.

interrupt-embetronicx1 Interrupt Tutorial

Types of Interrupts

Although interrupts have highest priority than other signals, there are many type of interrupts but basic type of interrupts are,

  1. Hardware Interrupts
  2. Software Interrupts

Hardware Interrupts

If the interrupt is coming from hardware or external devices, it is called Hardware Interrupt. Example: from keyboard we will press the key to do some action this pressing of key in keyboard will generate a signal which is given to the processor to do action, such interrupts are called hardware interrupts.

Software Interrupts

The interrupts which are caused by the software instructions are called software instructions.

Interrupt Latency

When an interrupt occur, the service of the interrupt by executing the ISR may not start immediately by context switching. The time interval between the occurrence of interrupt and start of execution of the ISR is called interrupt latency.

Download our new Android app. You can learn all Embedded Tutorials from your Android Phone easily.

Click Here to Download App!