Polling vs Interrupt and ISR – Microcontroller

Difference Between Polling and Interrupt is a topic of Interrupt operations on Second Year – Second Part of BE in Institute of Engineering (IOE) affiliated Engineering colleges under the course of Microprocessor. Complete syllabus of the subject can be accessed from HERE. Also, we have chapter wise PDF note of Microprocessor compiled by Er. Hari Prasad Aryal which can be accessed from this LINK.

The difference between polling and interrupt is whether software asks, or whether the hardware tells it. When polling, the software is asking at a certain point in the program, whether the event has occurred. It might look at the RDRF flag to see if a char has arrived yet on the serial port. In other words, imagine a schoolboy raising his hand every 5 minutes, and asking, is it time yet?

When the system is “interrupt driven”, it means the software under (normal conditions) never asks, just keeps doing something else as if it doesn’t care whether a char is received yet on the serial port. Meanwhile, hidden away is an ISR (Interrupt Service Routine). When the interrupt occurres, it means hardware has detected the char on the serial port. The CPU will then find where you hid that ISR, and change the program counter so it starts running that routine instead of whatever it was doing before. That’s why we call it an “interrupt”. The hardware literally interrupted the program to tell it that a char has arrived on the serial port. Imagine the schoolboy quietly doing his worksheet, when suddenly the teacher grabs him by the arm and drags him to the bus (so he doesn’t miss his ride home).

Source: https://community.freescale.com/thread/29262

The 8051 microcontroller can do only one task at a time. In polling, the microcontroller continously checks each port one by one according to the priority assigned to the ports, and if any device requires service, then it provides it. In interrupt, when the device requires service, it sends the request to micrcocontroller and the controller then provides service to it.

So essentially, the difference is that in polling, microcontroller has to check continously whether any device is asking for request, while in interrupt the device itself sends the request and the controller satisfies it. And because microcontroller is freed from the task of checking each port, it can do other work.
Source: http://www.discuss-book.com/reply/MjAx/Difference-between-polling-and-interrupt

Interrupt Service Routine (ISR)
An interrupt handler, also known as an interrupt service routine (ISR), is a callback subroutine in an operating system or device driver whose execution is triggered by the reception of an interrupt. Step in executing an Interrupt:
1) It finish the instruction it is executing and saves the address of the next instruction (PC) on the stack.
2) It also saves the current status of all the interrupt internally.
3) It Jumps to a fixed location in memory called the interrupt vector table that holds the address of the interrupt service routine.
4) The microcontroller gets the address of the ISR from the interrupt vector and jumps to it. It starts to execute the interrupt service subroutine until it reaches the last instruction of the subroutine.
5) Upon executing the RETI instruction ,the microcontroller returns to the Place where it was interrupt.
Source: http://www.careercup.com/question?id=7988664

Other links:

We're always listening.
Have something to say about this article? Find us on Facebook, Twitter or our LinkedIn.
Raju Dawadi
Raju Dawadi
Raju is currently actively involved in DevOps world and is focused on Container based architecture & CI/CD automation along with Linux administration. Want to discuss with him on any cool topics? Feel free to connect on twitter, linkedIn, facebook.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.