Difference between revisions of "EBC Exercise 12 I2C"

From eLinux.org
Jump to: navigation, search
(Initial page)
 
m (Assignment: Added Hardware details)
Line 3: Line 3:
  
 
[http://en.wikipedia.org/wiki/I%C2%B2C I2C] is a "two-wire interface" standard that is used to attach low-speed peripherals to an embedded system.  In this exercise we will wire up a couple of I2C temperature sensors ([http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010749 TC74]) and learn how to read their values.
 
[http://en.wikipedia.org/wiki/I%C2%B2C I2C] is a "two-wire interface" standard that is used to attach low-speed peripherals to an embedded system.  In this exercise we will wire up a couple of I2C temperature sensors ([http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010749 TC74]) and learn how to read their values.
 +
 +
== The Hardware ==
 +
 +
The DM3730 on the BeagleBoard-xM has four I²C controllers (Section 17 of the TRM). Bus 2 is brought out to the [[EBC_Exercise_02_Flashing_an_LED#Reading_a_gpio_pin_with_an_Oscilloscope | Expansion Header]]. These signals are 1.8V and the TC74 runs on 2.7 to 5.5V.  For now I'm going to use the [[BeagleBoard Trainer]] since it brings the voltages up to 3.3V.
 +
 +
I²C is a two-wire bus. The two wires are
 +
# Serial Clock (SCLK on the data sheet, SCL on the Beagle), is an input to the TC74 and is used to clock data into and out of the TC74.
 +
# Serial Data (SDA on both), is bidirection and carries the data to and from the TC74.
 +
 +
The only other two pins on the TC74 that you need to use are the Power Supply (Vdd) and Ground.
 +
 +
Wire up the TC74 to the Beagle by attaching the Vdd to the 3.3V pad on the Trainer, the GND to a GND on the Trainer and SDA to SDA and SCLK to SCL.  '''You will also need to attach two pull up resistors'''.  Get two 4.7KΩ resistors.  Attach one between SDA and Vdd.  Attach the other between SCL and Vdd.
 +
 +
You TC74 should be labeled with '''TC74a''#''''' where the '''#''' is a digit.  This digit tells the address of the device.  If you have another TC74 with a different address, you can wire it in parallel with the first.  That is, attach SDA to SDA and SCL to SCL, etc.  No need for additional pull up resistors.
 +
 +
== The Software ==
 +
 +
The Beagle brings out I²C bus 2 to the Expansion Header. You can see what devices are on the bus by using the [http://www.lm-sensors.org/wiki/man/i2cdetect i2cdetect] command. On your Beagle try:
 +
 +
<pre>
 +
$ i2cdetect -y-r 2
 +
    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
 +
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
 +
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 +
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 +
30: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- --
 +
40: -- -- -- -- -- -- -- -- 48 -- 4a -- -- -- -- --
 +
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 +
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 +
70: -- -- -- -- -- -- -- --
 +
</pre>
 +
What you see is a list of all the devices found on the bus. I've attached two TC74's, a TC74A0 and a TC74A2.  Their address are <code>1001 000</code> and <code>1001 010</code> respectively.
  
 
== Assignment ==
 
== Assignment ==
  
 
== References ==
 
== References ==

Revision as of 08:21, 26 July 2011


I2C is a "two-wire interface" standard that is used to attach low-speed peripherals to an embedded system. In this exercise we will wire up a couple of I2C temperature sensors (TC74) and learn how to read their values.

The Hardware

The DM3730 on the BeagleBoard-xM has four I²C controllers (Section 17 of the TRM). Bus 2 is brought out to the Expansion Header. These signals are 1.8V and the TC74 runs on 2.7 to 5.5V. For now I'm going to use the BeagleBoard Trainer since it brings the voltages up to 3.3V.

I²C is a two-wire bus. The two wires are

  1. Serial Clock (SCLK on the data sheet, SCL on the Beagle), is an input to the TC74 and is used to clock data into and out of the TC74.
  2. Serial Data (SDA on both), is bidirection and carries the data to and from the TC74.

The only other two pins on the TC74 that you need to use are the Power Supply (Vdd) and Ground.

Wire up the TC74 to the Beagle by attaching the Vdd to the 3.3V pad on the Trainer, the GND to a GND on the Trainer and SDA to SDA and SCLK to SCL. You will also need to attach two pull up resistors. Get two 4.7KΩ resistors. Attach one between SDA and Vdd. Attach the other between SCL and Vdd.

You TC74 should be labeled with TC74a# where the # is a digit. This digit tells the address of the device. If you have another TC74 with a different address, you can wire it in parallel with the first. That is, attach SDA to SDA and SCL to SCL, etc. No need for additional pull up resistors.

The Software

The Beagle brings out I²C bus 2 to the Expansion Header. You can see what devices are on the bus by using the i2cdetect command. On your Beagle try:

$ i2cdetect -y-r 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- 
40: -- -- -- -- -- -- -- -- 48 -- 4a -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- 

What you see is a list of all the devices found on the bus. I've attached two TC74's, a TC74A0 and a TC74A2. Their address are 1001 000 and 1001 010 respectively.

Assignment

References