Pic16f877a I2c Sample Code

In fact the fastest I2C mode, Ultra Fast, can reach only up to 5 MHz while some SPI busses can reach 50 MHz. List, I've finally got back around to a project which has been hanging around for a while using I2C. Your help is much appreciated,. For all of the different kinds of small OLED monochrome displays, you'll need to install the Arduino libraries. Interfacing DS1307(RTC) with PIC16F877A. PIC16F628 (Apr, I2C Philips PCF8533 RTC, RAM, I2C, Internal Clock. Interfacing an I2C LCD Display to PIC Example Code. This requires a clean organization of the code, with the device I2C bus example. The code that is written by the user to perform a specific task by the MCU is stored in the FPM (Flash Program Memory) of the MCU. C: Uses the PIC CCP module to measure a pulse width : EX_CENTER_ALIGNED_PWM. c Author: RSABear Date: 8 January 2008 Version: 1. I initially was using some MCP23106 code and MCP23017 chips and there is a subtle difference between the chips as they have different registers. write() i2c. It is a very simple and easy to understand project for the beginners and is commonly used in several electronic products. RMS Voltage calculation usin PIC16F877A with C-code OK, put an example code from my previous for loop one (or any) that describes your idea please. Well worth the price difference but initially I was at a loss to find drivers and example code to drive it. program pic16f877a for ds1307 The Synchronous Serial Port (SSP) module has five registers for I2C operation. Look at this code that will setup the internal clock in the template. In this example, two boards are programmed to communicate with one another in a Master Reader/Slave Sender configuration via the I2C synchronous serial protocol. This software example makes the EFM32 operate in both master and slave configuration. i am newbie to I2C in pic16f877a, i need to learn to programe for i2c in pic16f877a. This hookup guide will explore. It's maximum CPU speed is 20 MHz with an operating voltage range of 2 V - 5. You will need to import this into the IDE as usual. com, or CCS C. The I2C slave access rate can be reduced relative to the Sample Rate. It has an extended temperature range of -40°C to +125°C and is lead free. so some tell me exactly how to write for it and upload some sample programes for MPLAB. But since there is a great similarity among PICs example code from other PICs usually works. for sending and receiving characters. Read the I2C Protocol Guide for more information on I2C. The RGB LED is a common anode type, so to light an individual LED you need to make the appropriate port pin low. As many of you must be knowing that PIC16F887A is an 8 bit microcontroller chip that can execute programs just like a computer. 24C16 doesn’t use these pins for addressing chip. Read the I2C Protocol Guide for more information on I2C. A snippet of user logic code below demonstrates a simple technique for managing transactions with multiple reads and writes. So far the interface is working fine. pic16f877a x 1. I2C is a 2 line (plus common ground) communication method for one master device to control up to 112 slave devices. For a more comprehensive example of how to use this i2c code library, you can check “Interfacing of PIC16F877 with (i2c based) 24LC64 EEPROM” post. NodeMCU ESP8266 OLED Display Code Example January 9, 2019 ESP8266 ESP8266 , OLED Manoj R. The I2C slave access rate can be reduced relative to the Sample Rate. The NewPing library written by Tim Eckel can be used with many ultrasonic distance sensors. I2C_Initialize(): This routine initializes the i2c driver instance for: index, making it ready for clients to open and use it. Thakur This tutorial demonstrate how to use 0. The PIC16F877A is working at 0 and 5 Volt logic level whereas the serial port on PC communicates at logic level +/-15 Volts. PIC16F877A Introduction; PIC16F877A GPIO Tutorial Introduction PIC16F877A has 33-GPIO’s grouped into five ports namely PORTA to PORTE. 0 Issue Date: 2017-03-07 This application note provides an example of using the MPSSE feature of the FT232H device as an I2C Master with a Visual Basic. I 2 C or IIC or I2C stands for Inter-Integrated Circuit. RMS Voltage calculation usin PIC16F877A with C-code OK, put an example code from my previous for loop one (or any) that describes your idea please. PicBasic Pro Compiler Sample Code - i2c. This application note also intends to explain the functionality and working of I2C, as well as some sample code that explains how I2C is implemented. In some situations, it can be helpful to set up two (or more!) Arduino and Genuino boards to share information with each other. The schematic of the clock is very simple. Example code HC-SR04 with Arduino and NewPing library. //Feel free to use this code. Simple real time clock and calendar using DS3231 and PIC16F877A CCS C code: The following C code was tested with CCS PIC C compiler version 5. In this example the PIC16F877A runs with 8MHz crystal oscillator. This example implementation counts the busy signal transitions in order to issue commands to the I2C master at the proper time. Library example: LiquidCrystal_I2C : SerialDisplay. To download code and Proteus simulation click here. Hi Has anyone an example of actual working 'C' code to write to the I2C port on the Raspi. For different EEPROM capacities, you may need to connect A0, A1, and A2 pins to GND or pull high to set device address. Sample projects for the Microchip PIC micro series of microcontrollers, including the PIC12x, PIC16x, PIC18x, PIC24x, and dsPICx microcontrollers. Search the code for “LCD” and “i2c” to find all relevant portions. I2C access examples I2C device register access examples (using PCA9532 and ISL29003) Next code is a sample to write 4 bytes data using AI bit on the PCA9532. The resolution of the PIC16F877A ADC is 10-bit, which means the analog value after conversion is stored as a 10-bit number that varies from 0 to 1023 (0x3FF). PIC 16F877 HiTech C Code Example. A I2C Scanner for Arduino. zip > i2c_master. These examples were the first published for the LAB-X1. I2C or inter-integrated circuit is a widely used serial communication protocol in the electronics world. Now let's do some examples: Examples Master write example. 92 compiler which changes labels and code one types into machine code (a HEX file) programmed into the PIC. Instructions and Code How to read Keypad with Arduino and I2C. You will need an updated I2C LCD library, the original one I couldn’t get to work but this one does seem to work – LiquidCrystal_I2C-master. It is provided for general information only and should not be relied upon as complete or accurate. If you are new to PIC/LCD interface please see MikroC "Hello World!" LCD example. The MCP23017 can be configured to operate in 8-bit or 16-bit modes. The PIC16F877A was very popular in its day, but has now been replaced by the PIC16F887. Code to use I2C hardware on a PIC16F877A. PIC16F628 (Apr, I2C Philips PCF8533 RTC, RAM, I2C, Internal Clock. 24C16 doesn't use these pins for addressing chip. So, make sure that your SSD1306 OLED display is configured to work in I2C mode, some displays need jumper placing or some soldering. I initially was using some MCP23106 code and MCP23017 chips and there is a subtle difference between the chips as they have different registers. No I2C interface with that sensor? No problem. I2c is nice because it only uses two pins, and you can put multiple i2c devices on the same two pins. For all of the different kinds of small OLED monochrome displays, you'll need to install the Arduino libraries. So each digit represents a pin on the port, and we can use the individual digits to specifically refer to any one of the pins in port B. A snippet of user logic code below demonstrates a simple technique for managing transactions with multiple reads and writes. As you can see, though, binary codes are very hard for human beings to read or write because they’re completely arbitrary; they look like gibberish. 0 Issue Date: 2017-03-07 This application note provides an example of using the MPSSE feature of the FT232H device as an I2C Master with a Visual Basic. How to Interface I2C-EEPROM with PIC16F PIC Development Board Microcontroller BoardsRead, write and Erase EEPROM by using I2C in PIC16F/18F Primer Board. The Inter–Integrated Circuit (I2C) bus is a common and convenient technique to interface devices to embedded. It is quite easy to write one yourself. c, change:1998-02-08,size:5588b. Hi, Very nice design! Please give me a description of your software development setup, so I will try to get the same tools as you. MPLAB XC8 for Beginners Tutorial -37- I2C Communication, part 2: Config with MPLAB Code Configurator Config with MPLAB Code Configurator I2C driver for PIC16F877A with Proteus simulation. This means that the CPU is running during the execution of the interrupt service routines. NET project. The code we have is for any kind of Arduino, if you're using a different microcontroller, the code is pretty simple to adapt, the interface we use is basic bit-twiddling SPI or I2C. i am looking at i2c. AN10369 UART/SPI/I2C code examples Rev. h" #include "i2c. The aspect of the project I am having trouble with happens to. These are temporary cookes which should only be held in the memory of your browser and be deleted when you shutdown the browser or reboot your computer. Send three byte values to a device at address 33. SPI Communication with PIC Microcontroller, MPLAB XC8 library. How to Interface I2C-EEPROM with PIC16F PIC Development Board Microcontroller BoardsRead, write and Erase EEPROM by using I2C in PIC16F/18F Primer Board. Author Frank de Brabander. http://microcontrollerslab. //Feel free to use this code. So the '1' at the end of our code statement refers to the first pin in port B, which in this case is pin 0. PIC16F877A Interrupt Code During my attempt to program my tachometer, I decided to make things simpler by creating code for an external interrupt, timer 0 interrupt (TMR0), and timer 1 (TMR1) interrupt. So if you use MCP23016 code on MCP23017 chips and try to output some bits, the logic Low's are correct, and the logic High's come out as HiZ. CCS provides a complete, integrated tool suite for developing and debugging embedded applications running on Microchip PIC MCUs and dsPIC DSCs. upload the code. There are three types of memories in a PIC Microcontroller, The Flash Program Memory, The Data Memory (RAM) and The EEPROM Data Memory. Now my example below required the I2C address to be changed to 0x3F, a lot of the example I have looked at are 0x27. Most of these port pins are multiplexed for handling alternate function for peripheral features on the devices. The I2C slave access rate can be reduced relative to the Sample Rate. Using Feature Set of I2C Master on TM4C129x Microcontrollers AmitAshara ABSTRACT The inter-integrated circuit (I2C) is a multi-master, multi-slave, single-ended bus that is typically used for attaching lower speed peripheral ICs to processors and microcontrollers. watch this video and subscribe for more videos. This rate is only achievable if an oscillator. BANKSEL OSCCON ; Switch to Bank 1. I am using this I2C scanner code on. If a different speed clock is used then a different I2C speed will be seen. The type of slave devices range. Now let's do some examples: Examples Master write example. RTC-DS1307 from Dallas Semiconductors. So for example, you could have up to 8 LCD backpacks+LCDs all on two pins! The bad news is that you have to use the. It is a very simple and easy to understand project for the beginners and is commonly used in several electronic products. Here is the description of some few functions. Now a days new microcontrollers have inbuilt I²C Registers. PIC16F628 (Apr, I2C Philips PCF8533 RTC, RAM, I2C, Internal Clock. Arduino IDE in the Cloud. Look at this code that will setup the internal clock in the template. CCS PCM Compiler Sample Code. The I2C interface promised a much cleaner interface than the standard one. PIC16F877A Interrupt Code During my attempt to program my tachometer, I decided to make things simpler by creating code for an external interrupt, timer 0 interrupt (TMR0), and timer 1 (TMR1) interrupt. Now my example below required the I2C address to be changed to 0x3F, a lot of the example I have looked at are 0x27. For example, instead of OpenI2C(), they have OpenI2C1() and openI2C2(). write() i2c. The theory section will describe the Start/Stop sequence as well as the Data/Address send and receive functionality. You can leave your comments and suggestions in the comment section below. So we need a logic level converter and that is MAX232 here. Libraries available:. The 32, big-endian, and integer chosen for the format. When a slave's SS pin is pulled low, this means the master is "talking" to him. Until now, I use 8051 with Keil compiler, and I want to use PIC’s as I2C slaves. c Author: RSABear Date: 8 January 2008 Version: 1. I set up pins P28 and P27 for SDA and SCL. [PIC] I2C on PIC16F877 with ASM. Difference between I2C and SPI Communication. DS1307 + PIC16F877A Gerçek zamanlı saat //Sample code for For example if you are wanting to power one of our_blank">red LEDs in an automotive application. So if you use MCP23016 code on MCP23017 chips and try to output some bits, the logic Low's are correct, and the logic High's come out as HiZ. Here, we use three DHT22 sensors on a single I2C interface. For that I took Microchip’s 24LC64, which is a 64 Kbit Electrically Erasable PROM also called I2C. I am using this I2C scanner code on. but th datasheet of it is really confusing. c, change:1998-02-08,size:5588b. Interfacing an I2C LCD Display to PIC Example Code. c" /* ***** SourceBoost C Code Processor: PIC16F877A Filename: I2C_Slave_1. You will need to import this into the IDE as usual. Interfacing DS1307(RTC) with PIC16F877A. Then the slave receives the specified number of bytes in a buffer and sends them back to the master. 24C16 doesn’t use these pins for addressing chip. Multi-master mode is not supported. No I2C interface with that sensor? No problem. The trickiest part is determining the address of the module. In this guide we will going to find and detect i2c address on our i2c device. Example User Logic to Control the I2C Master. #include CCS Sample code. I2C example code. It initializes the serial communication at 9600 baud. Project list | pic microcontroller, »circuit digital clock using pic16f628a microcontroller schematics » they act only ones – right then, when it´s really necessary » how to burn. for sending and receiving characters. The code example included is written for the EFM32_Gxxx_DK development kit, but is easily ported to. With this library and LCDI2C4Bit you can use one keypad and one lcd (and a lot more devices!. Though I am using I2C driver provided by ST microelectronics as a board support package, I have made three functions which are specific to I2C EEPROM Interfacing. Pic16f877A DataSheet. The MCP23017 can be configured to operate in 8-bit or 16-bit modes. I am using this I2C scanner code on. I2C Interfacing of the MSP430 to a 24xx Series EEPROM (slaa115) the Code Examples (I report only the first two): fet110_8574. c -o i2c_binary. Read about 'I2C communication between PIC16F877a and Raspberry pi 3' on element14. FM Radio Using TEA5767 and PIC16F877A Micro-controller. In this project the SSD1306 OLED is configured to work in I2C mode. The code examples linked in the table below are compatible with PSoC Creator 3. - Sun Jun 21, 2015 12:15 pm #21092 esp01 would be fantastic with a good i2c driver - so may chips out there for i2c! Some people have put up I2C examples in the past but none work for me on the latest IDE but I can run the scanner and see MCP23017 and PCF8574 addresses :-----// -----// i2c_scanner // // Version 1 // This program (or code that. To download code and Proteus simulation click here. You can find the MaxSonar code by Bruce Allen in the Arduino playground, along with some additional notes and functions. Example Master Code This example shows how to implement a software I2C master, including clock stretching. I 2 C uses two bidirectional open drain data lines, Serial Data (SDA) and Serial Clock (SCL) with pull up resistors as shown below. The hardware I2C module of the PIC16F877A is initialized and configured using the function below with a speed of 100KHz:. so some tell me exactly how to write for it and upload some sample programes for MPLAB. How to Interface I2C-EEPROM with PIC16F PIC Development Board Microcontroller BoardsRead, write and Erase EEPROM by using I2C in PIC16F/18F Primer Board. Examples Write a big endian number to a device. Please note that the schematic does not show power supply to the PIC16F877A and the DS1307, you have to connect them by youself. For example, using the CodeSourcery ARM toolchain: $ gcc CROSS-COMPILE=arm-none-linux-gnueabi ARCH=arm i2c_interface. The code uses the BoostC standard RS232 and I2C driver code. In this example the PIC16F877A runs with 8MHz crystal oscillator. There are also 8 digits in our line of code. Examples in different C-Languages. Interfacing DS1307(RTC) with PIC16F877A. As many of you must be knowing that PIC16F887A is an 8 bit microcontroller chip that can execute programs just like a computer. Until now, I use 8051 with Keil compiler, and I want to use PIC’s as I2C slaves. The following appnote explains how to interface with an I2C bus device; source code is for C166, but it is very easy to adapt it to 8051. For example is you are reading many Analog voltages then make sure PIC has enough ADC channels and supportive resolution. M) Useful FAQ posts on the Microchip forum. You can use a PCF8574 I2C chip to expand I/O ports so only two GPIO ports would be occupied. These are temporary cookes which should only be held in the memory of your browser and be deleted when you shutdown the browser or reboot your computer. C Applications in PIC Designs. I purchased the SunFounder IIC I2C TWI Serial 2004 20x4 LCD Module Shield for Arduino Uno Mega2560 earlier in 2017. I bought the following module. The hardware I2C module of the PIC16F877A is initialized and configured using the function below with a speed of 100KHz:. do we have any example code for I2C ? in C for the prop that is. In this project the SSD1306 OLED is configured to work in I2C mode. inc file defines names based on the register/bank labels. This is a computer translation of the original content. h" /* * I2C functions for HI-TECH PIC C. As you can see, the connection is simple - only SDA and SCL lines have to be connected. I need code examples using TWI between two AVR units (in a Master->Slave configuration) I have seen examples either with only a Master and an EEPROM or something else slave, but no examples of a full-blown communication channel between two AVRs. PIC Microcontrollers PIC16F877a Its code is extremely efficient, allowing the PIC to run and I2C™ (Master/Slave) • Universal Synchronous Asynchronous. Send three byte values to a device at address 33. The p12f683. \$\begingroup\$ @AdamHaun, your example code for a binary counter has a potential bug. http://microcontrollerslab. Serial Communication. For that I took Microchip’s 24LC64, which is a 64 Kbit Electrically Erasable PROM also called I2C. 16-bit I/O Port Expander MCP23017 (I2C) The MCP23017 is a 16-bit, general purpose parallel I/O port expander for I2C bus applications. 5 V in a 44-Pin TQFP package. Hi Has anyone an example of actual working 'C' code to write to the I2C port on the Raspi. Includes hardware schematics (by Bernard van der Nest ). In this I2C tutorial you will learn all about the 2 wire I2C serial protocol; How easy it is to use, how it works and when to use it. Though I am using I2C driver provided by ST microelectronics as a board support package, I have made three functions which are specific to I2C EEPROM Interfacing. Example User Logic to Control the I2C Master. com/i2c-communication-pic-microcontroller/ I2C communication using pic16f877a microcontroller How to send data from master to a sl. If a different speed clock is used then a different I2C speed will be seen. Includes hardware schematics (by Bernard van der Nest ). 0 Issue Date: 2017-03-07 This application note provides an example of using the MPSSE feature of the FT232H device as an I2C Master with a Visual Basic. Multi-master mode is not supported. LCD module is used to display the data. It's maximum CPU speed is 20 MHz with an operating voltage range of 2 V - 5. Again we are using the Ql 200 PIC development board. I think your problem is that you converted code from 8051. pic16f877a x 1. Learn and experiment yourself to see how to write a simple program using C language for the PIC16C84. Typical voltages used are +3. \$\begingroup\$ @AdamHaun, your example code for a binary counter has a potential bug. When you are using I2C inside audio applications i advise you to use assembly to get above the audio frequencies (C-code slows down). M) Useful FAQ posts on the Microchip forum. This code only works on Linux. Please note that the schematic does not show power supply to the PIC16F877A and the DS1307, you have to connect them by youself. Now my example below required the I2C address to be changed to 0x3F, a lot of the example I have looked at are 0x27. These routines are hardware independent and can be used with any MCU. In order to compile the code and create a binary that can be run on the embedded system, you will need a cross compiler (e. 96″ small I2C based Display with NodeMCU ESP8266 using only two IO lines. I2C_Initialize(): This routine initializes the i2c driver instance for: index, making it ready for clients to open and use it. zip > i2c_master. do we have any example code for I2C ? in C for the prop that is. You should go through some sample examples source. c -o i2c_binary. As an example, we are going to interface old good 24C16 I2C EEPROM chip to Atmega328P. PicBasic Pro code samples for use with the LAB-X1 Experimenter Board from MicroEngineering Labs. The I2C PIC Interface Tutorial Setup An Example I2C Memory Device: 24LC02B Purpose & Overview of this project This tutorial will cover the basics of the I²C communication protocol. GPIO & PWM & Servo Example Blink example I2C READING DS1321 REAL TIME CLOCK More examples from esp8266-projects. This code is meant for the PIC16f1459, but the concepts can be ported over into several other PIC variants. // For example on the Arduino. In this tutorial, we are discussing about I2C module in PIC18F4550, how it can be implemented using firmware. but th datasheet of it is really confusing. #include #include "delay. h" /* * I2C functions for HI-TECH PIC C. do we have any example code for I2C ? in C for the prop that is. The 16-bit I/O port functionally consists of two 8-bit ports (PORTA and PORTB). GitHub Gist: instantly share code, notes, and snippets. C# (CSharp) Windows. Okay, so you've set it all up and opened the connection. A sample circuit where more than one slave is connected with the master for SPI communication is shown in the circuit below. The source code:. I am trying to connect to a I2C slave with 0x48 address and read a register 0x10. Learn and experiment yourself to see how to write a simple program using C language for the PIC16C84. Jun 16, 2010. In this example, two boards are programmed to communicate with one another in a Master Reader/Slave Sender configuration via the I2C synchronous serial protocol. For all of the different kinds of small OLED monochrome displays, you'll need to install the Arduino libraries. A complete working example with 16F877A microcontroller. Examples Write a big endian number to a device. SPB is an abstraction for low-speed serial buses (for example, I 2 C and SPI) that allows peripheral drivers to be developed for cross-platform use without any knowledge of the underlying bus hardware or device connections. So for example, you could have up to 8 LCD backpacks+LCDs all on two pins! The bad news is that you have to use the. Unlike the 8051, when using the pic you have to change the data direction register in order to receive bytes. For example code, refer to post: Interfacing an I2C LCD Display to PIC Example Code. Components C Code. A complete working example with 16F877A microcontroller. Hi Has anyone an example of actual working 'C' code to write to the I2C port on the Raspi. So far the interface is working fine. 01 — 06 April 2005 Application note Document information Info Content Keywords UART, SPI, I2C Abstract Simple code examples are provided for UART0, SPI and I2C. STM32F0 I2C - Tutorial 7 with STM32CubeMX 13 May 2017 on stm32 i2c tutorial , stm32f0 i2c , stm32 i2c cubemx , stm32 i2c hal , stm32f0 tutorial Hi everyone, I’m back :) Another year has come with lots of opportunities and challenges presented to me as I now become a fresh PhD candidate at Nanyang Technological University (NTU) Singapore. Unlike UART, you can connect and communicate to multiple devices using the same I2C bus. The trickiest part is determining the address of the module. Sample projects for the Microchip PIC micro series of microcontrollers, including the PIC12x, PIC16x, PIC18x, PIC24x, and dsPICx microcontrollers. I 2 C uses two bidirectional open drain data lines, Serial Data (SDA) and Serial Clock (SCL) with pull up resistors as shown below. com, or CCS C. PicBasic Pro Compiler Sample Code - i2c. Wiring up an I2C based EEPROM to the I2C port is relatively simple. As you can see, the connection is simple – only SDA and SCL lines have to be connected. I2C is pronounced "I squared C" and stands for Inter-Integrated Circuit. Examples Write a big endian number to a device. Following code is written for Hi-Tech C compiler. M) Useful FAQ posts on the Microchip forum. Now lets move onto the code part. The I2C code I am using is adapted from the I2C Explorer project on 43oh forum. It is a very popular multi-master, multi-slave serial communication interface developed by Philips. It is suitable for controlling all of our I2C based robot modules. I need code examples using TWI between two AVR units (in a Master->Slave configuration) I have seen examples either with only a Master and an EEPROM or something else slave, but no examples of a full-blown communication channel between two AVRs. This rate is only achievable if an oscillator. The schematic of the clock is very simple. I2C communication interfacing with PIC MICROCONTROLLER: Microcontrollers are known as standalone chips as they have internal memory and processor embedded. Let's see an example:. Send the value 2055 to the 7-bit I2C address as a 32-bit number. com Ring me +919597949799 for any queries, feel free to contact. 1 Initialization As shown in the previous example, configuring the device in master-transmit mode with DMA support requires that the function TI_USCI_I2C_DMA_transmitinit is called once before transmission begins. Been looking at the i2c examples, not a good enough pascal coder yet to figure out the layers. This is an example shows how to write texts on SSD1306 OLED display (128×64 pixel) using PIC16F877A microcontroller. So each digit represents a pin on the port, and we can use the individual digits to specifically refer to any one of the pins in port B. Code to use I2C hardware on a PIC16F877A. As an example, we are going to interface old good 24C16 I2C EEPROM chip to Atmega328P. It's maximum CPU speed is 20 MHz with an operating voltage range of 2 V - 5. The I2C code I am using is adapted from the I2C Explorer project on 43oh forum. It is provided for general information only and should not be relied upon as complete or accurate. com, or CCS C. Addressing. We also have the SPI version of this chip here MCP23S17. #include CCS Sample code. PCF8574 IO Expander Board - Tutorial/example requested. (Thanks to Dom for doing the difficult work of finding and testing the mapping. It is a very low power device with full BCD clock/calendar keep tracks of seconds, minutes, hours, date of month, month, day of month and year with leap year compensation which is valid upto year 2100. We use the serial communication to send data for each axis back to the computer. Now my example below required the I2C address to be changed to 0x3F, a lot of the example I have looked at are 0x27. For different EEPROM capacities, you may need to connect A0, A1, and A2 pins to GND or pull high to set device address. //Feel free to use this code. The PIC16F877A series of 8-bit Microcontroller has 7 K of Flash Program Memory with 33 I/O's. 83 compiler and simulation was made in Proteus v7. Send the value 2055 to the 7-bit I2C address as a 32-bit number. I initially was using some MCP23106 code and MCP23017 chips and there is a subtle difference between the chips as they have different registers. I 2 C uses two bidirectional open drain data lines, Serial Data (SDA) and Serial Clock (SCL) with pull up resistors as shown below. Includes hardware schematics (by Bernard van der Nest ).