Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
learn:fundamentals:communication-protocols:i2c:start [2016/07/11 20:38] – created Sam Klearn:fundamentals:communication-protocols:i2c:start [2021/10/14 00:11] (current) Arthur Brown
Line 1: Line 1:
 ====== I²C ====== ====== I²C ======
-Inter-integrated-circuit, more commonly known as I²C (generally pronounced I-squared-C), is a communication style originally developed by Phillips Semiconductor (now NXP Semiconductor). In this protocol, originally intended to be part of the [[http://blog.digilentinc.com/index.php/digilent-pmods-an-introduction/|"Imod Series"]], only two communication pins are used: a serial data line (SDA) which is shared by both the "master" and "slave" devices and a serial clock line (SCK) which the master controls. Both of these lines are natively held in a logic high position through the use of pull-up resistors.+Inter-integrated-circuit, more commonly known as I²C (generally pronounced I-squared-C), is a communication style originally developed by Phillips Semiconductor (now NXP Semiconductor). In this protocol, originally intended to be part of the [[https://digilent.com/blog/digilent-pmods-an-introduction/|"Imod Series"]], only two communication pins are used: a serial data line (SDA) which is shared by both the "master" and "slave" devices and a serial clock line (SCK) which the master controls. Both of these lines are natively held in a logic high position through the use of pull-up resistors.
  
 I²C with its 7 or 10-bit addressing scheme offers the advantage of placing numerous devices on the single data and clock lines. A lone master is then able to start a communication session with a device by issuing a start condition and then submitting the address, as well as an indicator if it wants to read from or write to the device, on the SDA line to all of the listening devices. If the device that the host board is calling is on the line (pun intended), that device will respond with an acknowledge (ACK) bit leaving it to listen for the next command while the rest of the devices wait for another start condition before listening for their address again. I²C with its 7 or 10-bit addressing scheme offers the advantage of placing numerous devices on the single data and clock lines. A lone master is then able to start a communication session with a device by issuing a start condition and then submitting the address, as well as an indicator if it wants to read from or write to the device, on the SDA line to all of the listening devices. If the device that the host board is calling is on the line (pun intended), that device will respond with an acknowledge (ACK) bit leaving it to listen for the next command while the rest of the devices wait for another start condition before listening for their address again.
Line 53: Line 53:
   * When the Serial Clock line reaches a high voltage level (after any clock stretching has been completed), the SDA line is then read by the receiving device to collect the data bit, as shown by each of the green bars.   * When the Serial Clock line reaches a high voltage level (after any clock stretching has been completed), the SDA line is then read by the receiving device to collect the data bit, as shown by each of the green bars.
   * This process of SCL transistions and data bits being placed and read continues until a stop bit, indicated by the SDA being pulled high by the pull-up resistors while the SCL line is high, occurs.   * This process of SCL transistions and data bits being placed and read continues until a stop bit, indicated by the SDA being pulled high by the pull-up resistors while the SCL line is high, occurs.
- 
-==== Example Code ==== 
-Demonstration code that uses the default I²C port on Digilent chipKIT boards is provided below. It uses the Wire.h library that comes with MPIDE and showcases Digilent's PmodCDC1. 
- 
-(2/11/2015 - to be provided in the near future) 
------ 
- 
-===== Hardware Compatibility ===== 
- 
  
 ===== More Information ===== ===== More Information =====
  
 Although this communication style is inherently not as fast as [[pmod:communication_protocols:spi|SPI]] because it only operates in half-duplex and requires consistent checking for arbitration, it is far easier to create a string or "daisy-chain" of I²C devices. This is because the Pmods that offer I²C communication styles have a 2x4 pin header for I²C allowing for a string of devices. Additionally, because the communication style is set up where the master calls out a slave address as opposed to selecting a specific slave on it's own line, only two Input/Output pins are ever needed for a I²C communication setup. Although this communication style is inherently not as fast as [[pmod:communication_protocols:spi|SPI]] because it only operates in half-duplex and requires consistent checking for arbitration, it is far easier to create a string or "daisy-chain" of I²C devices. This is because the Pmods that offer I²C communication styles have a 2x4 pin header for I²C allowing for a string of devices. Additionally, because the communication style is set up where the master calls out a slave address as opposed to selecting a specific slave on it's own line, only two Input/Output pins are ever needed for a I²C communication setup.
- 
-Here is the list of Pmods that use the I²C interface 
- 
-^  I²C Interface  ||| 
-^  Pmod Name  ^  Fastest Speed Supported      ^  Pull-up Resistors?  | 
-|  [[pmod:pmod:acl|PmodACL]]      |  400 kHz  |  No      | 
-|  [[pmod:pmod:ad2|PmodAD2]]      |  3.4 MHz  |  No      | 
-|  [[pmod:pmod:amp3|PmodAMP3]]    |  400 kHz  |  No      | 
-|  [[pmod:pmod:cdc1|PmodCDC1]]    |  400 kHz  |  Yes; 100K to Vcc  | 
-|  [[pmod:pmod:cls|PmodCLS]]      |  400 kHz  |  No      | 
-|  [[pmod:pmod:cmps|PmodCMPS]]    |  400 kHz  |  Jumper Blocks; 2.2k to Vcc  | 
-|  [[pmod:pmod:gyro|PmodGYRO]]    |  400 kHz  |  No      | 
-|  [[pmod:pmod:ioxp|PmodIOXP]]    |  1 MHz    |  No      | 
-|  [[pmod:pmod:pmon1|PmodPMON1]]  |  400 kHz  |  No      | 
-|  [[pmod:pmod:rtcc|PmodRTCC]]    |  400 kHz  |  No      | 
-|  [[pmod:pmod:tmp2|PmodTMP2]]    |  400 kHz  |  No      | 
-|  [[pmod:pmod:tmp3|PmodTMP3]]    |  400 kHz  |  Jumper Blocks; 2.2k to Vcc  |