Maker Pro
Maker Pro

Prioritary interrupts on PIC (XC8 compiler)

Hi.
I'm trying to run a µC (PIC18f26K22) with prioritary interrupts. It generally works fine but it's like when an high priority interrupt stops a low priority interrupt, the µC never returns to the low priority one.
My program is a little heavy (65ko), so I won't post it here, but is there anything I didn't understand well on using prioritary interrupts ?
I see in documentation :
5.2.2 : Fast Register Stack said:
If both low and high priority interrupts are enabled, the
stack registers cannot be used reliably to return from
low priority interrupts. If a high priority interrupt occurs
while servicing a low priority interrupt, the stack register
values stored by the low priority interrupt will be
overwritten. In these cases, users must save the key
registers by software during a low priority interrupt.

Do I have to save anything when entering in a low interrupt routine or is XC8 compiler handle the problem itself ?
Thanks for your answers.
 
Thanks. I see that I didn't understand well the way to code interrupts. For example, when I detect a button action, I launch a debounce timer as it
Code:
static void Debounce(void) {
    iCompteurTmr0 = -1;
    TMR0 = 0;                   // Init Timer0
    T0CONbits.TMR0ON = 1;       // Démarre Timer0
}
I found clearer in code to call Debouce() for each button, but they advice not using function calls inside the interrupt routines. Maybe using a macro would be more efficient.
I'll read all this and correct my code, it could be more optimized.
 
Last edited:
Top