PIC16F-6-I2C-Slave-Initialization

by Marwen Maghrebi
void I2C_Slave_Init(unsigned char address) {
    SSPADD = address;  // Set the I2C slave address
    SSPSTAT = 0x80;  // Slew rate control disabled
    SSPCON = 0x36;  // Enable clock stretching and set slave mode
    SSPCON2 = 0x01;  // Enable general call
    TRISC3 = 1;  // Set SCL as input
    TRISC4 = 1;  // Set SDA as input
    GIE = 1;  // Enable global interrupts
    PEIE = 1;  // Enable peripheral interrupts
    SSPIF = 0;  // Clear SSP interrupt flag
    SSPIE = 1;  // Enable SSP (I2C) interrupt
}
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