I have the following interrupt routine for Timer1
The ISR simply toggles a latch.
Notice the static int x = 0; line.
If I remove it the ISR no longer gets called. I can even move it outside the function and the ISR gets called. I just can't remove it.
In addition I have another variable declared globally.
char weekdays[7][4] = {"Sun", "Mon", "Tue", "Wed","Thr","Fri","Sat"};
that is also unused.
If I remove it the ISR no longer gets called. Very strange.
At first I though it was a bad chip. I had a 18F27J53 but I also have a 18F26J53 and it does the same thing.
It is almost like I need X amount of memory allocated for the ISR to work.
And I have a second issue with code not running in a release compile these chips but I will post in a separate thread.
Rich (BB code):
#pragma interruptlow InterruptServiceLow
void InterruptServiceLow(void)
{
static int x = 0;
// Check for Timer1 Overflow Interrupt
if (PIR1bits.TMR1IF)
{
LATBbits.LATB3 =~ LATBbits.LATB3;
TMR1H = 255; // preload for timer1 MSB register
TMR1L = 195; // preload for timer1 LSB register
PIR1bits.TMR1IF = 0; // clear flag
}
}
Notice the static int x = 0; line.
If I remove it the ISR no longer gets called. I can even move it outside the function and the ISR gets called. I just can't remove it.
In addition I have another variable declared globally.
char weekdays[7][4] = {"Sun", "Mon", "Tue", "Wed","Thr","Fri","Sat"};
that is also unused.
If I remove it the ISR no longer gets called. Very strange.
At first I though it was a bad chip. I had a 18F27J53 but I also have a 18F26J53 and it does the same thing.
It is almost like I need X amount of memory allocated for the ISR to work.
And I have a second issue with code not running in a release compile these chips but I will post in a separate thread.