I2C @ Dorkbot PDX 0X08
Total Page:16
File Type:pdf, Size:1020Kb
Sailing the I2Cs with the Bus Pirate ShareBrained Technology Jared Boone DorkbotPDX 0x08 - January 30, 2012 Tuesday, February 26, 13 Hi, I'm Jared Boone. I'm going to speak about the I2C bus, and a cool gadget, called the Bus Pirate, that makes working with the I2C bus a lot easier. “I2C”? • “Inter-Integrated Circuit” bus. • Truth in naming: provides a way for integrated circuits (chips) to communicate. • Very simple. So simple it costs virtually nothing to implement inside a chip. • PCI, USB, even PC-style serial ports are more complicated and expensive to put in a chip. And they’re all overkill for chip-chip communication. Tuesday, February 26, 13 So what is I2C? It’s a communication bus designed specifically for chips to communicate with each other, very inexpensively. The best way to make something inexpensive is to make it simple. And I2C is definitely simple. It’s *almost* the simplest form of digital communication conceivable. Way simpler than PCI or PCI Express. Way simpler than USB. Simpler, even, than a PC serial port. What Speaks I2C? • Many integrated circuits -- sensors, memories, chips that need to be configured/controlled externally. • Most microcontrollers speak I2C, too. The Arduino (AVR8), ARMs, MSP430s, PICs, you name it! Tuesday, February 26, 13 OK, so it’s simple. But what is it good for? A lot of fun and interesting chips implement I2C, as do virtually all the microcontroller chips available. Here are some examples: Sensors SparkFun.com SparkFun.com SparkFun.com Tuesday, February 26, 13 Analog Devices ADXL345 three-axis accelerometer Honeywell HMC5843 three-axis magnetometer (compass) Invensense ITG-3200 three-axis gyroscope Many others available -- temperature, humidity, pressure, light/color... Stereo Audio Codec Tuesday, February 26, 13 Audio codecs, for high-quality audio. I2C is not used for the audio signal, but is used for configuring signal routing, input and output volumes, etc. 24AA128/24LC128/24FC128 128K I2C™ CMOS Serial EEPROM Device Selection Table •Temperature Ranges: -Industrial (I): -40C to +85C Part VCC Max. Clock Temp. - Automotive (E): -40C to +125C Number Range Frequency Ranges 24AA128 1.7-5.5V 400 kHZ(1) I Description: 24LC128 2.5-5.5V 400 kHZ I, E The Microchip Technology Inc. 24AA128/24LC128/ (2) 24FC128 1.7-5.5V 1 MHZ I 24FC128 (24XX128*) is a 16K x 8 (128 Kbit) Serial Note 1: 100 kHZ for VCC < 2.5V. Electrically Erasable PROM (EEPROM), capable of 2: 400 kHZ for VCC < 2.5V. operation across a broad voltage range (1.7V to 5.5V). It has been developed for advanced, low-power Features: applications such as personal communications or data acquisition. This device also has a page write capabil- •Single Supply with Operation down to 1.7V for ity of up to 64 bytes of data. This device is capable of 24AA128/24FC128 devices, 2.5V for 24LC128 both random and sequential reads up to the 128K Devices boundary. Functional address lines allow up to eight •Low-Power CMOS Technology: devices on the same bus, for up to 1 Mbit address -Write current 3 mA, typical space. This device is available in the standard 8-pin -Standby current 100 nA, typical plastic DIP, SOIC (3.90 mm and 5.28 mm), TSSOP, •2-Wire Serial Interface, I2C™ Compatible MSOP, DFN, TDFN and Chip Scale packages. •Cascadable up to Eight Devices Block Diagram •Schmitt Trigger Inputs for Noise Suppression A0 A1 A2WP HV Generator •Output Slope Control to Eliminate Ground Bounce •100 kHZ and 400 kHZ Clock Compatibility •1 MHZ Clock for FC Versions I/O Memory EEPROM •Page Write Time 5 ms, typical Control Control XDEC Array Logic Logic •Self-Timed Erase/Write Cycle Page Latches •64-Byte Page Write Buffer I/O •Hardware Write-Protect SCL •ESD Protection >4000V YDEC •More than 1 Million Erase/Write Cycles SDA •Data Retention > 200 years •Factory Programming Available VCC •Packages include 8-lead PDIP, SOIC, TSSOP, VSS Sense Amp. R/W Control DFN, TDFN, MSOP, and Chip Scale Packages •Pb-Free and RoHS Compliant *24XX128 is used in this document as a generic part number Electrically-Erasable ROM for the 24AA128/24LC128/24FC128 devices. Package Types 1 PDIP/SOIC TSSOP/MSOP DFN/TDFN CS (Chip Scale)2 A0 1 8 VCC VCC A1 A0 A0 1 8 VCC A0 1 8 VCC 123 A1 2 7 WP A1 2 7 WP A1 2 7 WP WP45 A2 A2 3 6 SCL A2 3 6 SCL A2 3 6 SCL 6 7 8 24XX128 24XX128 24XX128 VSS 4 5 SDA SDA SCL VSS VSS 4 5 SDA VSS 4 5 SDA (TOP DOWN VIEW, BALLS NOT VISIBLE) Courtesy of Microchip Note 1: Pins A0 and A1 are no-connects for the MSOP package only. 2: Available in I-temp, “AA” only. Tuesday, February 26, 13 memory: Serial EEPROMs and flash for persisting more data than your microcontroller allows. 2010 Microchip Technology Inc. DS21191S-page 1 Analog to Digital Converter BurrĆBrown Products BD0 Courtesy of Texas Instruments ADS1000 Tuesday, February 26, 13 from Texas Instruments Data converters: Low-speed analog-to-digital and digital-to-analog converters for capturing or generating analog signals (if your microcontroller doesn’t have enough converters, or they’re not very good). SBAS357A–SEPTEMBER 2006–REVISED OCTOBER 2007 LOW-POWER, 12-Bit ANALOG-TO-DIGITAL CONVERTER with I2C™ INTERFACE 1FEATURES DESCRIPTION 23• Complete 12-Bit Data Acquisition System in The ADS1000 is an I2C-compatible serial interface a Tiny SOT-23 Package Analog-to-Digital (A/D) converter with differential • Low Current Consumption: Only 90A inputs and 12 bits of resolution in a tiny SOT23-6 package. Conversions are performed ratiometrically, Integral Nonlinearity: 1LSB Max • using the power supply as the reference voltage. The • Single-Cycle Conversion ADS1000 operates from a single power supply • Programmable Gain Amplifier ranging from 2.7V to 5.5V. Gain = 1, 2, 4, or 8 The ADS1000 performs conversions at a rate of 128 • 128SPS Data Rate samples per second (SPS). The onboard • I2C Interface with Two Available Addresses programmable gain amplifier (PGA), which offers gains of up to 8, allows smaller signals to be • Power Supply: 2.7V to 5.5V measured with high resolution. In single-conversion • Pin- and Software-Compatible with 16-Bit mode, the ADS1000 automatically powers down after ADS1100 a conversion, greatly reducing current consumption during idle periods. APPLICATIONS The ADS1000 is designed for applications where • Voltage Monitors space and power consumption are major • Battery Management considerations. Typical applications include portable • Industrial Process Control instrumentation, consumer goods, and voltage monitoring. • Consumer Goods • Temperature Measurement VDD A=1,2,4,or8 VIN+ SCL A/D 2 PGA IC Converter Interface VIN- SDA Clock Oscillator ADS1000 GND 1 Please be aware that an important notice concerning availability, standard warranty, and use in critical applications of Texas Instruments semiconductor products and disclaimers thereto appears at the end of this data sheet. 2I2C is a trademark of NXP Semiconductors, Inc. 3All other trademarks are the property of their respective owners. PRODUCTION DATA information is current as of publication date. Products conform to specifications per the terms of the Texas Copyright © 2006–2007, Texas Instruments Incorporated Instruments standard warranty. Production processing does not necessarily include testing of all parameters. I2C-controlled RGB LED SparkFun.com Tuesday, February 26, 13 LEDs like the BlinkM: For generating a complex, multi-color, multi-LED light show from your microcontroller. How Simple Is It? • Serial bus -- transfers data one bit at a time. • No fancy self-clocking scheme (like USB or even PC-style serial ports). Clock signal is a separate signal from the data. • Only two signals/wires to connect chips to each other. (If they’re on the same board, that is...) Tuesday, February 26, 13 So I2C is a simple serial bus. It transmits data one bit at a time. What makes it simpler than other serial buses, like USB or a PC serial port? USB and serial ports use tricky encodings and hardware so the receiving device’s hardware can synchronize with the transmitted data. That extra hardware is expensive to put in a chip, so instead, the I2C designers added a separate synchronization (or “clock”) signal. This makes the hardware in the chip a lot simpler. Shared Bus I2C uC Sensor Sensor Memory ADC Tuesday, February 26, 13 I2C is a shared bus. You can connect lots of devices to the same bus, and communicate with them individually. With only two signals shared between all the devices, how do the devices on the bus avoid speaking at the same time? To start with, I2C uses a master/slave model. The master (usually the microcontroller) starts ALL conversations. The rest of the devices on the bus are slaves, and only respond to the master’s requests. OK, so the master is in charge of the bus, initiating all requests. But, at the start of a request, how does the master indicate which device it wants to speak with? At the beginning of each request, the master sends an address over the bus. Each device has a unique address, and only the device which matches that address will respond. Unique Addresses I2C uC Sensor Sensor Memory ADC addr=1d addr=53 addr=72 addr=48 Tuesday, February 26, 13 I2C addresses are seven bits. So you can only have 128 devices on the bus. In practice, that’s not a big deal. Most I2C designs I’ve seen have no more than a half-dozen devices on the bus. Address Conflict I2C uC Sensor Sensor Memory ADC addr=1d addr=1d addr=72 addr=48 Tuesday, February 26, 13 The problem is with how chips get their addresses.