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

/* Config bits (not all shown) */

#pragma config FSRSSEL = PRIORITY_7     /* Assign the SRS to level 7 priority handlers */

void __ISR(_TIMER_2_VECTOR, IPL7SRS) T2Interrupt(void)
{
    // Toggle LED LD1
    LATGINV = _LATG_LATG6_MASK;

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

int main(void)
{
    // Initialization

    IPC2bits.T2IP = 7;                /* Set Timer 2 interrupt priority to 7 */

    while(1);                        /* main application loop */

}