#include <xc.h>
#pragma config FNOSC = FRCPLL
#pragma config PWMLOCK = OFF
#pragma config FWDTEN = OFF
#pragma config JTAGEN = OFF
#pragma config ICS = PGD3
void __attribute__((__interrupt__, __auto_psv__)) _T2Interrupt(void);
void __attribute__((__interrupt__, __auto_psv__)) _T2Interrupt(void) {
_T2IF = 0;
_LATB5 = 1 - _LATB5;
}
int main(void)
{
_PLLDIV = 256;
_PLLPOST = 1;
_PLLPRE = 2;
while(_LOCK == 0);
TRISBbits.TRISB5 = 0;
_LATB5 = 0;
/* -------------- TIMER2 -------------------------- */
T2CON = 0; // Clear Timer 2 configuration
T2CONbits.TCKPS = 3; // Set timer 2 prescaler (0=1:1, 1=1:8, 2=1:64, 3=1:256)
PR2 = 58594; // Set Timer 2 period (max value is 65535)
_T2IP = 3; // Set Timer 2 interrupt priority
_T2IF = 0; // Clear Timer 2 interrupt flag
_T2IE = 1; // Enable Timer 2 interrupt
T2CONbits.TON = 1; // Turn on Timer 2
while(1)
{
}
}