View Single Post
  #8   Spotlight this post!  
Unread 04-02-2008, 22:10
Abrakadabra Abrakadabra is offline
Here We Go !!!
AKA: Scott Kukshtel, Mr. K
FRC #3467 (The Windham Windup!)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2002
Location: Windham, New Hampshire
Posts: 160
Abrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant future
Re: Programming the Infrared board

Sravan,

The reason that the CheckIR() function is written that way is that it is an Interrupt Service Routine (ISR) and needs to be as fast as possible. It is called every 30ms, and while it is running, no other interrupts can occur.

Using GetDigitalInput() is good to use in your code that runs in the normal service loop, if for no other reason than it aids in program readability.
However, all it really does is access the same rc_dig_inXX variables that Brad's (and Kevin's) code uses. The function call has the disadvantage of having to use additional clock cycles to put the parameter, the return value, and the return address on the call stack, something you don't want to do if you don't have to when time is of the essence.

The time critical nature of the routine is also why you especially don't want to call any other functions from within it to do your work. If you do, then the entire system will slow down waiting for your code to finish. Instead, you want to just get in, check the ports of interest, put the found information in a place that's easy to access later, and get out. That's also why Brad is using the bitwise operators to save his information, rather than the more normal arithmetic operators - bitwise operations are much quicker!

Karl200 & d235j,

You should only need to include ifi_aliases.h and ifi_defaults.h. They can be found in the IFI default code package. They will also pull in a few other header files from the mcc18/h directory, so it is important to include that directory in your compile line include path. This old thread may be of some interest:
http://www.chiefdelphi.com/forums/sh...ad.php?t=42407

Brad,

While I'm here - I got rid of the changed variable and modified the last two lines of the ISR to look like this:

Code:
irCommands |= (~previous) & current;
previous = irCommands;
Does that do what you originally intended?

Last edited by Abrakadabra : 04-02-2008 at 22:15.
Reply With Quote