View Single Post
  #7   Spotlight this post!  
Unread 11-01-2004, 22:38
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: When would I use an interrupt?

Quote:
Originally Posted by Apollo Clark
I'm a noob to C programming, and don't understand how interrupts work, so...

How is:

void Default_Routine(void)
{
if(bButtonA)
vButtonPressed();
....
};

different from calling an interrupt when ever bButtonA is pressed?

(i tried to post this message earlier, but it didn't seem to go though...)
First let me explain clearly what an interrupt is. Basically an interrupt is a peice of code that is automatically executed whenever a specific event occurs. When an interrupt occurs, your program will immediately stop executing whatever it was doing and jump to the interrupt handler. Once the interrupt handler has finished, the program jumps back to wherever it was before the interrupt occured. Our control system has many soureces of interrupts. The two most useful are explained below.:

Timers: These are special counters that operate in the background. They can be programmed to count up at a specified speed. They can be programmed to trigger an interrupt once they reach a specified number. This is extremely useful for keeping track of time or making somethign happen at a specific time. Thsi description really doesn't so timers justice. I recimmend you read the IFI whitepaper at: http://innovationfirst.com/FIRSTRobo...003-Nov-20.pdf

IO: pins: interrupts can be set up to execute each time the state of an IO pin changes. An example of this would be your button scenario above.

What you did above is called polling. This method of detecting whether something is happening has two disadvantages. The first is that you are wasting time actively checking to see if something happened or not. The second is that its not very good at detecting things immmediately or things that happen quickly.
__________________
1139 Alumni