enable interrupt

I am trying to use an encoder and want to use interrupts, but I cannot figure out how to enable them! :confused: How do you enable interrupts? I have it programmed, just not enabled! :o

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.

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.