

I☬ protocol was invented by Philips semiconductors in the 1980s, to provide easy on-board communications between a CPU and various peripheral chips. We will use PIC16F877A and PIC18F4550 microcontroller for programming examples. In the end, I2C programming examples will be discussed in both compilers. Secondly, we will understand the control and configuration registers of PIC Microcontroller I2C module. At the start, we will see the introduction of I2C communication. We will see I2C code examples with two popular compilers such as MPLAB XC8 and MikroC Pro. More information about the I2C protocol can be found on Wikipedia.This tutorial is an in-depth guide on I2C Communication using PIC Microcontroller. I successfully used 400000 with an OLED display module to increase the rate at which images could be updated.įinally, for a list of I2C related articles click here. For this reason I would recommend using 100000 or 400000 as baudrate values. The BCM2835 ARM Peripherals specification (page 28) says that the Pi has a “fast-mode” (400Kb/s) driver. Step 3 – Rebootįinally, reboot the Pi for the new setting to take effect : sudo reboot I2C Baudrate Values Use CTRL-X, then Y, then RETURN to save the file and exit. This enables the bus and sets the baudrate at the same time with a comma separating both parameters. This should give you a line looking like : dtparam=i2c_arm=on,i2c_arm_baudrate=400000 Using the following command the config.txt file can be edited : sudo nano /boot/config.txtįind the line containing “dtparam=i2c_arm=on”.Īdd “,i2c_arm_baudrate=400000” where 400000 is the new speed (400 Kbit/s). Step 2 – Edit Config.txt File to set I2C Bus Speed

This can be done using “raspi-config” on the command line or “Raspberry Pi Configuration” on the Raspbian desktop.įor step-by-step instructions on how to do this please take a look at the Enable I2C Interface on the Raspberry Pi post. The bus speed is sometimes referred to as “baudrate” although the two aren’t actually the same thing.īefore the interface baudrate can be changed the I2C interface must be enabled. In the newer versions of Raspbian this change must be made using a Device Tree parameter. This is particularly important when using the I2C interface to control a display module. Changing the default I2C bus speed on the Raspberry Pi can help improve the performance of some projects.
