Thread: Quick question about a block of code

  1. #1
    Registered User
    Join Date
    May 2009
    Location
    Look in your attic, I am there...
    Posts
    92

    Quick question about a block of code

    I found this in a source file I was looking at for a navigation system for an RC plane. What is the "ISR(PCINT2_vect) {"? Is it a function?... and if so what is the significance of having just a single type in the parameters?

    Code:
    #if RADIO_TYPE == 0
    ISR(PCINT2_vect) {
    	int cnt = TCNT1;
    	
    	if(PIND & B00000100){ 		// ch 1 (pin 2) is high
    		ch1_read = 1;
    		timer1count = cnt;
    	}else if (ch1_read == 1){	// ch 1 (pin 2) is Low
    		ch1_read = 0;
    		if (cnt < timer1count)   // Timer1 reset during the read of this pulse
    		   timer1diff = (cnt + 40000 - timer1count);    // Timer1 TOP = 40000
    		else
    		  timer1diff = (cnt - timer1count);
    	}
    	
    	if(PIND & B00001000){ 		// ch 1 (pin 2) is high
    		ch2_read = 1;
    		timer2count = cnt;
    	}else if (ch2_read == 1){	// ch 1 (pin 2) is Low
    		ch2_read = 0;
    		if (cnt < timer2count)   // Timer1 reset during the read of this pulse
    		   timer2diff = (cnt + 40000 - timer2count);    // Timer1 TOP = 40000
    		else
    		  timer2diff = (cnt - timer2count);
    	}
    }
    ISR(PCINT0_vect)
    {	
    	int cnt = TCNT1;
    	if(PINB & B00100000){
    		timer3count = cnt;
    	}else{	
    		if (cnt < timer3count)   // Timer1 reset during the read of this pulse
    		   timer3diff = (cnt + 40000 - timer3count);    // Timer1 TOP = 40000
    		else
    		  timer3diff = (cnt - timer3count);
    	}
    }
    #endif

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    ISR presumably = Interrupt handler. Either you have a bespoke compiler that is tailored to whatever chip you're looking at that handles the low-level stuff, or someone's been doing some #define magic.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick Pointer Question
    By Toonzaka in forum C Programming
    Replies: 3
    Last Post: 02-19-2010, 11:58 AM
  2. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  3. Replies: 1
    Last Post: 01-23-2002, 03:34 AM
  4. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM