Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Interrupt priorities

Hayee

Member level 2
Joined
Mar 4, 2022
Messages
44
Helped
0
Reputation
0
Reaction score
1
Trophy points
8
Activity points
434
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.

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
IPR2bits.TMR3IP = 0; // Timer3 Interrupt: Low Priority
code for 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
 

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top