#include "xc.h"
int main(void) {
TRISB = 0x0000; // Bit B13 como salida.
T1CONbits.TON =0;
T1CONbits.TCS =0;
T1CONbits.TGATE =0;
T1CONbits.TCKPS =0b11; // Pre escaler 1:256
TMR1=0x00;
PR1=781; // Valor en el registro ( Retardo 20ms)
IPC0bits.T1IP =0x01;
IFS0bits.T1IF=0; // Borra el Flag de Interrup Timer1
IEC0bits.T1IE =1; // Habilita interrupcion Timer1
T1CONbits.TON =1; // Start Timer
while(1);
return 0;
}
void __attribute__((__interrupt__, __auto_psv__)) _T1Interrupt(void)
{
IFS0bits.T1IF = 0;
_LATB13 = ~_LATB13;
}