main.c

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.

// Tested with 24LC256 Memory from Microchip and PIC16F877 running at 20MHz.

// No Liability Accepted.



#include "Eprom Functions.h"



// To write to memory:  ByteWrite( Chip ID, Upper Address Byte, Lower Address Byte, Data Byte);

// To read from memory: RetrieveData( Chip ID, Upper Address Byte, Lower Address Byte );



main()

{

    TRISB=0;				/* Port B all outputs - used to display data */



    ByteWrite( 0x50, 0, 1, 53 );		/* Writes 53 to the Address Location 1 */

    PORTB=RetrieveData( 0x50, 0 , 0 );	/* Reads back and presents it on PORTB */



    while(1);				/* Infinite Loop */

}




Copyright© 2002 Pavel Baranov.