Professional Documents
Culture Documents
Solution For Exams
Solution For Exams
2 wire communication
Vtg high=1,low=0
I2c multi master
It is multi master bus
So bus arbitration is required
If is traying to send logic one but hears logic 0, it immediatly
stops transmision and gives sender priority
Using 4 wires
Always full-duplex
Multiple Mbps transmition
Multiple slaves
Transfer data 4-16 bit character
Advantages
full-duplex communication
Higher throughput than i2c protocol
Not limited to 8-bit words in the case of bit transfering.
Arbitrary choise of message size,content,and purpuse
Simple and hardware interfacing
Typicaly lawer power requiremeents than i2c due to less
circuitry
Advantages
Simle to setup
electrically robust
Most microcontroller support
Easy to use
Only use 2 wires
No clock signal is necessary
Provide error detection by parity bit check
Cost and size will be much lesser compare to the paralel
communication
Disdvantages
No protocol level error correction
Fairly requires reference clock
Baud should match
No support for multiple master and slave
The size of the data frame is limited to a maximum of 9 bit.
Limited speed is the bottleneck for the application which
required higher data transmission rate.
Interrupts
It is a methed of creating a temporary halt during program
excution and allows peripheral(output) device to access
mpu(microprocesor unit)
Microprocesor unit response to that interrupt with interrupt
service routine ISR (short prog indicating how to handle the
interrupt(events that come into the program)).
The microprocesor jumps to ISR to service peripherals after it
microprocesor again continue to the main program
An interrupt is a condition that causes the microprocessor to
temporarily work on a different task, and then later return to its
previous task. Interrupts can be internal or external. Internal
interrupts, or "software interrupts," are triggered by a software
instruction and operate similarly to a jump or branch instruction.
An external interrupt, or a "hardware interrupt," is caused by an
external hardware module. As an example, many computer
systems use interrupt driven I/O, a process where pressing a key
on the keyboard or clicking a button on the mouse triggers an
interrupt. The processor stops what it is doing, it reads the input
from the keyboard or mouse, and then it returns to the current
program.
The grey bars represent the control flow. The top line is the
program that is currently running, and the bottom bar is the
interrupt service routine (ISR). Notice that when the interrupt
(Int) occurs, the program stops executing and the
microcontroller begins to execute the ISR. Once the ISR is
complete, the microcontroller returns to processing the
program where it left off.
Procedure that ensures that only one of the master dicide will
control the bus. This ensure that the transfer data does not get
corrupted.
Process to get the bus access
Related to SDA line
It is a multi master bus driving the bus symentanioully so
costantlly monitoring the bus continouslly start and stop
condition they can ditermine whethere the bus is idle(first) or
not
multiple master start transfer at the same time in this case only
one master will be win who ever send zero first is called
arbitration
Clock Synchronasation
Procedure where the clock signals of two or more device are
synchronized
What is UART?
UART stands for Universal Asynchronous Receiver Transmitter. At a
high-level, a UART is simply a microchip that enables communications
between a computing device (PC, embedded system, etc.) and other
equipment.
So, what exactly does this have to do with UART anyway? Simple,
UART chips are used to convert inbound serial data to parallel data for
the system to read and conversely converts outbound parallel data to
serial before sending it on to other systems. Worded differently, a UART
enables a system to act as a DTE (Data Terminal Equipment) Device.
Before we move onto SPI, let’s quickly cover a few other important
details about UART communication:
UART uses 2 wires: 1 for transmit (or Tx) and one for receive (or
Rx)
UART communication is asynchronous, meaning that it is not
synchronized using a clock
UART has a max communication distance of 15 meters
UART leverages shift registers to convert serial communication to
parallel communication
UART is commonly used as a “serial port” on computers or in
microcontrollers
UART supports full-duplex communication
ADVANTAGES
Only uses two wires
No clock signal is necessary
Has a parity bit to allow for error checking
The structure of the data packet can be changed as long as both
sides are set up for it
Well documented and widely used method
DISADVANTAGES
The size of the data frame is limited to a maximum of 9 bits
Doesn’t support multiple slave or multiple master systems
The baud rates of each UART must be within 10% of each other
What is SPI?
SPI (Serial Peripheral Interface) is a serial communication protocol
originally developed by Motorola that enables communication between
nearly any electronic device that supports clocked serial streams. SPI uses
a master-slave method for communication that enables high-speed data
streaming.
As opposed to just using two wires, SPI must use at least 4 wires. As
there can be multiple slave devices in an SPI implementation, the actual
amount of wires or traces used will be n+3 where n = the number of slave
devices in use.
SPI is synchronous
SPI is a simple protocol with little overhead
SPI supports full-duplex communication
SPI communication does not have a means for acknowledgment or
flow control
SPI does not use much board space
Hardware vs protocol
One of the biggest differences is that UART is a type of hardware while
SPI is a protocol. When you are dealing with the nuances of getting
things to work in an embedded system, this can be easy to overlook.
However, UART is an actual piece of hardware (a microchip) while SPI
is a protocol or specification for communication.
Number of pins
UARTs use just two pins while SPI devices need at least 4. When
designing a system this means that if pins/traces are scarce, SPI may not
be an attractive solution.
Communications speed
SPI is significantly faster than UART. In some cases, an SPI solution can
be three times faster than a UART solution.
Price
In any engineering endeavor, the cost of a given solution is a big driver of
choice. Generally speaking, SPI is cheaper than UART.
Asynchronous vs Synchronous
As you can tell from the descriptions of the two earlier, another major
difference when comparing UART vs SPI is UART communication is
asynchronous while SPI is synchronous.
Size
Generally speaking, SPI devices take up relatively less space than UART
chips. This means use cases where there is limited board space may be
better served by SPI.
For example, our SPI Development Kit enables developers to test target
devices as a master device, simulate a master device, program flash
devices that are SPI-based, and monitor an SPI bus with granularity down
to 20 nanoseconds.