SlideShare una empresa de Scribd logo
1 de 73
Low Speed Serial Interfaces
SPI and I2C
2 of 40
The I2C Bus
• What is the I2C Bus and what is it used for?
• Bus characteristics
• I2C Bus Protocol
• Data Format
• Typical I2C devices
• Example device
• Sample pseudo code
3 of 40
What is I2C
• The name stands for “Inter - Integrated Circuit Bus”
• A Small Area Network connecting ICs and other electronic
systems
• Originally intended for operation on one
single board / PCB
– Synchronous Serial Signal
– Two wires carry information between
a number of devices
– One wire use for the data
– One wire used for the clock
• Today, a variety of devices are available with I2C Interfaces
– Microcontroller, EEPROM, Real-Timer, interface chips, LCD driver, A/D
converter
4 of 40
What is I2C used for?
• Data transfer between ICs and systems at relatively
low rates
– “Classic” I2C is rated to 100K bits/second
– “Fast Mode” devices support up to 400K bits/second
– A “High Speed Mode” is defined for operation up to 3.4M
bits/second
• Reduces Board Space and Cost By:
– Allowing use of ICs with fewer pins and smaller packages
– Greatly reducing interconnect complexity
– Allowing digitally controlled components to be located
close to their point of use
5 of 40
I2C Bus Characteristics
• Includes electrical and timing specifications,
and an associated bus protocol
• Two wire serial data & control bus implemented with the
serial data (SDA) and clock (SCL) lines
– For reliable operation, a third line is required:
Common ground
• Unique start and stop condition
• Slave selection protocol uses a 7-Bit slave address
– The bus specification allows an extension to 10 bits
• Bi-directional data transfer
• Acknowledgement after each transferred byte
• No fixed length of transfer
6 of 40
I2C Bus Characteristics (cont’d)
• True multi-master capability
– Clock synchronization
– Arbitration procedure
• Transmission speeds up to 100Khz
(classic I2C)
• Max. line capacitance of 400pF,
approximately 4 meters (12 feet)
• Allows series resistor for IC protection
• Compatible with different IC technologies
7 of 40
I2C Bus Definitions
• Master:
– Initiates a transfer by generating
start and stop conditions
– Generates the clock
– Transmits the slave address
– Determines data transfer direction
• Slave:
– Responds only when addressed
– Timing is controlled by the clock line
8 of 40
I2C Bus Configuration Example
9 of 40
I2C Hardware Details
• Devices connected to the bus must have an open drain or
open collector output for serial clock and data signal
• The device must also be able to sense the logic level on
these pins
• All devices have a common ground reference
• The serial clock and data lines are connected to Vdd(typically
+5V) through pull up resistors
• At any given moment the I2C bus is:
– Quiescent (Idle), or
– in Master transmit mode or
– in Master receive mode.
10 of 40
I2C Electrical Aspects
• I2C devices are wire ANDed together.
• If any single node writes a zero, the entire line is zero
I2C Bus Configuration
• 2-wire serial bus – Serial data (SDA) and Serial clock (SCL)
• Half-duplex, synchronous, multi-master bus
• No chip select or arbitration logic required
• Lines pulled high via resistors, pulled down via open-drain drivers
(wired-AND)
I2C Protocol
1. Master sends start condition (S) and controls the clock signal
2. Master sends a unique 7-bit slave device address
3. Master sends read/write bit (R/W) – 0 - slave receive, 1 - slave transmit
4. Receiver sends acknowledge bit (ACK)
5. Transmitter (slave or master) transmits 1 byte of data
I2C Protocol (cont.)
6. Receiver issues an ACK bit for the byte received
7. Repeat 5 and 6 if more bytes need to be transmitted.
8.a) For write transaction (master transmitting), master issues stop
condition (P) after last byte of data.
8.b) For read transaction (master receiving), master does not acknowledge
final byte, just issues stop condition (P) to tell the slave the
transmission is done
I2C Signals
• Start – high-to-low transition of the SDA line while SCL line is high
• Stop – low-to-high transition of the SDA line while SCL line is high
• Ack – receiver pulls SDA low while transmitter allows it to float high
• Data – transition takes place while SCL is slow, valid while SCL is high
15 of 40
Bit Transfer on the I2C Bus
• In normal data transfer, the data line only changes state
when the clock is low
SDA
SCL
Data line stable;
Data valid
Change
of data
allowed
16 of 40
Start and Stop Conditions
A transition of the data line while the clock line is high is
defined as either a start or a stop condition.
Both start and stop conditions are generated by the bus
master
The bus is considered busy after a start condition, until a stop
condition occurs
Start
Condition
Stop
Condition
SCL SCL
SDASDA
17 of 40
I2C Addressing
• Each node has a unique 7 (or 10) bit address
• Peripherals often have fixed and programmable
address portions
• Addresses starting with 0000 or 1111 have
special functions:-
– 0000000 Is a General Call Address
– 0000001 Is a Null (CBUS) Address
– 1111XXX Address Extension
– 1111111 Address Extension – Next Bytes are the
Actual Address
18 of 40
MSB
ACK
LSB
7 – Bit Slave Address
R / Wr
First Byte in Data Transfer on the I2C Bus
R/Wr
0 – Slave written to by Master
1 – Slave read by Master
ACK – Generated by the slave whose address has been output.
19 of 40
I2C Bus Connections
• Masters can be
– Transmitter only
– Transmitter and receiver
• Slaves can be
– Receiver only
– Receiver and transmitter
20 of 40
Acknowledgements
• Master/slave receivers pull data line low for one clock pulse
after reception of a byte
• Master receiver leaves data line high after receipt of the last
byte requested
• Slave receiver leaves data line high on the byte following the
last byte it can accept
Acknowledgement
from receiver
Transmitter releases SDA
line during 9th clock
pulse.
21 of 40
Acknowledgements
• From Slave to Master Transmitter:
– After address received correctly
– After data byte received correctly
• From Slave to Master Receiver:
– Never (Master Receiver generates ACK)
• From Master Transmitter to Slave:
– Never (Slave generates ACK)
• From Master Receiver to Slave:
– After data byte received correctly
22 of 40
Negative Acknowledge
• Receiver leaves data line high for one clock
pulse after reception of a byte
Not acknowledgement
(NACK) from receiver
Transmitter releases SDA
line during 9th clock
pulse.
23 of 40
Negative Acknowledge (Cont’d.)
• From Slave to Master Transmitter:
– After address not received correctly
– After data byte not received correctly
– Slave Is not connected to the bus
• From Slave to Master Receiver:
– Never (Master Receiver generates ACK)
• From Master Transmitter to Slave:
– Never (Slave generates ACK)
• From Master Receiver to Slave:
– After last data byte received correctly
24 of 40
Data Transfer on the I2C Bus
• Start Condition
• Slave address + R/W
– Slave acknowledges with ACK
• All data bytes
– Each followed by ACK
• Stop Condition
ACK from Slave ACK from
Receiver
Remember : Clock is produced by Master
Start Stop
SCL
SDA
25 of 40
Data Formats
Master writing to a Slave
AAA
26 of 40
Data Formats Cont’d.
Master reading from a Slave :
Master is Receiver of data and Slave is Transmitter of data.
1
27 of 40
Data Formats Cont’d.
Combined Format
 A repeated start avoids releasing the bus and therefore
prevents another master from taking over the bus
28 of 40
Multi-master I2C Systems
• Multimaster situations require two additional
features of the I2C protocol
• Arbitration:
– Arbitration is the procedure by which competing
masters decide final control of the bus
– I2C arbitration does not corrupt the data transmitted
by the prevailing master
– Arbitration is performed bit by bit until it is uniquely
resolved
– Arbitration is lost by a master when it attempts to
assert a high on the data line and fails
29 of 40
Arbitration Between Two Masters
• As the data line is like a wired AND, a ZERO address bit overwrites a ONE
• The node detecting that it has been overwritten stops transmitting and
waits for the Stop Condition before it retries to arbitrate the bus
30 of 40
Error Checking
• I2C defines the basic protocol and timing
– Protocol errors are typically flagged by the interface
– Timing errors may be flagged, or in some cases could
be interpreted as a different bus event
• Glitches (if not filtered out) could potentially
cause:
– Apparent extra clocks
– Incorrect data
– “Locked” bus
• Microprocessors communicating with each
other can add a checksum or equivalent
31 of 40
Bus Recovery
• An I2C bus can be “locked” when:
– A Master and a Slave get out of synch
– A Stop is omitted or missed (possibly due to noise)
– Any device on the bus holds one of the lines low
improperly, for any reason
– A shorted bus line
• If SCL can be driven, the Master may send extra
clocks until SDA goes high, then send a Stop.
• If SCL is stuck low, only the device driving it can
correct the problem.
32 of 40
Type of I2C Implementations
• Byte Oriented Interface
– Data is handled one byte at a a time
– Processor interprets a status byte when an event occurs
– For instance Philips 8xC554, 8xC591
• Bit Oriented Interface
– Processor is involved in every bus event when the interface is not Idle
• “Bit Banged”
– Implemented completely in software on 2 regular I/O pins of the
microcontroller
– Works for single master systems
– Not recommended for Slave devices or Multimaster systems
33 of 40
Available I2C Devices
• Analog to Digital Converters (A/D, D/A): MMI functions,
battery & converters, temperature monitoring, control
systems
• Bus Controller: Telecom, consumer electronics, automotive,
Hi-Fi systems, PCs, servers
• Bus Repeater, Hub & Expander: Telecom, consumer
electronics, automotive, Hi-Fi systems, PCs, servers
• Real Time Clock (RTC)/Calendar: Telecom, EDP, consumer
electronics, clocks, automotive, Hi-Fi systems, FAX, PCs,
terminals
• DIP Switch: Telecom, automotive, servers, battery &
converters, control systems
• LCD/LED Display Drivers: Telecom, automotive instrument
driver clusters, metering systems, POS terminals, portable
items, consumer electronics
34 of 40
Available I2C Devices
• General Purpose Input/Output (GPIO) Expanders and LED
Display Control: Servers, keyboard interface, expanders,
mouse track balls, remote transducers, LED drive, interrupt
output, drive relays, switch input
• Multiplexer & Switch: Telecom, automotive instrument driver
clusters, metering systems, POS terminals, portable items,
consumer electronics
• Serial RAM/ EEPROM: Scratch pad/ parameter storage
• Temperature & Voltage Monitor: Telecom, metering systems,
portable items, PC, servers
• Voltage Level Translator: Telecom, servers, PC, portable
items, consumer electronics
35 of 40
End use
• Telecom: Mobile phones, Base stations,
Switching, Routers
• Data processing: Laptop, Desktop,
Workstation, Server
• Instrumentation: Portable instrumentation,
Metering systems
• Automotive: Dashboard, Infotainment
• Consumer: Audio/video systems, Consumer
electronics (DVD, TV etc.)
36 of 40
Applications
• There are some specific applications for
certain types of I2C devices such as TV or radio
tuners, but in most cases a general purpose
I2C device can be used in many different
applications because of its simple
construction.
37 of 40
I2C designer benefits
• Functional blocks on the block diagram
correspond with the actual ICs; designs proceed
rapidly from block diagram to final schematic
• No need to design bus interfaces because the I2C-
bus interface is already integrated on-chip
• Integrated addressing and data-transfer protocol
allow systems to be completely software-defined
• The same IC types can often be used in many
different applications
38 of 40
I2C designer benefits
• Design-time improves as designers quickly become familiar
with the frequently used functional blocks represented by I2C-
bus compatible ICs
• ICs can be added to or removed from a system without
affecting any other circuits on the bus
• Fault diagnosis and debugging are simple; malfunctions can
be immediately traced
• Software development time can be reduced by assembling a
library of reusable software modules
• The simple 2-wire serial I2C-bus minimizes interconnections so
ICs have fewer pins and there are fewer PCB tracks; resulting
in smaller and less expensive PCBs
39 of 40
I2C Manufacturers benefits
• The completely integrated I2C-bus protocol eliminates the
need for address decoders and other ‘glue logic’
• The multi-master capability of the I2C-bus allows rapid
testing/alignment of end-user equipment via external
connections to an assembly-line
• Increases system design flexibility by allowing simple
construction of equipment variants and easy upgrading to
keep design up-to-date
• The I2C-bus is a de facto world standard that is implemented
in over 1000 different ICs (Philips has > 400) and licensed to
more than 70 companies
40 of 40
Example – EEPROM (Part 24WC32)
• 400 KHz I2C Bus Compatible*
• 1.8 to 6 Volt Read and Write
Operation
• Cascadable for up to Eight Devices
• 32-Byte Page Write Buffer
• Self-Timed Write Cycle with Auto-
Clear
• Zero Standby Current
• Commercial, Industrial and
Automotive Temperature Ranges
 Write Protection– Entire
Array Protected When WP at
VIH
 1,000,000 Program/Erase
Cycles
 100 Year Data Retention
41 of 40
• 32KBit memory organise as 4K x 8bit
• 12 address bits (2^12 = 4K)
• Device Address :
• Writing
– Byte Write
– Page Write
– Write time 10mS maximum
– Write acknowledge Polling
• Reading
– Immediate/Current address reading
– Selective/Random Read
– Sequential Read
24WC32 Characteristics
42 of 40
Writing a Single Data Byte
After the STOP bit is receive the device internally programs
the EEPROM with the received data byte.
The programming can take up to 10ms (max.). The device
will be busy during this period and will not respond to its
slave address.
43 of 40
Writing Multiple Bytes (Page Write)
The bytes are received by the device and stored internally in a buffer
before being programmed into the EEPROM.
A maximum of 32 bytes (one page = 32 bytes) may be written at one
time for the 24WC32 device.
44 of 40
Reading EEPROM
Read current location
Read specified location – Note repeated start to
prevent loss of bus during read process.
45 of 40
Introduction - SPI
 What is it?
 Basic Serial Peripheral Interface (SPI)
 Capabilities
 Protocol
 Pro / Cons and Competitor
 Uses
 Conclusion
Serial Peripheral Interface
What is SPI?
• Serial Bus protocol
• Fast, Easy to use, Simple
• Everyone supports it
SPI Basics
 A communication protocol using 4 wires
 Also known as a 4 wire bus
 Used to communicate across small
distances
 Multiple Slaves, Single Master
 Synchronized
Capabilities of SPI
 Always Full Duplex
 Communicating in two directions at the same
time
 Transmission need not be meaningful
 Multiple Mbps transmission speed
 Transfers data in 4 to 16 bit characters
 Multiple slaves
 Daisy-chaining possible
Protocol
 Wires:
 Master Out Slave In (MOSI)
 Master In Slave Out (MISO)
 System Clock (SCLK)
 Slave Select 1…N
 Master Set Slave Select low
 Master Generates Clock
 Shift registers shift in and out data
Advantages and drawbacks
• SPI is a very simple communication protocol.
– It does not have a specific high-level protocol which means that there is almost no
overhead.
• Data can be shifted at very high rates in full duplex mode
– This makes it very simple and efficient in a
single master single slave scenario.
• The exchange itself has no pre-defined protocol. This makes it ideal for
data-streaming applications.
• Data can be transferred at high speed, often into the range of the tens of
megaHertz.
• The flipside is that there is no acknowledgment, no flow control, and the
master may not even be aware of the slave's presence / or absence.
– You could do “some” handshaking via software
Systems that use SPI
The question is of course, which peripheral types exist
and which can be connected to the host processor.
Peripheral types can be subdivided into the following
categories:
– Converters (ADC and DAC)
– Memories (EEPROM and FLASH)
– Real Time Clocks (RTC)
– Sensors (temperature, pressure)
– Others (signalmixer, potentiometer, LCD controller, UART, CAN
controller, USB controller, amplifier)
Concept of Master and Slave
• Master
– The component
that initiates the
transfer
– The component
that controls the
transfer
• Slave
– The component
that responds to
the transfer
Master / Slave concept
Slave Select (Chip Select)
• Master sends out
active low chip
select signal SS1,
then slave 1
responds
• Master sends out
active low chip
select signal SS2,
then slave 2
responds
FOR SAFETY – SELECT SIGNAL IS “ACTIVE LOW” NOT “ACTIVE HIGH”
Master / Slave concept
Master to Slave data movement
• Master sends out
information to slave on
MOSI wire
• Slave receives
information from the
master on MOSI wire
• Information (bits) is
clocked by SCLK signal.
– 1-bit, 1 clock tick
MOSI --MASTER OUT – SLAVE IN
Master / Slave concept
Slave to Master data movement
• Master receives
information from slave
on MISO wire
• Slave sends
information to the
master on MISO wire
• Information (bits) is
clocked by SCLK signal.
– 1-bit, 1 clock tick
MISO --MASTER IN – SLAVE OUT
Wires in Detail
 MOSI – Carries data out of Master to Slave
 MISO – Carries data from Slave to Master
 Both signals happen for every transmission
 SS_BAR – Unique line to select a slave
 SCLK – Master produced clock to
synchronize data transfer
Shifting Protocol
Master shifts out data to Slave, and shift in data from Slave
http://upload.wikimedia.org/wikipedia/commons/thumb/b/bb/SPI_8-bit_circular_transfer.svg/400px-SPI_8-bit_circular_transfer.svg.png
Diagram
Master and multiple independent
slaves
Master and multiple daisy-
chained slaves
Some wires have been renamed
Clock Phase (Advanced)
 Two phases and two polarities of clock
 Four modes
 Master and selected slave must be in same
mode
 Master must change polarity and phase to
communicate with slaves of different
numbers
Timing Diagram
Timing Diagram – Showing Clock polarities and phases
http://www.maxim-ic.com.cn/images/appnotes/3078/3078Fig02.gif
Pros and Cons
Pros:
 Fast and easy
 Fast for point-to-point connections
 Easily allows streaming/Constant data inflow
 No addressing/Simple to implement
 Everyone supports it
Cons:
 SS makes multiple slaves very complicated
 No acknowledgement ability
 No inherent arbitration
 No flow control
Uses
 Some Serial Encoders/Decoders,
Converters, Serial LCDs, Sensors, etc.
 Pre-SPI serial devices
 PPC
 PPC implements SPI well
 The bus of choice for communicating with
small peripherals
Conclusion
 SPI – 4 wire serial bus protocol
 MOSI MISO SS SCLK wires
 Full duplex
 Multiple slaves, One master
 Best for point-to-point streaming data
 Easily Supported
Universal Asynchronous
Receiver/Transmitter (UART)
7-66
UART (Universal Asynchronous Receiver/Transmitter)
• Most UARTS are full duplex – they have separate pins and
electronic hardware for the transmitter and receiver that
allows serial output and serial input to take place
simultaneously.
• Based around shift registers and a clock signal.
• UART clock determines baud rate
• UART frames the data bits with
– a start bit to provide synchronisation to the receiver
– one or more (usually one) stop bits to signal end of data
• Most UARTs can also optionally generate parity bits on
transmission and parity checking on reception to provide
simple error detection.
• UARTs often have receive and transmit buffers(FIFO's) as well
as the serial shift registers
7-67
UART - Transmitter
• Transmitter (Tx) - converts data from parallel
to serial format
– inserts start and stop bits
– calculates and inserts parity bit if required
– output bit rate is determined by the UART clock
Serial output
Parallel
data
UART Clock from
baud rate generator
Status information
7-68
Asynchronous serial transmission
1
0
Serial transmission is little endian (least significant bit first)
7-69
UART - The Receiver
– synchronises with transmitter using the falling edge of the start bit.
– samples the input data line at a clock rate that is normally a multiple of
baud rate, typically 16 times the baud rate.
– reads each bit in middle of bit period (many modern UARTs use a
majority decision of the several samples to determine the bit value)
– removes the start and stop bits, optional calculates and checks the
parity bit. Presents the received data value in parallel form.
Serial input
Status information
Parallel
data
UART Clock from
baud rate generator
7-70
Asynchronous serial reception
Idle
waiting for
start bit
Start bit
1
First data bit
etc.
0
Start detected
7-71
UARTs
• Usually used on simple systems
• Typically point to point communications
• Various different formats and protocols
• Normally 8-bit data format with one start and one stop bit
• Standards: E.g. RS232
– defines connector type, pin assignments, voltage levels, max bit rate,
cable length etc.
– Min. 3 pins – TxD, RxD, Ground
– Other pins for data flow control.
• Some common RS232 baud rates - 300,1200,9600,19200
• Handshaking
– None
– Hardware - RTS, CTS, etc - simple logic levels
The LPC23xx UARTs
• UART1 is identical to UART0/2/3, but with the
addition of a modem interface.
• 16 byte Receive and Transmit FIFOs.
• Register locations conform to ‘550 industry
standard.
• Receiver FIFO trigger points at 1, 4, 8, and 14
bytes.
• Built-in baud rate generator.
• Standard modem interface signals included 7-72
UART Registers
• Control registers
• Transmit
• Receive
• FIFO control
• Status
• Interrupt
• Interrupt enable
• Format control
• Baud rate control 7-73

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
SPI Bus Protocol
SPI Bus ProtocolSPI Bus Protocol
SPI Bus Protocol
 
SPI introduction(Serial Peripheral Interface)
SPI introduction(Serial Peripheral Interface)SPI introduction(Serial Peripheral Interface)
SPI introduction(Serial Peripheral Interface)
 
I2 c protocol
I2 c protocolI2 c protocol
I2 c protocol
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
The I2C Interface
The I2C InterfaceThe I2C Interface
The I2C Interface
 
Usb protocol
Usb protocol Usb protocol
Usb protocol
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
 
spi-180501092933-converted.pptx
spi-180501092933-converted.pptxspi-180501092933-converted.pptx
spi-180501092933-converted.pptx
 
MIPI DevCon Bangalore 2017: MIPI I3C Interface - Advanced Features
MIPI DevCon Bangalore 2017: MIPI I3C Interface - Advanced FeaturesMIPI DevCon Bangalore 2017: MIPI I3C Interface - Advanced Features
MIPI DevCon Bangalore 2017: MIPI I3C Interface - Advanced Features
 
I2C
I2CI2C
I2C
 
UART
UARTUART
UART
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
Lpc2148 i2c
Lpc2148 i2cLpc2148 i2c
Lpc2148 i2c
 
Slideshare - PCIe
Slideshare - PCIeSlideshare - PCIe
Slideshare - PCIe
 
I2C BUS PROTOCOL
I2C BUS PROTOCOLI2C BUS PROTOCOL
I2C BUS PROTOCOL
 
Uart
UartUart
Uart
 
Axi
AxiAxi
Axi
 
PCI express
PCI expressPCI express
PCI express
 

Destacado

Spi master core verification
Spi master core verificationSpi master core verification
Spi master core verification
Maulik Suthar
 
Karen Devine Ind NUI Seanad Proposals
Karen Devine Ind NUI Seanad ProposalsKaren Devine Ind NUI Seanad Proposals
Karen Devine Ind NUI Seanad Proposals
Dr. Karen Devine
 
Senior boletin-23rd-world-senior-championships-linz-austria-25-30-october-201...
Senior boletin-23rd-world-senior-championships-linz-austria-25-30-october-201...Senior boletin-23rd-world-senior-championships-linz-austria-25-30-october-201...
Senior boletin-23rd-world-senior-championships-linz-austria-25-30-october-201...
emiliomerayo
 

Destacado (20)

Satellite communication
Satellite communicationSatellite communication
Satellite communication
 
802 15-4 tutorial
802 15-4 tutorial802 15-4 tutorial
802 15-4 tutorial
 
Spi master core verification
Spi master core verificationSpi master core verification
Spi master core verification
 
Redes Industriais
Redes IndustriaisRedes Industriais
Redes Industriais
 
Mobile Communication
Mobile CommunicationMobile Communication
Mobile Communication
 
WSN protocol 802.15.4 together with cc2420 seminars
WSN protocol 802.15.4 together with cc2420 seminars WSN protocol 802.15.4 together with cc2420 seminars
WSN protocol 802.15.4 together with cc2420 seminars
 
Serial Peripherical Interface (SPI)
Serial Peripherical Interface (SPI)Serial Peripherical Interface (SPI)
Serial Peripherical Interface (SPI)
 
Dft,fft,windowing
Dft,fft,windowingDft,fft,windowing
Dft,fft,windowing
 
Serial peripheral interface
Serial peripheral interfaceSerial peripheral interface
Serial peripheral interface
 
Uart
UartUart
Uart
 
Diario Resumen 20140531
Diario Resumen 20140531Diario Resumen 20140531
Diario Resumen 20140531
 
Informe de Sostenibilidad Ambiental para el Sector Eléctrico 2015-20
Informe de Sostenibilidad Ambiental para el Sector Eléctrico 2015-20Informe de Sostenibilidad Ambiental para el Sector Eléctrico 2015-20
Informe de Sostenibilidad Ambiental para el Sector Eléctrico 2015-20
 
LVSC presentation: Building Partnerships for ESF, 8 May
LVSC presentation: Building Partnerships for ESF, 8 MayLVSC presentation: Building Partnerships for ESF, 8 May
LVSC presentation: Building Partnerships for ESF, 8 May
 
Cómo localizar un libro
Cómo localizar un libroCómo localizar un libro
Cómo localizar un libro
 
My zoo
My zooMy zoo
My zoo
 
Karen Devine Ind NUI Seanad Proposals
Karen Devine Ind NUI Seanad ProposalsKaren Devine Ind NUI Seanad Proposals
Karen Devine Ind NUI Seanad Proposals
 
Red de Jóvenes Trabajando por el Desarrollo Rural
Red de Jóvenes Trabajando por el Desarrollo RuralRed de Jóvenes Trabajando por el Desarrollo Rural
Red de Jóvenes Trabajando por el Desarrollo Rural
 
Edelweiss MC Presentation
Edelweiss MC PresentationEdelweiss MC Presentation
Edelweiss MC Presentation
 
Tsaafd Juan De Mairena 2
Tsaafd Juan De Mairena 2Tsaafd Juan De Mairena 2
Tsaafd Juan De Mairena 2
 
Senior boletin-23rd-world-senior-championships-linz-austria-25-30-october-201...
Senior boletin-23rd-world-senior-championships-linz-austria-25-30-october-201...Senior boletin-23rd-world-senior-championships-linz-austria-25-30-october-201...
Senior boletin-23rd-world-senior-championships-linz-austria-25-30-october-201...
 

Similar a Slow peripheral interfaces (i2 c spi uart)

Similar a Slow peripheral interfaces (i2 c spi uart) (20)

serial_busses_i2c.pptx
serial_busses_i2c.pptxserial_busses_i2c.pptx
serial_busses_i2c.pptx
 
Serial Busses.pptx
Serial Busses.pptxSerial Busses.pptx
Serial Busses.pptx
 
Peripherals and interfacing
Peripherals  and interfacingPeripherals  and interfacing
Peripherals and interfacing
 
Inter intergrated circuits-communication protocol
Inter intergrated circuits-communication protocolInter intergrated circuits-communication protocol
Inter intergrated circuits-communication protocol
 
Raspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication ProtocolsRaspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication Protocols
 
communication interfaces-Embedded real time systems
communication interfaces-Embedded real time systemscommunication interfaces-Embedded real time systems
communication interfaces-Embedded real time systems
 
Embedded networking
Embedded networkingEmbedded networking
Embedded networking
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
UNI T 6- SPI_I2C_Lecture8.pptx
UNI                    T 6- SPI_I2C_Lecture8.pptxUNI                    T 6- SPI_I2C_Lecture8.pptx
UNI T 6- SPI_I2C_Lecture8.pptx
 
I2 c communication protocol
I2 c communication protocolI2 c communication protocol
I2 c communication protocol
 
I2C
I2CI2C
I2C
 
I2C PRESENTATION.PPT
I2C PRESENTATION.PPTI2C PRESENTATION.PPT
I2C PRESENTATION.PPT
 
Networks-part17-Bridges-RP1.pptjwhwhsjshh
Networks-part17-Bridges-RP1.pptjwhwhsjshhNetworks-part17-Bridges-RP1.pptjwhwhsjshh
Networks-part17-Bridges-RP1.pptjwhwhsjshh
 
I2 c and mpu6050 basics
I2 c and mpu6050 basicsI2 c and mpu6050 basics
I2 c and mpu6050 basics
 
Deepu Kumar Shah.pptx
Deepu Kumar Shah.pptxDeepu Kumar Shah.pptx
Deepu Kumar Shah.pptx
 
MIPI DevCon 2016: A Developer's Guide to MIPI I3C Implementation
MIPI DevCon 2016: A Developer's Guide to MIPI I3C ImplementationMIPI DevCon 2016: A Developer's Guide to MIPI I3C Implementation
MIPI DevCon 2016: A Developer's Guide to MIPI I3C Implementation
 
dsPIC33FJ06GSXXX DSCs
dsPIC33FJ06GSXXX DSCsdsPIC33FJ06GSXXX DSCs
dsPIC33FJ06GSXXX DSCs
 
I2C BUS
I2C BUSI2C BUS
I2C BUS
 
Usart 8251
Usart 8251Usart 8251
Usart 8251
 
CMOS Logic Circuits
CMOS Logic CircuitsCMOS Logic Circuits
CMOS Logic Circuits
 

Más de PREMAL GAJJAR

Más de PREMAL GAJJAR (7)

Rs 232 interface
Rs 232 interfaceRs 232 interface
Rs 232 interface
 
Storage interface sata_pata
Storage interface sata_pataStorage interface sata_pata
Storage interface sata_pata
 
Hdmi
Hdmi Hdmi
Hdmi
 
Advance of usb
Advance of usb Advance of usb
Advance of usb
 
Network switching
Network switchingNetwork switching
Network switching
 
Introduction types of medium data_com
Introduction types of medium data_comIntroduction types of medium data_com
Introduction types of medium data_com
 
Framming data link layer
Framming data link layerFramming data link layer
Framming data link layer
 

Último

scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
HenryBriggs2
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 

Último (20)

Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 

Slow peripheral interfaces (i2 c spi uart)

  • 1. Low Speed Serial Interfaces SPI and I2C
  • 2. 2 of 40 The I2C Bus • What is the I2C Bus and what is it used for? • Bus characteristics • I2C Bus Protocol • Data Format • Typical I2C devices • Example device • Sample pseudo code
  • 3. 3 of 40 What is I2C • The name stands for “Inter - Integrated Circuit Bus” • A Small Area Network connecting ICs and other electronic systems • Originally intended for operation on one single board / PCB – Synchronous Serial Signal – Two wires carry information between a number of devices – One wire use for the data – One wire used for the clock • Today, a variety of devices are available with I2C Interfaces – Microcontroller, EEPROM, Real-Timer, interface chips, LCD driver, A/D converter
  • 4. 4 of 40 What is I2C used for? • Data transfer between ICs and systems at relatively low rates – “Classic” I2C is rated to 100K bits/second – “Fast Mode” devices support up to 400K bits/second – A “High Speed Mode” is defined for operation up to 3.4M bits/second • Reduces Board Space and Cost By: – Allowing use of ICs with fewer pins and smaller packages – Greatly reducing interconnect complexity – Allowing digitally controlled components to be located close to their point of use
  • 5. 5 of 40 I2C Bus Characteristics • Includes electrical and timing specifications, and an associated bus protocol • Two wire serial data & control bus implemented with the serial data (SDA) and clock (SCL) lines – For reliable operation, a third line is required: Common ground • Unique start and stop condition • Slave selection protocol uses a 7-Bit slave address – The bus specification allows an extension to 10 bits • Bi-directional data transfer • Acknowledgement after each transferred byte • No fixed length of transfer
  • 6. 6 of 40 I2C Bus Characteristics (cont’d) • True multi-master capability – Clock synchronization – Arbitration procedure • Transmission speeds up to 100Khz (classic I2C) • Max. line capacitance of 400pF, approximately 4 meters (12 feet) • Allows series resistor for IC protection • Compatible with different IC technologies
  • 7. 7 of 40 I2C Bus Definitions • Master: – Initiates a transfer by generating start and stop conditions – Generates the clock – Transmits the slave address – Determines data transfer direction • Slave: – Responds only when addressed – Timing is controlled by the clock line
  • 8. 8 of 40 I2C Bus Configuration Example
  • 9. 9 of 40 I2C Hardware Details • Devices connected to the bus must have an open drain or open collector output for serial clock and data signal • The device must also be able to sense the logic level on these pins • All devices have a common ground reference • The serial clock and data lines are connected to Vdd(typically +5V) through pull up resistors • At any given moment the I2C bus is: – Quiescent (Idle), or – in Master transmit mode or – in Master receive mode.
  • 10. 10 of 40 I2C Electrical Aspects • I2C devices are wire ANDed together. • If any single node writes a zero, the entire line is zero
  • 11. I2C Bus Configuration • 2-wire serial bus – Serial data (SDA) and Serial clock (SCL) • Half-duplex, synchronous, multi-master bus • No chip select or arbitration logic required • Lines pulled high via resistors, pulled down via open-drain drivers (wired-AND)
  • 12. I2C Protocol 1. Master sends start condition (S) and controls the clock signal 2. Master sends a unique 7-bit slave device address 3. Master sends read/write bit (R/W) – 0 - slave receive, 1 - slave transmit 4. Receiver sends acknowledge bit (ACK) 5. Transmitter (slave or master) transmits 1 byte of data
  • 13. I2C Protocol (cont.) 6. Receiver issues an ACK bit for the byte received 7. Repeat 5 and 6 if more bytes need to be transmitted. 8.a) For write transaction (master transmitting), master issues stop condition (P) after last byte of data. 8.b) For read transaction (master receiving), master does not acknowledge final byte, just issues stop condition (P) to tell the slave the transmission is done
  • 14. I2C Signals • Start – high-to-low transition of the SDA line while SCL line is high • Stop – low-to-high transition of the SDA line while SCL line is high • Ack – receiver pulls SDA low while transmitter allows it to float high • Data – transition takes place while SCL is slow, valid while SCL is high
  • 15. 15 of 40 Bit Transfer on the I2C Bus • In normal data transfer, the data line only changes state when the clock is low SDA SCL Data line stable; Data valid Change of data allowed
  • 16. 16 of 40 Start and Stop Conditions A transition of the data line while the clock line is high is defined as either a start or a stop condition. Both start and stop conditions are generated by the bus master The bus is considered busy after a start condition, until a stop condition occurs Start Condition Stop Condition SCL SCL SDASDA
  • 17. 17 of 40 I2C Addressing • Each node has a unique 7 (or 10) bit address • Peripherals often have fixed and programmable address portions • Addresses starting with 0000 or 1111 have special functions:- – 0000000 Is a General Call Address – 0000001 Is a Null (CBUS) Address – 1111XXX Address Extension – 1111111 Address Extension – Next Bytes are the Actual Address
  • 18. 18 of 40 MSB ACK LSB 7 – Bit Slave Address R / Wr First Byte in Data Transfer on the I2C Bus R/Wr 0 – Slave written to by Master 1 – Slave read by Master ACK – Generated by the slave whose address has been output.
  • 19. 19 of 40 I2C Bus Connections • Masters can be – Transmitter only – Transmitter and receiver • Slaves can be – Receiver only – Receiver and transmitter
  • 20. 20 of 40 Acknowledgements • Master/slave receivers pull data line low for one clock pulse after reception of a byte • Master receiver leaves data line high after receipt of the last byte requested • Slave receiver leaves data line high on the byte following the last byte it can accept Acknowledgement from receiver Transmitter releases SDA line during 9th clock pulse.
  • 21. 21 of 40 Acknowledgements • From Slave to Master Transmitter: – After address received correctly – After data byte received correctly • From Slave to Master Receiver: – Never (Master Receiver generates ACK) • From Master Transmitter to Slave: – Never (Slave generates ACK) • From Master Receiver to Slave: – After data byte received correctly
  • 22. 22 of 40 Negative Acknowledge • Receiver leaves data line high for one clock pulse after reception of a byte Not acknowledgement (NACK) from receiver Transmitter releases SDA line during 9th clock pulse.
  • 23. 23 of 40 Negative Acknowledge (Cont’d.) • From Slave to Master Transmitter: – After address not received correctly – After data byte not received correctly – Slave Is not connected to the bus • From Slave to Master Receiver: – Never (Master Receiver generates ACK) • From Master Transmitter to Slave: – Never (Slave generates ACK) • From Master Receiver to Slave: – After last data byte received correctly
  • 24. 24 of 40 Data Transfer on the I2C Bus • Start Condition • Slave address + R/W – Slave acknowledges with ACK • All data bytes – Each followed by ACK • Stop Condition ACK from Slave ACK from Receiver Remember : Clock is produced by Master Start Stop SCL SDA
  • 25. 25 of 40 Data Formats Master writing to a Slave AAA
  • 26. 26 of 40 Data Formats Cont’d. Master reading from a Slave : Master is Receiver of data and Slave is Transmitter of data. 1
  • 27. 27 of 40 Data Formats Cont’d. Combined Format  A repeated start avoids releasing the bus and therefore prevents another master from taking over the bus
  • 28. 28 of 40 Multi-master I2C Systems • Multimaster situations require two additional features of the I2C protocol • Arbitration: – Arbitration is the procedure by which competing masters decide final control of the bus – I2C arbitration does not corrupt the data transmitted by the prevailing master – Arbitration is performed bit by bit until it is uniquely resolved – Arbitration is lost by a master when it attempts to assert a high on the data line and fails
  • 29. 29 of 40 Arbitration Between Two Masters • As the data line is like a wired AND, a ZERO address bit overwrites a ONE • The node detecting that it has been overwritten stops transmitting and waits for the Stop Condition before it retries to arbitrate the bus
  • 30. 30 of 40 Error Checking • I2C defines the basic protocol and timing – Protocol errors are typically flagged by the interface – Timing errors may be flagged, or in some cases could be interpreted as a different bus event • Glitches (if not filtered out) could potentially cause: – Apparent extra clocks – Incorrect data – “Locked” bus • Microprocessors communicating with each other can add a checksum or equivalent
  • 31. 31 of 40 Bus Recovery • An I2C bus can be “locked” when: – A Master and a Slave get out of synch – A Stop is omitted or missed (possibly due to noise) – Any device on the bus holds one of the lines low improperly, for any reason – A shorted bus line • If SCL can be driven, the Master may send extra clocks until SDA goes high, then send a Stop. • If SCL is stuck low, only the device driving it can correct the problem.
  • 32. 32 of 40 Type of I2C Implementations • Byte Oriented Interface – Data is handled one byte at a a time – Processor interprets a status byte when an event occurs – For instance Philips 8xC554, 8xC591 • Bit Oriented Interface – Processor is involved in every bus event when the interface is not Idle • “Bit Banged” – Implemented completely in software on 2 regular I/O pins of the microcontroller – Works for single master systems – Not recommended for Slave devices or Multimaster systems
  • 33. 33 of 40 Available I2C Devices • Analog to Digital Converters (A/D, D/A): MMI functions, battery & converters, temperature monitoring, control systems • Bus Controller: Telecom, consumer electronics, automotive, Hi-Fi systems, PCs, servers • Bus Repeater, Hub & Expander: Telecom, consumer electronics, automotive, Hi-Fi systems, PCs, servers • Real Time Clock (RTC)/Calendar: Telecom, EDP, consumer electronics, clocks, automotive, Hi-Fi systems, FAX, PCs, terminals • DIP Switch: Telecom, automotive, servers, battery & converters, control systems • LCD/LED Display Drivers: Telecom, automotive instrument driver clusters, metering systems, POS terminals, portable items, consumer electronics
  • 34. 34 of 40 Available I2C Devices • General Purpose Input/Output (GPIO) Expanders and LED Display Control: Servers, keyboard interface, expanders, mouse track balls, remote transducers, LED drive, interrupt output, drive relays, switch input • Multiplexer & Switch: Telecom, automotive instrument driver clusters, metering systems, POS terminals, portable items, consumer electronics • Serial RAM/ EEPROM: Scratch pad/ parameter storage • Temperature & Voltage Monitor: Telecom, metering systems, portable items, PC, servers • Voltage Level Translator: Telecom, servers, PC, portable items, consumer electronics
  • 35. 35 of 40 End use • Telecom: Mobile phones, Base stations, Switching, Routers • Data processing: Laptop, Desktop, Workstation, Server • Instrumentation: Portable instrumentation, Metering systems • Automotive: Dashboard, Infotainment • Consumer: Audio/video systems, Consumer electronics (DVD, TV etc.)
  • 36. 36 of 40 Applications • There are some specific applications for certain types of I2C devices such as TV or radio tuners, but in most cases a general purpose I2C device can be used in many different applications because of its simple construction.
  • 37. 37 of 40 I2C designer benefits • Functional blocks on the block diagram correspond with the actual ICs; designs proceed rapidly from block diagram to final schematic • No need to design bus interfaces because the I2C- bus interface is already integrated on-chip • Integrated addressing and data-transfer protocol allow systems to be completely software-defined • The same IC types can often be used in many different applications
  • 38. 38 of 40 I2C designer benefits • Design-time improves as designers quickly become familiar with the frequently used functional blocks represented by I2C- bus compatible ICs • ICs can be added to or removed from a system without affecting any other circuits on the bus • Fault diagnosis and debugging are simple; malfunctions can be immediately traced • Software development time can be reduced by assembling a library of reusable software modules • The simple 2-wire serial I2C-bus minimizes interconnections so ICs have fewer pins and there are fewer PCB tracks; resulting in smaller and less expensive PCBs
  • 39. 39 of 40 I2C Manufacturers benefits • The completely integrated I2C-bus protocol eliminates the need for address decoders and other ‘glue logic’ • The multi-master capability of the I2C-bus allows rapid testing/alignment of end-user equipment via external connections to an assembly-line • Increases system design flexibility by allowing simple construction of equipment variants and easy upgrading to keep design up-to-date • The I2C-bus is a de facto world standard that is implemented in over 1000 different ICs (Philips has > 400) and licensed to more than 70 companies
  • 40. 40 of 40 Example – EEPROM (Part 24WC32) • 400 KHz I2C Bus Compatible* • 1.8 to 6 Volt Read and Write Operation • Cascadable for up to Eight Devices • 32-Byte Page Write Buffer • Self-Timed Write Cycle with Auto- Clear • Zero Standby Current • Commercial, Industrial and Automotive Temperature Ranges  Write Protection– Entire Array Protected When WP at VIH  1,000,000 Program/Erase Cycles  100 Year Data Retention
  • 41. 41 of 40 • 32KBit memory organise as 4K x 8bit • 12 address bits (2^12 = 4K) • Device Address : • Writing – Byte Write – Page Write – Write time 10mS maximum – Write acknowledge Polling • Reading – Immediate/Current address reading – Selective/Random Read – Sequential Read 24WC32 Characteristics
  • 42. 42 of 40 Writing a Single Data Byte After the STOP bit is receive the device internally programs the EEPROM with the received data byte. The programming can take up to 10ms (max.). The device will be busy during this period and will not respond to its slave address.
  • 43. 43 of 40 Writing Multiple Bytes (Page Write) The bytes are received by the device and stored internally in a buffer before being programmed into the EEPROM. A maximum of 32 bytes (one page = 32 bytes) may be written at one time for the 24WC32 device.
  • 44. 44 of 40 Reading EEPROM Read current location Read specified location – Note repeated start to prevent loss of bus during read process.
  • 46. Introduction - SPI  What is it?  Basic Serial Peripheral Interface (SPI)  Capabilities  Protocol  Pro / Cons and Competitor  Uses  Conclusion Serial Peripheral Interface
  • 47. What is SPI? • Serial Bus protocol • Fast, Easy to use, Simple • Everyone supports it
  • 48. SPI Basics  A communication protocol using 4 wires  Also known as a 4 wire bus  Used to communicate across small distances  Multiple Slaves, Single Master  Synchronized
  • 49. Capabilities of SPI  Always Full Duplex  Communicating in two directions at the same time  Transmission need not be meaningful  Multiple Mbps transmission speed  Transfers data in 4 to 16 bit characters  Multiple slaves  Daisy-chaining possible
  • 50. Protocol  Wires:  Master Out Slave In (MOSI)  Master In Slave Out (MISO)  System Clock (SCLK)  Slave Select 1…N  Master Set Slave Select low  Master Generates Clock  Shift registers shift in and out data
  • 51. Advantages and drawbacks • SPI is a very simple communication protocol. – It does not have a specific high-level protocol which means that there is almost no overhead. • Data can be shifted at very high rates in full duplex mode – This makes it very simple and efficient in a single master single slave scenario. • The exchange itself has no pre-defined protocol. This makes it ideal for data-streaming applications. • Data can be transferred at high speed, often into the range of the tens of megaHertz. • The flipside is that there is no acknowledgment, no flow control, and the master may not even be aware of the slave's presence / or absence. – You could do “some” handshaking via software
  • 52. Systems that use SPI The question is of course, which peripheral types exist and which can be connected to the host processor. Peripheral types can be subdivided into the following categories: – Converters (ADC and DAC) – Memories (EEPROM and FLASH) – Real Time Clocks (RTC) – Sensors (temperature, pressure) – Others (signalmixer, potentiometer, LCD controller, UART, CAN controller, USB controller, amplifier)
  • 53. Concept of Master and Slave • Master – The component that initiates the transfer – The component that controls the transfer • Slave – The component that responds to the transfer
  • 54. Master / Slave concept Slave Select (Chip Select) • Master sends out active low chip select signal SS1, then slave 1 responds • Master sends out active low chip select signal SS2, then slave 2 responds FOR SAFETY – SELECT SIGNAL IS “ACTIVE LOW” NOT “ACTIVE HIGH”
  • 55. Master / Slave concept Master to Slave data movement • Master sends out information to slave on MOSI wire • Slave receives information from the master on MOSI wire • Information (bits) is clocked by SCLK signal. – 1-bit, 1 clock tick MOSI --MASTER OUT – SLAVE IN
  • 56. Master / Slave concept Slave to Master data movement • Master receives information from slave on MISO wire • Slave sends information to the master on MISO wire • Information (bits) is clocked by SCLK signal. – 1-bit, 1 clock tick MISO --MASTER IN – SLAVE OUT
  • 57. Wires in Detail  MOSI – Carries data out of Master to Slave  MISO – Carries data from Slave to Master  Both signals happen for every transmission  SS_BAR – Unique line to select a slave  SCLK – Master produced clock to synchronize data transfer
  • 58. Shifting Protocol Master shifts out data to Slave, and shift in data from Slave http://upload.wikimedia.org/wikipedia/commons/thumb/b/bb/SPI_8-bit_circular_transfer.svg/400px-SPI_8-bit_circular_transfer.svg.png
  • 59. Diagram Master and multiple independent slaves Master and multiple daisy- chained slaves Some wires have been renamed
  • 60. Clock Phase (Advanced)  Two phases and two polarities of clock  Four modes  Master and selected slave must be in same mode  Master must change polarity and phase to communicate with slaves of different numbers
  • 61. Timing Diagram Timing Diagram – Showing Clock polarities and phases http://www.maxim-ic.com.cn/images/appnotes/3078/3078Fig02.gif
  • 62. Pros and Cons Pros:  Fast and easy  Fast for point-to-point connections  Easily allows streaming/Constant data inflow  No addressing/Simple to implement  Everyone supports it Cons:  SS makes multiple slaves very complicated  No acknowledgement ability  No inherent arbitration  No flow control
  • 63. Uses  Some Serial Encoders/Decoders, Converters, Serial LCDs, Sensors, etc.  Pre-SPI serial devices  PPC  PPC implements SPI well  The bus of choice for communicating with small peripherals
  • 64. Conclusion  SPI – 4 wire serial bus protocol  MOSI MISO SS SCLK wires  Full duplex  Multiple slaves, One master  Best for point-to-point streaming data  Easily Supported
  • 66. 7-66 UART (Universal Asynchronous Receiver/Transmitter) • Most UARTS are full duplex – they have separate pins and electronic hardware for the transmitter and receiver that allows serial output and serial input to take place simultaneously. • Based around shift registers and a clock signal. • UART clock determines baud rate • UART frames the data bits with – a start bit to provide synchronisation to the receiver – one or more (usually one) stop bits to signal end of data • Most UARTs can also optionally generate parity bits on transmission and parity checking on reception to provide simple error detection. • UARTs often have receive and transmit buffers(FIFO's) as well as the serial shift registers
  • 67. 7-67 UART - Transmitter • Transmitter (Tx) - converts data from parallel to serial format – inserts start and stop bits – calculates and inserts parity bit if required – output bit rate is determined by the UART clock Serial output Parallel data UART Clock from baud rate generator Status information
  • 68. 7-68 Asynchronous serial transmission 1 0 Serial transmission is little endian (least significant bit first)
  • 69. 7-69 UART - The Receiver – synchronises with transmitter using the falling edge of the start bit. – samples the input data line at a clock rate that is normally a multiple of baud rate, typically 16 times the baud rate. – reads each bit in middle of bit period (many modern UARTs use a majority decision of the several samples to determine the bit value) – removes the start and stop bits, optional calculates and checks the parity bit. Presents the received data value in parallel form. Serial input Status information Parallel data UART Clock from baud rate generator
  • 70. 7-70 Asynchronous serial reception Idle waiting for start bit Start bit 1 First data bit etc. 0 Start detected
  • 71. 7-71 UARTs • Usually used on simple systems • Typically point to point communications • Various different formats and protocols • Normally 8-bit data format with one start and one stop bit • Standards: E.g. RS232 – defines connector type, pin assignments, voltage levels, max bit rate, cable length etc. – Min. 3 pins – TxD, RxD, Ground – Other pins for data flow control. • Some common RS232 baud rates - 300,1200,9600,19200 • Handshaking – None – Hardware - RTS, CTS, etc - simple logic levels
  • 72. The LPC23xx UARTs • UART1 is identical to UART0/2/3, but with the addition of a modem interface. • 16 byte Receive and Transmit FIFOs. • Register locations conform to ‘550 industry standard. • Receiver FIFO trigger points at 1, 4, 8, and 14 bytes. • Built-in baud rate generator. • Standard modem interface signals included 7-72
  • 73. UART Registers • Control registers • Transmit • Receive • FIFO control • Status • Interrupt • Interrupt enable • Format control • Baud rate control 7-73