//#include <16F628.h>
#include <16F648A.h>
#use delay(clock=4000000)
#fuses XT,PUT,BROWNOUT,MCLR,NOWDT,NOPROTECT,NOLVP
#define TxD PIN_A0
#define RxD PIN_A1
#use rs232(baud=9600, xmit=TxD,rcv=RxD)
int16 time;
#INT_CCP1
void compare_isr()
{
time = get_timer1(); // Get Timer1
printf("Compare set interrupt\r\n");
printf("Timer1: %lu us\r\n",time);
disable_interrupts(GLOBAL); // All interrupts OFF
disable_interrupts(INT_CCP1); // Disable interrupt CCP1
}
void main(void)
{
setup_ccp1(CCP_COMPARE_INT); // Interrupt on compare mode
setup_timer_1(T1_INTERNAL); // Set up timer to instruction clk
enable_interrupts(INT_CCP1); // Enable interrupt CCP1
enable_interrupts(GLOBAL); // All interrupts ON
set_timer1(0); // Set Timer1
CCP_1 = 500; // Set high time limit to 100 us
// limit is time/(clock/4)
// 500 = .0001*(20000000/4)
while(TRUE); //Loop here
}