(3n4) SerialCommunication
(3n4) SerialCommunication
Communications
Steve Gunn
Hardware Communication
Sending data over a communication channel or bus
Serial One bit is sent at a time
Parallel Disadvantages
Pin Count
Integrated circuits cost increases with pin count.
Interconnect Density
Cable/board cost increases with conductor count.
Clock Skew (Timing Skew)
Signals take time to move down wires. Arrival times may be
different.
Crosstalk
Signals may interact due to undesired capacitive or
inductive coupling
3
Serpentine Routing
Ethernet
RS-232 (UART)
JTAG
I2C
SPI
FireWire
USB
Thunderbolt
MIDI
5
Resources Used
AVR Datasheet
Communication
AVR Libc
#include <avr/io.h>
#include <util/setbaud.h>
#include <util/twi.h>
6
SPI
I2C (TWI)
UART
32 I/O pins
Grouped as 4 ports
Each pin has a special
function
Or can be used as GPIO
Sec. 13 of AVR Datasheet
UART
Universal Asynchronous Receiver/Transmitter
UART Overview
End to end communication between two devices.
Speeds up to ~2M baud1 possible
High speeds need accurate timing and good signal integrity.
Two wires (TX and RX) for sending and receiving.
Additional line (CLK) for USART
Effectively RS-232 with logic voltage levels
Communication modes: Simplex, Duplex, Half-duplex
1. The baud rate is defined to be the transfer rate in bit per second (bps)
UART connection
Asynchronous
Device A
Device B
TX
RX
RX
TX
Synchronous
Device A
Device B
TX
RX
RX
TX
CLK
CLK
10
UART Frame
11
UART
12
13
14
16
17
18
SPI
Serial Peripheral Interface (Bus)
SPI Overview
End to end communication between two devices.
Multiple devices allowed on the bus.
One device operates as the Master.
Speeds up to 100MHz possible
High speeds need good signal integrity.
Four wires (SCLK, MOSI, MISO, /SS) sending and receiving.
Communication mode: Duplex
20
SPI connection
21
Mode
CPOL
CPHA
23
Slave Select
In general if only a single slave device is used, you may
connect the /SS pin on the slave to ground.
Daisy Chained
Normal configuration.
26
ADC/DAC
Digital Potentiometer
Accelerometers
Gyros
Magnetometers
EEPROM
...
27
2
IC
Inter-Integrated Circuit (Bus)
I2C Overview
End to end communication between two devices.
Multiple devices allowed on the bus (limited by the address
space and by the bus capacitance)
Distances limited to a few metres.
I2C connection
128
Unique addresses
I2C Operation
Four potential modes of operation for a given bus device:
master transmit master node sending to a slave
31
Source: http://www.best-microcontroller-projects.com/i2c-tutorial.html
33
Source: http://www.best-microcontroller-projects.com/i2c-tutorial.html
34
35
Digital Potentiometer
Accelerometers
Gyros
Magnetometer
EEPROM
...
36
JTAG
Joint Test Action Group
JTAG Overview
Similar to SPI with an additional mode pin (TMS)
Multiple devices allowed by daisy chaining.
Speeds up to 100MHz possible
Four wires (TCK, TDI, TDO, TMS)
Communication mode: Duplex
Use #1: device programming of firmware
Use #2: boundary scan
Use #3: hardware debugging (breakpoints and single step)
38
JTAG Chain
39
Source: http://www.jtag.com
40
Microcontrollers
CPLDs
FPGAs
Microprocessors
Not usually found on simpler devices such as sensors.
41