SPI and I2C Flashcards
(17 cards)
What are I2C and SPI
I2C and SPI are fast, synchronous comunication protocol that though relatively complex enable multiple devices to be connected
compare UART to I2C and SPI
▪ UART is slow
▪ UART allows only a limited number of devices
▪ UART is simple
▪ UART is asynchronous
what architecture does the I2C work on
Operates on a controller-target architecture
Two lines are:
* Serial Data (SDA): Line for controller and target to send and receive data
* Serial Clock (SCL): Clock signal line
advantages of I2C
Advantages:
▪ Allows multiple controllers and target peripherals
▪ Clock stretching
▪ 7 to 10 bit addressing (127+ devices)
▪ Two wires
▪ Synchronous
▪ Low power consumption
▪ Faster than serial ports (9600 baud = 9.6 kpbs)
▪ Data transmission acknowledgement
▪ Arbitration
▪ Variable data rates
▪ Acknowledgement/error detection
Disadvantages of I2C
Disadvantages:
▪ Half duplex
▪ Data overhead (12+ bits sent for every 8 bits of data)
▪ Speed not as fast as SPI (5 Mbps with Ultra Fast Mode)
Start condition for I2C
Controller sets SCL high (1) and pulls SDA low (0), which informs all peripherals that transmission is to start
Address Frame for I2C
Controller indicates which target peripheral is being sent data. MSB of 7 bit address sent first (27 (128)
possible addresses)
what is the ACK/NACK bit
Every 9th bit, target peripheral given control. If SDA does not go low (0) before 9th clock pulse we can infer that
transmission failed
what are the stop conditions for I2C
Defined by Low to High transition on SDA AFTER a low to high transition on SCL, with SCL staying high
afterwards. SDA should not change between SCL rising and subsequently falling, risk of false stop
I2C writing
When the controller writes to the target peripherals the information sent by the controller is in blue in above diagram,
information sent by the peripheral is orange. R/W control bit is 0
I2C reading
When the controller reads from the target peripherals the information sent by the controller is in blue in above
diagram, information sent by the peripheral is orange. R/W control bit is 1
what is the SPI
SPI is a 4 wire, full duplex synchronous serial communication mode which
uses a controller-target architecture
what is the architecture of SPI
A controller-target architecture means the controller is the controlling
device, with other devices called targets taking instruction from the
controller, in theory, you can have infinite targets but in reality, this is
limited by loading issues
what does SPI stand for
Serial Peripheral Interface
what does the controller do in SPI
- The Controller can initiate data transmission at any time by outputting
clock signal (SCLK) to synchronise Target - Only the Controller can generate clock signal
- The Target is synchronised on the falling or rising clock edge
Controller reads bits as received
The Controller can select clock polarity and
phase
Advantages of SPI
Advantages
▪ No start and stop bits – continuous stream of data, no overhead
▪ High data transmission rates (10 Mbps)
▪ Full duplex
Disadvantages of SPI
Disadvantages
▪ Four wires
▪ No error checking
▪ No data transmission acknowledgement
▪ Single Controller