Hayee
Member level 4
- Joined
- Mar 4, 2022
- Messages
- 69
- Helped
- 1
- Reputation
- 2
- Reaction score
- 3
- Trophy points
- 8
- Activity points
- 733
Hi
I am working on interrupts and without settings the priorities of interrupts the code is working fine. following is the code without defining priority of TIMER3 interrupt.
but when i assign low priority to the interrupt it does not works, I also defined the IP flag for Timer3
I am using MPLAB XC8 compiler version 6.15 and microcontroller is PIC18f46k22
Kindly guide me what is wrong or missing in the code
I am working on interrupts and without settings the priorities of interrupts the code is working fine. following is the code without defining priority of TIMER3 interrupt.
C:
void __interrupt() ISR(void){
//===Timer3 Interrupt Routine============================================//
/*
* Timer3 is used to create a 1 Sec delay.
* This 1 Sec delay can be used by different tasks.
*/
if(PIR2bits.TMR3IF){
_1sec++;
if(_1sec == 10)
{
RED_LED = !RED_LED; // Toggle LED after every sec
if(backlight_timeout) backlight_timeout--;
if(serial_timeout) serial_timeout--;
_1sec = 0;
}
PIR2bits.TMR3IF = 0;
TMR3H = 0x3C;
TMR3L = 0xB0;
}
}
but when i assign low priority to the interrupt it does not works, I also defined the IP flag for Timer3
code for low priorityIPR2bits.TMR3IP = 0; // Timer3 Interrupt: Low Priority
C:
void __interrupt(__low_priority) LowPriorityISR(void){
//===Timer3 Interrupt Routine============================================//
/*
* Timer3 is used to create a 1 Sec delay.
* This 1 Sec delay can be used by different tasks.
*/
if(PIE2bits.TMR3IE && PIR2bits.TMR3IF){
_1sec++;
if(_1sec == 10)
{
RED_LED = !RED_LED;
if(backlight_timeout) backlight_timeout--;
if(serial_timeout) serial_timeout--;
_1sec = 0;
}
PIR2bits.TMR3IF = 0;
TMR3H = 0x3C;
TMR3L = 0xB0;
}
}
I am using MPLAB XC8 compiler version 6.15 and microcontroller is PIC18f46k22
Kindly guide me what is wrong or missing in the code