Serial Interfaces – Part 2

ECE 153B Sensor & Peripheral Interface Design Winter 2016 The I2C

 I2C (Inter Integrated Circuit) Bus

 Serial, 2-wire bus  Different than point–to–point communications

 Developed by Philips (now NXP) Semiconductor in early 1980’s  SMBus (System Management Bus) is a subset of I2C

 Software controlled addressing  No address decoding hardware  Available as a built-in peripheral on many μControllers and μProcessors

Winter 2016 ECE 153B - Sensor & Peripheral Interface 2 Design - Serial Interfaces - Part 2 The I2C Bus

 Revision / Speed History

 The original (1982) 100-kHz I²C system was created as a simple internal bus system for building control electronics with various Philips chips

 Version 1 (1992) added 400-kHz Fast-mode (Fm) and a 10-bit addressing mode to increase capacity to 1008 nodes  This was the first standardized version

 Version 2 (1998) added 3.4-MHz High-speed mode (Hs) with power- saving requirements for electric voltage and current

 Version 3 (2007) added 1-MHz Fast-mode plus (Fm+), and a device ID mechanism

 Version 4 (2012) added 5-MHz Ultra Fast-mode (UFm) for new USDA and USCL lines using push-pull logic without pull-up resistors, and added assigned manufacturer ID table

Winter 2016 ECE 153B - Sensor & Peripheral Interface 3 Design - Serial Interfaces - Part 2 The I2C Bus

 2 Wire, Serial Bus  SDA – Serial Data  SCL – Serial Clock

 Many masters, many slaves possible  always at least one master (µcontroller or DSP)

Winter 2016 ECE 153B - Sensor & Peripheral Interface 4 Design - Serial Interfaces - Part 2 The I2C Bus

 Electrical implementation  Open drain (collector) connection to data and clock buses

Winter 2016 ECE 153B - Sensor & Peripheral Interface 5 Design - Serial Interfaces - Part 2 The I2C Bus

 Each device has a unique 7-bit I2C address

 4 most significant bits are typically fixed and assigned to specific categories of devices

 e.g. 4’b1010 is assigned to serial EEPROMs  3 less significant bits are programmable, often through hardware address pins

Winter 2016 ECE 153B - Sensor & Peripheral Interface 6 Design - Serial Interfaces - Part 2 I2C Bus Terminology

 Master

 The component that initiates a transfer (Start command), generates the clock signal (SCL), and terminates the transfer (Stop command)

 Slave

 The device addressed by the master  A slave can be either receiver or transmitter

 Transmitter

 Device that sends data to the bus  can be master-transmitter or slave-transmitter

 Receiver

 Device that receives data from the bus  can be master-receiver or slave-receiver

Winter 2016 ECE 153B - Sensor & Peripheral Interface 7 Design - Serial Interfaces - Part 2 I2C Bus – Terminology Illustrated

 Master always drives the clock line which sets the timing for all transactions

 Master can be either transmitter or receiver, depending on data direction

Winter 2016 ECE 153B - Sensor & Peripheral Interface 8 Design - Serial Interfaces - Part 2 More I2C Bus Terminology

 Multi-master

 The ability for more than one master to co-exist on the bus at the same time without collision or data loss.

 Obviously, though multiple masters may be present, only one can be master in any one transaction

 Arbitration

 The prearranged procedure that authorizes only one master at a time to take control of the bus

 Synchronization

 The prearranged procedure that synchronizes the clock signals provided by two or more masters.

Winter 2016 ECE 153B - Sensor & Peripheral Interface 9 Design - Serial Interfaces - Part 2 The I2C Bus

 Nomenclature for I2C Bus Transfer Conditions and States

 F (FREE)

 The bus is free or idle; the data line SDA and the SCL clock are both in the high state

 S (START) or R (RESTART)

 Data transfer begins with a Start condition. The level of the SDA data line changes from high to low, while the SCL clock line remains high. When this occurs, the bus becomes 'busy‘

 C (CHANGE)

 While the SCL clock line is low, the data bit to be transferred can be applied to the SDA data line by a transmitter. During this time, SDA may change its state, as long as the SCL line remains low.

Winter 2016 ECE 153B - Sensor & Peripheral Interface 10 Design - Serial Interfaces - Part 2 The I2C Bus

 More nomenclature for I2C Bus Transfer Conditions and States

 D (DATA)

 A high or low bit of information on the SDA data line is valid during the high level of the SCL clock line  This level must be kept stable during the entire time that the clock remains high to avoid misinterpretation as a Start or Stop condition

 P (STOP)

 Data transfer is terminated by a Stop condition  This occurs when the level on the SDA data line passes from the low state to the high state, while the SCL clock line remains high  When the data transfer has been terminated, the bus is free once again

Winter 2016 ECE 153B - Sensor & Peripheral Interface 11 Design - Serial Interfaces - Part 2 I2C Bus Transactions

 I2C address of the targeted device is sent in the first byte after Start condition

 LSB of initial byte indicates direction of transfer (R/W)

 Each transmission sequence begins with Start condition and ends with Stop or ReStart condition

 After every 8 data bits in one direction, an "acknowledge" bit is transmitted in the other direction

 The transmitter and receiver switch roles for one bit and the erstwhile receiver transmits a single 0 bit (ACK) back

Winter 2016 ECE 153B - Sensor & Peripheral Interface 12 Design - Serial Interfaces - Part 2 I2C Bus Transactions

 If the transmitter sees a 1 bit (NACK) instead, it learns that:  (If master transmitting to slave) The slave is unable to accept the data. No such slave, command not understood, or unable to accept any more data  (If slave transmitting to master) The master wishes the transfer to stop after this data byte

Winter 2016 ECE 153B - Sensor & Peripheral Interface 13 Design - Serial Interfaces - Part 2 I2C Bus Transactions

 Data transfer is initiated with the START bit (S) when SDA is pulled low while SCL stays high

 Then, SDA sets the transferred bit while SCL is low (blue) and the data is sampled (received) when SCL rises (green)

 When the transfer is complete, a STOP bit (P) is sent by releasing the data line to allow it to be pulled up while SCL is constantly high

 In order to avoid false marker detection, the level on SDA is changed on the falling edge and is captured on the rising edge of SCL

Winter 2016 ECE 153B - Sensor & Peripheral Interface 14 Design - Serial Interfaces - Part 2 SPI – Serial Peripheral Interface

 Developed by Motorola  Also known as Serial Synchronous Interface (SSI)

 3- or 4-wire serial interface  Optional 4-wire (SS=slave select) is not bussed

 Full-duplex data transfer

Winter 2016 ECE 153B - Sensor & Peripheral Interface 15 Design - Serial Interfaces - Part 2 SPI – Serial Peripheral Interface

 No special protocol  Just a simple shift register  MSB generally transmitted first

 All data transfers are full-duplex  Data are transferred even if they have no meaning

Winter 2016 ECE 153B - Sensor & Peripheral Interface 16 Design - Serial Interfaces - Part 2 SPI – Serial Peripheral Interface

 Flexible clocking strategies

 Clock is not free-running like I2C  Synchronizes after each transfer

 Programmable clock phase (CPHA) and polarity (CPOL) established by master

 Clock speed can be quite Red line indicates CPHA =0 high Blue line indicates CPHA = 1  e.g. an adaptation for SD cards uses 25MHz

Winter 2016 ECE 153B - Sensor & Peripheral Interface 17 Design - Serial Interfaces - Part 2 SPI – Serial Peripheral Interface

 Two possibilities for connecting multiple slaves

Star (slaves in parallel) Slaves in Series

Note: SS may Note: extra not be SS signals needed

Winter 2016 ECE 153B - Sensor & Peripheral Interface 18 Design - Serial Interfaces - Part 2 USB

 The Universal Serial Bus

Winter 2016 ECE 153B - Sensor & Peripheral Interface 19 Design - Serial Interfaces - Part 2 USB

 Developed (1996) to provide simple connectivity between PC’s and a diverse range of peripheral devices

 Original consortium included Intel, Compaq, Microsoft, NEC, Digital Equipment Corporation, IBM, Nortel

 USB is both a serial protocol and a physical link

 One pair of wires transmits differential data

 Second pair of wires provides power to downstream peripherals

 Up to 127 USB devices can be connected to a host computer port

Winter 2016 ECE 153B - Sensor & Peripheral Interface 20 Design - Serial Interfaces - Part 2 USB

 Data rates

 USB-1.1 (1996)  1.5 Mbps (low speed) and 12 Mbps (full speed)

 USB-2.0 (2000)  480 Mbps (Hi-Speed) . Compare that with I2C: 100 Kbps up to 3.4 Mbps max

 USB-3.0 (2008)  Up to 5Gbps (SuperSpeed)  Uses different connectors, downward compatible

Winter 2016 ECE 153B - Sensor & Peripheral Interface 21 Design - Serial Interfaces - Part 2 USB

 Peripherals can be connected and removed without powering the entire system down

 Referred to as “hot swapping”

 Peripheral power (for the interface) is provided through the USB connection

 USB peripherals are slaves, responding to commands from the host

 When a peripheral is attached to a USB network, the host communicates with the device to learn its identity and to discover which device driver is required

 Process is called “bus enumeration”  This is what takes so long whenever you plug or unplug

Winter 2016 ECE 153B - Sensor & Peripheral Interface 22 Design - Serial Interfaces - Part 2 USB

 USB peripherals only communicate with the host  Peripherals cannot communicate directly with each other

 USB communications take place between the host and “endpoints” located in the peripherals

 All USB transfers occur through “virtual pipes”  When establishing communications with the peripheral, each endpoint returns a descriptor

 A data structure that tells the host about the endpoint’s configuration and its expectations

 Descriptors include: . transfer type . maximum size of packets . optionally the interval for data transfers and the required bandwidth . what version of the protocol to use

Winter 2016 ECE 153B - Sensor & Peripheral Interface 23 Design - Serial Interfaces - Part 2 USB

 The host device driver

 USB is a complex standard that requires extensive software support, both on the firmware side and in the host computer

 A USB host driver is a complex piece of software

 Many devices, however, can make use of general-purpose “class drivers” provided with Windows, MAC O/S, or

 e.g. Human Interface Device (HID), Communication, Mass Storage, Printer, Audio, etc.

 Alternatively, devices can go their own way but then they require a custom driver (for each O/S)

 IC vendors offer specialized parts (camera controllers, audio devices, etc.) for the peripheral side of the interface

Winter 2016 ECE 153B - Sensor & Peripheral Interface 24 Design - Serial Interfaces - Part 2 FireWire (IEEE – 1394)

 FireWire developed by Apple Computer in 1986

 Became IEEE Standard 1394 in 1987

 Other trade names include i.LINK (Sony), Linx (Texas Instruments) and others

 Serial interface similar to USB

 Target application is high-bandwidth, isochronous (real-time) data interfacing

 Intended to replace parallel SCSI (Small Computer System Interface)

 Lower implementation costs and a simplified, more adaptable cabling system

Winter 2016 ECE 153B - Sensor & Peripheral Interface 25 Design - Serial Interfaces - Part 2 FireWire (IEEE – 1394)

 Revision History and Data Rates

 IEEE 1394a (1995/2000)  100, 200, or 400 Mbps

 IEEE 1394b (2002)  800, 1600, 3200 Mbps  Beta mode operation based on 8B/10B encoding . Allows clock recovery in Telecom systems

 IEEE 1394c (2006)  800 Mbps over Cat5E copper cable with RJ45 connector . FireWire over Gigabit cable and connector

Winter 2016 ECE 153B - Sensor & Peripheral Interface 26 Design - Serial Interfaces - Part 2 USB vs. FireWire

 Comparison to USB

 Both are serial buses using twisted pair wiring for data transmission

 FireWire had higher data rate (until USB3.0)

 FireWire can support 63 devices (127 for USB)

 Both allow hot swapping

 Both have feature

 FireWire is generally considered to be a more complex and expensive interface

Winter 2016 ECE 153B - Sensor & Peripheral Interface 27 Design - Serial Interfaces - Part 2 Ethernet

 Local Area Network (LAN) Protocol

 History

 Developed as an experimental coaxial cable network in the late 1970’s by Xerox PARC (Palo Alto Research Center)

 Original data rate was 3 Mbps

 Joint development among Xerox, Digital Equipment Corporation (DEC) and Intel led to 10-Mbps Ethernet Version 1.0 specification in 1980

 “vampire tap” shown above  This was used in bus-style coax

 IEEE 802.3 published as first official standard in 1985

Winter 2016 ECE 153B - Sensor & Peripheral Interface 28 Design - Serial Interfaces - Part 2 Ethernet

 Many data rates developed over various media, including optical fiber and twisted-pair cables

 10 Mbps (1990) IEEE 802.3i  10Base-T Ethernet

 100 Mbps (1995) IEEE 802.3u  so-called “Fast Ethernet”

 1,000 Mbps (1999) IEEE 802.3ab  Gigabit Ethernet

 10,000 Mbps (2006) IEEE 802.3an  10 Gigabit Ethernet

 100,000 Mbps (2010) IEEE 802.3ba  100 Gigabit Ethernet

Winter 2016 ECE 153B - Sensor & Peripheral Interface 29 Design - Serial Interfaces - Part 2 Bluetooth

 Wireless, serial, radio frequency (RF) protocol for the connection of electronic devices

 Introduced by Ericsson (Sweden)

 Originally developed (circa 1997) as a system that would allow mobile phones to communicate with computers

 Why the name?

 Harald Bluetooth was king of Denmark in the late 10th century

 The word “Bluetooth” is an anglicized version of the Scandinavian Blåtand/Blåtann

Winter 2016 ECE 153B - Sensor & Peripheral Interface 30 Design - Serial Interfaces - Part 2 Bluetooth

 King Harald was known as “Bluetooth” because of his love for smile-staining blueberries!

 He united Denmark and Norway (and parts of Sweden) under one rule

 He was killed in a 986 battle with his son, Sven Forkbeard

 This name was chosen because of the importance of the Baltic region in the communications industry (Nokia, Ericsson, etc.) with the implication being that Bluetooth does the same with communications protocols that King Harald did with Denmark and Norway; uniting them under one universal standard

Winter 2016 ECE 153B - Sensor & Peripheral Interface 31 Design - Serial Interfaces - Part 2 Bluetooth

 Bluetooth devices operate in the ISM (industrial, scientific and medical) band

 Center frequency at 2.45 GHz

 Bluetooth uses a radio technology called “frequency-hopping spread spectrum”

 Power output is limited to 1mW (class 1) and 2.5 mW (class 2) to avoid interference with other devices operating in the same frequency band

 Transmission is officially limited to 10 meters, but doesn’t suffer the line of sight limitation that infrared does

 Allows transmission through walls

Winter 2016 ECE 153B - Sensor & Peripheral Interface 32 Design - Serial Interfaces - Part 2 Bluetooth

 When Bluetooth-capable devices come within range of one another the protocol dictates that they determine if they have data to share or whether one needs to control the other

 Sometimes referred to as “sniff mode”

 Devices avoid interference using spread-spectrum frequency hopping

 Devices change operating frequency at a 1.6 KHz rate

 Frequencies are selected randomly from 79 available between 2.402 and 2.48 GHz

Winter 2016 ECE 153B - Sensor & Peripheral Interface 33 Design - Serial Interfaces - Part 2 Bluetooth

 If the devices need to communicate, they form a personal-area network (PAN), or piconet

 Once a piconet is established, the members synchronize frequency hopping to maintain communication, while not interfering with other devices and piconets

 All of this happens automatically and mostly in firmware or hardware

Winter 2016 ECE 153B - Sensor & Peripheral Interface 34 Design - Serial Interfaces - Part 2 Bluetooth

 Specs

 Piconet channel capacity : 1 Mbps

 In U.S. and Europe, 79 RF channels (1 MHz each) between 2.402 and 2.480 GHz

 In Japan, 23 RF channels (1MHz) between 2.472 and 2.497 GHz

 In both cases, frequency hopping occurs at 1.6 KHz rate  625 µsec per time slot

 A piconet has a master and up to seven slaves  The master transmits in even time slots, slaves in odd time slots

Winter 2016 ECE 153B - Sensor & Peripheral Interface 35 Design - Serial Interfaces - Part 2 Bluetooth Implementation

 Bluetooth Module – RN-41XV (~$30)

 3.3V Operation

 30mA connected  < 10mA “sniff mode”

 UART and USB Data Interface

 Bluetooth® version 2.1 + Enhanced Data Rate (EDR) Module

 Backward compatible with Bluetooth version 2.0, 1.2 and 1.0

Winter 2016 ECE 153B - Sensor & Peripheral Interface 36 Design - Serial Interfaces - Part 2 WiFi

 Wireless networking protocol

 The name is a trademark name, and was stated to be a play on the audiophile term Hi-Fi (High Fidelity)

 The Wi-Fi Alliance hired Interbrand to determine a name that was "a little catchier than 'IEEE 802.11b Direct Sequence”

 IEEE 802.11 established in 1997

 Several versions of 802.11 exist (a,b,g,n)

 IEEE 802.11b (1999)

 Slowest and least expensive

 Operates at 2.4 GHz with up to 11 Mbps

 Good range; able to penetrate walls

Winter 2016 ECE 153B - Sensor & Peripheral Interface 37 Design - Serial Interfaces - Part 2 WiFi

 IEEE 802.11a (1999)

 Operates at 5 GHz with up to 54 Mbps  More expensive than 802.11b and poorer range and penetration

 IEEE 802.11g (2003)

 Best of two previous versions  Operates at 2.4 GHz (cheaper than 5 MHz) but maintains 54 Mbps data rate of 802.11b

 IEEE 802.11n (2009)

 Uses multiple signals and antennas (MIMO)  Supports data rates above 100Mbps  Can have greater interference (uses multiple signals)  Better range than previous versions

Winter 2016 ECE 153B - Sensor & Peripheral Interface 38 Design - Serial Interfaces - Part 2 WiFi

 WiFi implementation is actually quite complicated from an RF and communication theory perspective

 It employs the same type of spread-spectrum frequency hopping that Bluetooth uses

 It also employs advanced signal processing and data compression techniques

 Interfacing to WiFi is generally accomplished through incorporation of a WiFi module

 Thus, the interface to WiFi is the interface offered by the module

Winter 2016 ECE 153B - Sensor & Peripheral Interface 39 Design - Serial Interfaces - Part 2 WiFi Implementation

 Roving Networks RN171XVW-I/RM

 3.3V Operation

 TTL UART Interface

 802.11 b/g

 Built-in HTML web client to send GPIO, UART, and sensor data to remote web servers

 Built-in networking applications:

 DHCP, DNS, ARP, ICMP UDP, Telnet, FTP client, and HTML client

Winter 2016 ECE 153B - Sensor & Peripheral Interface 40 Design - Serial Interfaces - Part 2 Bluetooth vs. WiFi

 Bluetooth and WiFi have some similar applications:

 Setting up networks, printing, or transferring files

 Bluetooth is intended for portable equipment and its applications

 This category of applications is outlined as the wireless personal area network (WPAN)

 WiFi is intended as a replacement for high speed cabling for general local area network access in work areas

 This category of applications is sometimes called wireless local area networks (WLAN)

 Bluetooth and WiFi are to some extent complementary in their applications and usage

 WiFi is usually access point-centered, with an asymmetrical client-server connection with all traffic routed through the access point

 Bluetooth is usually symmetrical, between two Bluetooth devices

Winter 2016 ECE 153B - Sensor & Peripheral Interface 41 Design - Serial Interfaces - Part 2