View Single Post
  #3   Spotlight this post!  
Unread 13-02-2005, 07:37
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: enable interrupt

Quote:
Originally Posted by AIBob
You need to call "Initialize_Interrupts();"..
...which is called in user_routines.c under function "void User_Initialization (void)" (at least in my teams code it works there)
He's refering to Kevin Watson's interrupt code which is avialable at http://www.kevin.org/frc.

If you want to just turn on the interrupts without having to go through that, then you'll have something like this in User_Initialization() (Or somewhere are there. You just have to do this before the interrupts are on)
I just copied this from the function in Watson's code which was referred to earlier, with one change (in bold) which actually enables the interrupt. Kevin's code just sets it up.
Code:
TRISBbits.TRISB2 = 1;	// make sure the RB2/INT2 pin is configured as an input [108]
INTCON3bits.INT2IP = 0;	// 0: interrupt 1 is low priority (leave at 0 for IFI controllers) [91]
			// 1: interrupt 1 is high priority
INTCON2bits.INTEDG2 = 0;// 0: trigger on the falling-edge [90]
			// 1: trigger on the rising-edge
INTCON3bits.INT2IF = 0;	// 0: external interrupt 1 hasn't happened (set to 0 before enabling the interrupt) [91]
			// 1: external interrupt 1 has happened
INTCON3bits.INT2IE = 1;	// 0: disable interrupt	1 [91]
			// 1: enable interrupt 1
That enables the interrupt on digital input 1. To learn how to do the rest, I'd look at Mr. Watson's code and read this white paper.
__________________


Last edited by Ryan M. : 13-02-2005 at 07:39.