void interrupt ISR()
{
if(CCP1IF) // Capture Interrupt Flag
{
RD2 ^=1; // Toggling the bit
CCP1IF = 0;
}
}
// Main Function
void main(void)
{
unsigned char ch;
RD2 = 0; // As Output for checking the toggling
TRISD2=0;
TRISC2 = 1; // As CCP1 to capture the input
//RC2=1;
TMR1H = 19; // Timer value
TMR1L = 19;
T1CON = 0x31; // TMR1 ON
/* configure capture unit */
CCPR1H=0x00;
CCPR1L=0x00;
CCP1CON = 0x05; // Capture at Every rising edge
CCP1IE = 1; //Capture interrupt enable
CCP1IF = 0;
/* configure interrupts */
PEIE = 1;
PIR1 = 1;
INTCON=0xC0; // Interrupt enable
while(1)
{
}
}