/*
* File: main.c
* Author: Paul
*
* Created on May 16, 2016, 11:22 AM
*/
#include "header2.h"
#include <xc.h>
#define _ISRFAST __attribute__((interrupt, shadow))
void _ISRFAST _T1Interrupt(void);
int counter;
int main()
{
TRISBbits.TRISB0 = 0;
T1CONbits.TCKPS = 0x03; // prescaler is divide by 256
T1CONbits.TCS = 0; // timer clock source is from TOSC
IEC0bits.T1IE = 1; // enable timer1 interrupt
// enable pher inter
IPC0bits.T1IP2 = 1; // tmr1 inter priority = 0
IPC0bits.T1IP1 = 0;
IPC0bits.T1IP0 = 1;
IFS0bits.T1IF = 0;
T1CONbits.TON = 1; // start the timer!
TRISBbits.TRISB0 = 0; // b0 as output(led's here)
while(1){}
}
void _ISRFAST _T1Interrupt(void)
{
if(IEC0bits.T1IE && IFS0bits.T1IF)
{
counter++; //Increment Over Flow Counter
if(counter==30)
{
LATBbits.LATB0 = ~LATBbits.LATB0; // togle bit
counter=0; //Reset Counter
}
IFS0bits.T1IF = 0; // clear flag
}
}