PIC16F-10-Capture-Mode-Interrupt&ServiceRoutine

by Marwen Maghrebi
// ISR Handler
void __interrupt() ISR() {
    if (CCP1IF) {
        // Capture event occurred, read CCPR1 value
        uint16_t capturedValue = CCPR1L | (CCPR1H << 8);
        
        if (capturedValue == 9) {
            // Toggle the LED (now on RC3)
            RC3 = ~RC3;
        }
        
        // Write CCPR1 value to PORTB
        PORTB = capturedValue;

        // Clear the Interrupt Flag Bit
        CCP1IF = 0;
    }
}
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
-
00:00
00:00
Update Required Flash plugin
-
00:00
00:00