can any one please tell me the difference between polling and interrupt mechanism in any 16 bit microcontroller.currently i am using MC9S12XDp512 .how the polling mechanism is handled and how is it different from interrupt handling.while hadnling data transfer how polling mechanism is handled and how is it different from interrupt handling.in polling mechanism how an array of 8 elements tranferred and in interrupt mechansim how they are transferred and reception side how they are recieved just tell me the procedure of handling of both mechanisms .what i am thinking is if i tranfer data from one microcontroller to other microcontroller through polling mechnaism only one element is recieved at a time and in interrupt mechanism all 8 elements are recieved when interrupt comes is it true please ealborate and tell me
From what Alban said, notice that polling tends to lead to a longer delay before reacting, but there's a more important difference which can affect other things.
On your open-book test, put this:
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).
P.S. I almost forgot to say the other things that become important :-/ When I started using interrupts, it was horrible because
Interrupts increase risk by being non-synchronous with the rest of the program. Developers can go quite out of their way to protect from this, but it adds more code, ram usage, and time to execute. Too bad because they were just trying to speed it up in the first place.
It gets harder to debug with interrupts. You could be tracing one line at a time in the C source code, but not have a clue how many ISR were called inbetween each step.
I didn't really need it, since it was plenty responsive with polling. Sometimes I benefit by polling in two different parts of the main loop, and that introduces almost no added risk compared to interrupts.
When you do a polling, it means you are regularly checking that a bit is set or not. This takes time and you can do a lot of things before checking again and see that the bit actually changed.
When working on interruption, the program continues running and do anything it wants and when the event occurs, your software is stopped and execute the interrupt to deal with the event. It means you react immediately to the event and that you don't need to check if the bit is set or not.
With interrupt, you have a better reaction time as the event triggers the interrupt. With polling, you are talking CPU load to do a check that are usually not met, until the check works.
It a bit like if a phone with a ring and a phone without a ring: Polling means that you pick up the phone regularly to see if someone is on the other end. Interrupt means you can do what you want and the phone will ring to interrupt you when someone arrives on the other end.