RE: C18 interrupt How To
there is an exampe of using interrupts in the c18 users guide. this is a segment of code i have. i am using both high and low priorities.
this code just shows the low priority.
#pragma code low_vector=0x18 //Low interrupt priority starts at 0x18
_asm GOTO low_isr _endasm
#pragma interrupt low_isr save=PROD //Context Save
void low_isr (void)
if(INTCONbits.TMR0IF) //Timer0 interrupt
INTCONbits.TMR0IF = 0; // reset overflow bit
do what u need to do.............. }
INTCONbits.GIE = 1; //enable interrupts
RCONbits.IPEN = 1; // turn priority levels on
INTCON2bits.TMR0IP = 0; //set timer0 to low priority
check the pic datasheet for what flags there are. IF are set when somethign overflows, i.e. timer, recieve, transmit, etc. IP are priority level (low and high, if you have both). hope this helps.