// Capture/compare RPINR7bits.IC1R = 7; IC1CON1bits.ICTSEL = 7; // Fosc/2 IC1CON1bits.ICI = 0; // interrupt on every one IC1CON1bits.ICM = 2; // capture on falling edge IC1CON2bits.SYNCSEL = 20; // Sync on IC1 input IC1CON2bits.ICTRIG = 0; // Trigger ICx from source designated by SYNCSELx bits TRISBbits.TRISB7 = 1; // input
Read ICBUF for rising edge and ICBUF for falling edge, then subtract the two
AndersGYou mean to have it interrupt on both edges and do it in the ISR? In that case I do not even need the CCP, just a timer. I thought I could do more with the CCP in hardware.