I2C Low Level.h

PIC16F877 sample code that demonstrates how to access an external I2C EEPROM chip connected to a PIC. PIC16F877 is running at 20MHz and 24LC256 with RC0 as a clock pin and RC1 as a data pin. This example does not use the I2C specific interrupt features of the PIC16F877 to enable it to be used on a wider variety of PIC's. Modular approach makes it easy to follow and adapt for other designs (by Jamie Balfour).






// External Eprom Access. Jamie Balfour. Dec 2002.

// No Liability Accepted.



/* I2C Constants */

#define WRITE 0

#define READ 1



/* Medium Level I2C Functions */

void SendStart( void );

unsigned char SendDeviceAddress( unsigned char , unsigned char );

unsigned char CheckForAck(void);

void SendData( unsigned char );

void Restart( void );

unsigned char GetData( void );

void SendStop( void );



/* Low Level I2C Functions */

void SDAw( unsigned char );

void SCLw( unsigned char );

unsigned char SDAr( void );




Copyright© 2002 Pavel Baranov.