Connect with us

Prioritary interrupts on PIC (XC8 compiler)

Discussion in 'Microcontrollers, Programming and IoT' started by Anard, Mar 7, 2018.

  1. Anard

    Anard

    47
    1
    Feb 21, 2018
    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 :
    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.
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    9,369
    1,903
    Nov 17, 2011
    Does this help?
    On another site someone wrote that the XC8 compiler should manage the saving and restoring by itself.
     
  3. Anard

    Anard

    47
    1
    Feb 21, 2018
    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: Mar 8, 2018
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-