Duplicate int handlers
Posted: Wed Jan 27, 2010 2:52 pm
Hi, me again....
If you use the Port B interrupt-on change in your program, and you enable that interrupt at two (or more) places, the compiler generates two interrupt handler subroutines. Since each int handler uses the same variables (here: char mxtmp), you get an error: 'variable already exists' and compile fails.
See attached fragment which results when both PortB int on change and TMR0 int are enabled in two places. The duplicate TMR0 does not cause an error as there is no duplicate symbol...
jan didden
Linear Audio
If you use the Port B interrupt-on change in your program, and you enable that interrupt at two (or more) places, the compiler generates two interrupt handler subroutines. Since each int handler uses the same variables (here: char mxtmp), you get an error: 'variable already exists' and compile fails.
See attached fragment which results when both PortB int on change and TMR0 int are enabled in two places. The duplicate TMR0 does not cause an error as there is no duplicate symbol...
Code: Select all
void interrupt(void)
{
//Handler code for [PORTB]
char mxtmp;
if ((intcon & (1 << RBIF)) && (intcon & (1 << RBIE)))
{
FCM_enc_int_service();
mxtmp=portb;
clear_bit(intcon, RBIF);
}
//Handler code for [TMR0]
if ((intcon & (1 << T0IF)) && (intcon & (1 << T0IE)))
{
FCM_clk_int_service();
clear_bit(intcon, T0IF);
}
//Handler code for [PORTB]
char mxtmp;
if ((intcon & (1 << RBIF)) && (intcon & (1 << RBIE)))
{
FCM_enc_int_service();
mxtmp=portb;
clear_bit(intcon, RBIF);
}
//Handler code for [TMR0]
if ((intcon & (1 << T0IF)) && (intcon & (1 << T0IE)))
{
FCM_clk_int_service();
clear_bit(intcon, T0IF);
}
}
Linear Audio