#define _XTAL_FREQ 8000000 //The speed of your internal(or)external oscillator
#define USE_AND_MASKS
#include <xc.h>
#include "config.h"
#include <plib/timers.h>
int i = 0;
unsigned char Timer0Config;
void SetupClock(void);
void main(int argc, char** argv) {
SetupClock(); // Internal Clock to 8MHz
TRISBbits.RB4 = 0; //set RB4 as output
LATB4 = 1; //Make RB4 high when the program starts
Timer0Config = TIMER_INT_ON & T0_16BIT & T0_SOURCE_INT & T0_PS_1_256 ;
OpenTimer0(Timer0Config);
WriteTimer0(0xE17B); //Please use HEX. Decimal don't work
INTCONbits.TMR0IF = 0; //reset Interrupt Flag
ei(); // This is like fliping the master switch to enable interrupt
while(1) //infinite loop
{
}
}
void SetupClock()
{
OSCCONbits.IRCF0 = 1;
OSCCONbits.IRCF1 = 1;
OSCCONbits.IRCF2 = 1;
}
void interrupt TimerOverflow()
{
if(INTCONbits.TMR0IF == 1)
{
LATB4 = ~LATB4;
INTCONbits.TMR0IF = 0;
WriteTimer0(0xE17B); //Please use HEX. Decimal don't work
}
}