#include <xc.h>
#include <sys/attribs.h>

/* define a Timer 5 ISR function at IPL level 2 that uses a shadow register set */

void __ISR_AT_VECTOR (_TIMER_5_VECTOR, IPL2SRS) T5Interrupt(void)
{
    // Do some useful work

    // Reset interrupt flag
    IFS0bits.T5IF = 0;
}

/* Application begins here */
int main(void)
{
    // Initialize peripherals
    InitializeSystem();

    // Interrupt Controller
    PRISSbits.PRI2SS = 2;                /* assign shadow set #2 to priority level 2 ISRs */
    INCONSET = _INTCON_MVEC_MASK;    /* enable interrupt controller for multi-vector mode */
    __builtin_enable_interrupts();            /* atomic enable CP0 Status(IE) flag */

    while(1)
    {
        mainTasks();                /* main application loop */
    }
}