8 Serial Interfaces 3 Flashcards
History I2C?
- Philips Semiconductor is now NXP, who used to hold a patent on the protocol, but this has now expired
- Originally used by Philips inside television sets but is now a very common peripheral bus standard
I2C overview?
- I2C is a two wire serial bus that was invented by Philips Semiconductor in the early 1980s
- Intended for use in embedded systems
- I 2C is a multi-master multi-slave interface designed for connecting integrated circuits together
- The original specification was fixed to operate at 100 kHz, the most recent version supports clock rates of up to ~5 MHz
- Inspired I2S (inter-integrated sound)
Main difference I2C?
there are strict conditions
Common I2C layout?
I2C connections
• I²C uses only two bidirectional open-drain lines, Serial Data Line (SDA) and Serial Clock Line (SCL), pulled up with resistors (don’t forget these!)
I2C typical voltages?
Typical voltages used are + 5 V or + 3.3 V although systems with other voltages are permitted
I2C chip select lines?
There are no chip select lines, instead, I²C devices have a 7-bit or a 10-bit address, each device is required to have a unique address
Data Transmission I2C?
- Each device has an open drain output and so lines can be pulled low by any device, and are high when all devices release them. Multiple devices pulling the lines low do not cause internal short circuits
- Data is clocked synchronously to SCL, with the clock being generated by the master device
- It is possible to have multiple masters, but arbitration must be used to ensure correct communication. The arbitration is normally as simple and checking both SDA and SCL have been high for some time before transmitting
How is the basic flow of communication controlled by the master?
Starts the communication
Signals the slave address, including a read/write bit
Looks for an acknowledgement
Reads/write data until done, then stops
Diagram I2C communication?
How to write I2C?
- All Devices: Allow SDA & SCL to float high
- Master: Pull SDA low to signal start
- Master: Drive clock on SCL, and 7 bit address followed by 0 (W) on SDA
- Slave: Pull SDA low to signify ACKnowledge
- Master: Clock out 8 data bits on SDA
- Slave: ACK
- All: Allow SDA to float high when SCL is high (stop)
How to read I2C?
- Master: Address followed by 1 (R) on SDA
- Slave: Clock out 8 data bits on SDA
- Master: ACK
What is clock stretching?
- Clock stretching is a tool used to temporarily slow down the data transfer if the slave device is not ready to receive/transmit more data
- Commonly seen on very high speed data converters where sometimes data just isn’t ready for transmission yet
Advantages of I2C?
- Multi-master and multi-slave are supported
- Individual chip addressing, up to 127 slave devices using only two wires!
- Very low pin count compared to parallel or SPI
- Fairly simple, although more complex than SPI
- Uses ACK to confirm that the devices have correctly understood each other
- Clear, fixed specification so generally easier to implement
- Possible to perform verification against the specification
- Supports hot swapping (you can connect new devices with the bus running)
Disadvantages of I2C?
- Signals are bidirectional, more difficult to achieve Galvanic isolation
- Each slave device must have a unique address, in practice this means you can’t have more than a handful of the same device
- If two devices have the same address then bus conflicts can occur
- Due to the open-drain design, the maximum clock frequency can be lower than SPI
- Only handles short distances
- Only one device can ever be driving the bus at once (so if you have lots of devices you have to talk to them one at a time)
- Full compliance to the specification sometimes involves paying NXP a license fee
Goals of USB?
- Ease-of-use for PC peripheral expansion
- Support fast data rates, up to 7.2 Gb/s for USB 3.1
- Native support for voice, audio and video
- Flexibility for isochronous and asynchronous messaging
- Integration into commodity device technology
- Enable a new class of devices that are “plug-and-play”
- No limitations on what the devices might “be
The requirements of USB?
USB requires a single master (host) device, but with multiple slave devices over multiple hubs
Upon “insertion” the slave devices are enumerated and specify data formats, communications speeds, power requirements and class conformance. Very flexible!
Aims of USB?
USB is designed for connecting products together, as opposed to SPI and I2C that are designed to operate at the component level
USB cost?
- Sadly, if you want to sell a certified USB product (and get hold of the full documentation) then you have to pay a licence fee to the USB Implementers Forum (Microsoft et al)
- Currently $5,000 USD setup plus $3,500 USD a year
USB capabilities?
- USB is a very complicated serial communication system, you often need to write your own device drivers for Windows/Linux (unless your device conforms to a standard such as mass storage)
- USB devices can be powered from the bus, often up to a few Amps, this is how you can charge your iPhone from USB, or power the PIC programmer
Main issue with USB?
• Partly because it is so powerful, USB is notoriously difficult to implement and debug, it is almost never used for small embedded systems
How can you make usb devices easily?
- You can buy USB-to-SPI type chips to speed things up for simple devices
- Designing a fully custom USB device typically requires both a hardware and software development team and about a person year of work
- Devices like the Arduino and the mbed are now providing some simple open source USB libraries that implement things like audio devices – this is very cool and means you can easily make your own USB sound card
- The USB 3.1 specification, which covers only the low level basics, is over 600 pages long!