This is a bizarre problem, something I have never come across before. I am trying to get Timers 0,1,3 all running and generating high-priority interrupts simultaneously. Timer0 works perfectly and generates an interrupt on rollover. Timers 1 and 3 do not. I used my debugger and stepped through the code line by line and I see everything working -> The timer is incrementing, then it gets to 65536 and rolls over to 0, and the TMR1IF flag gets set, BUT an interrupt is never called, and the timer just keeps counting up from 0 and the interrupt flag stays set. I have the interrupts configured correctly and the priority set as high. Here is the relevant setup:
After this I turn global interrupts ON, I turn the timers on and just wait for an interrupt in main(). Again, Timer0 works fine and generates interrupts, so I know the interrupts in general are working. They just do not work with Timer1 or Timer3. Is there something I have configured wrong or something I am overlooking?
The uC is a PIC18F4550 and here is the datasheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/39632e.pdf
Rich (BB code):
T0CON = 0b00001000; //Setup 16-bit timer0 to bypass prescaler (page 129 of datasheet)
T1CON = 0b00000000; //Setup 16-bit timer1 to bypass prescaler (page 133) of datasheet
T3CON = 0b00000000; //Setup 16-bit timer3 to bypass prescaler (page 141) of datasheet
//Enable timer overflow interrupts
INTCONbits.TMR0IF = 0; //Clear Timer0 interrupt flag
INTCONbits.TMR0IE = 1; //Enable Timer0 interrupts
INTCON2 = 0b00000100;
INTCON3 = 0b01001000;
PIR1bits.TMR1IF = 0; //Clear Timer1 interrupt flag
PIE1bits.TMR1IE = 1; //Enable Timer1 interrupts
IPR1bits.TMR1IP = 1; //Set Timer1 interrupt priority
PIR2bits.TMR3IF = 0; //Clear Timer3 interrupt flag
PIE2bits.TMR3IE = 1; //Enable Timer3 interrupts
IPR2bits.TMR3IP = 1; //Set Timer3 interrupt priority
The uC is a PIC18F4550 and here is the datasheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/39632e.pdf