PIC16F-6-I2C-Interrupt-Service-Routine

by Marwen Maghrebi
void __interrupt() ISR(void) {
    if (SSPIF) {  // Check if I2C interrupt flag is set
        if (!D_nA && R_nW) {  // Check if it is an address match and read request
            volatile char dummy = SSPBUF;  // Clear the buffer
            SSPBUF = PORTB;  // Load the DIP switch state into the buffer
            CKP = 1;  // Release the clock
            while (BF);  // Wait until the buffer is clear
        }
        CKP = 1;  // Release the clock
        SSPIF = 0;  // Clear the interrupt flag
    }
}
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