Communication Protocol
Communication Protocol
UART means Universal Asynchronous Receiver Transmitter Protocol. UART is used for serial
communication without clock signal
.
before starting with the communication we need to define the data format and transmission speed.
NRZ encoding for data communication.
Start Bit
The UART data transmission line is normally held at a high voltage level when it’s not transmitting data. To start
the transfer of data, the transmitting UART pulls the transmission line from high to low for one clock cycle. When
the receiving UART detects the high to low voltage transition, it begins reading the bits in the data frame at the
frequency of the baud rate.
Data Frame
The data frame contains the actual data being transferred. It can be 5 bits up to 8 bits long if a parity bit is used. If
no parity bit is used, the data frame can be 9 bits long. In most cases, the data is sent with the least significant bit
first.
Parity
Parity describes the evenness or oddness of a number. The parity bit is a way for the receiving UART to tell if any
data has changed during transmission. Bits can be changed by electromagnetic radiation, mismatched baud rates,
or long distance data transfers. After the receiving UART reads the data frame, it counts the number of bits with a
value of 1 and checks if the total is an even or odd number. If the parity bit is a 0 (even parity), the 1 bits in the
data frame should total to an even number. If the parity bit is a 1 (odd parity), the 1 bits in the data frame should
total to an odd number. When the parity bit matches the data, the UART knows that the transmission was free of
errors. But if the parity bit is a 0, and the total is odd; or the parity bit is a 1, and the total is even, the UART knows
that bits in the data frame have changed.
Stop Bits
To signal the end of the data packet, the sending UART drives the data transmission line from a low voltage to a
high voltage for at least two bit durations.
UART is having serial communication, therefore, it has less speed. two lines for communication,
Can configure at different baud rates.
Start bit, stop bit, and the parity bit is other overhead.
we should configure both devices at the same speed because the clock signal is absent.
One master to one slave.
SPI Communication:
Ex: SD card reader modules, RFID card reader modules, and 2.4 GHz wireless transmitter/receivers.
Any number of bits can be sent or received in a continuous stream.
Maximum speed upto 10mbps.
MOSI (Master Output/Slave Input) – Line for the master to send data to the slave.
MISO (Master Input/Slave Output) – Line for the slave to send data to the master.
SCLK (Clock) – Line for the clock signal.
SS/CS (Slave Select/Chip Select) – Line for the master to select which slave to send data to.
The clock signal synchronizes the output of data bits from the master to the sampling of bits by the slave. One bit
of data is transferred in each clock cycle, so the speed of data transfer is determined by the frequency of the clock
signal. SPI communication is always initiated by the master since the master configures and generates the clock
signal.
The master can choose which slave it wants to talk to by setting the slave’s CS/SS line to a low voltage level. In
the idle, non-transmitting state, the slave select line is kept at a high voltage level. Multiple CS/SS pins may be
available on the master, which allows for multiple slaves to be wired in parallel. If only one CS/SS pin is present,
multiple slaves can be wired to the master by daisy-chaining.
SDA (Serial Data) – The line for the master and slave to send and
receive data.
SCL (Serial Clock) – The line that carries the clock signal.
Speed:
Standard mode: 100kbps
Fast Mode : 400kbps
High Speed Mode: 3.4mbps
Ultra Fast mode: 5mbps
Start Condition: The SDA line switches from a high voltage level to a low voltage level before the SCL line
switches from high to low.
Stop Condition: The SDA line switches from a low voltage level to a high voltage level after the SCL line
switches from low to high.
Address Frame: A 7 or 10 bit sequence unique to each slave that identifies the slave when the master
wants to talk to it.
Read/Write Bit: A single bit specifying whether the master is sending data to the slave (low voltage
level) or requesting data from it (high voltage level).
Addressing
I2C doesn’t have slave select lines like SPI, so it needs another way to let the slave know that data is
being sent to it, and not another slave. It does this by addressing. The address frame is always the first
frame after the start bit in a new message.
The master sends the address of the slave it wants to communicate with to every slave connected to it.
Each slave then compares the address sent from the master to its own address. If the address matches,
it sends a low voltage ACK bit back to the master. If the address doesn’t match, the slave does nothing
and the SDA line remains high.
Read/Write bit:
The address frame includes a single bit at the end that informs the slave whether the master wants to
write data to it or receive data from it. If the master wants to send data to the slave, the read/write bit
is a low voltage level. If the master is requesting data from the slave, the bit is a high voltage level.
Standard CAN ID: Uses an 11-bit identifier, allowing for 2,048 unique message IDs.
Extended CAN ID: Uses a 29-bit identifier, offering a significantly larger address space with 536,870,912
unique message IDs.
Start of Frame (SOF): Marks the beginning of the frame with a dominant bit, synchronizing all nodes to
the start of the message.
Arbitration Field:
Identifier: A unique value used to identify the message and determine its priority during arbitration.
RTR (Remote Transmission Request): Differentiates between data frames and remote frames (requests
data).
Control Field:
IDE (Identifier Extension): Indicates whether the identifier field is standard (11 bits) or extended (29
bits).
r (Reserved bit): Reserved for future use, should always be dominant.
DLC (Data Length Code): Specifies the number of bytes of data (0 to 8 bytes).
Data Field: Contains the actual payload data, from 0 to 8 bytes.
CRC Field:
CRC Sequence: Holds the Cyclic Redundancy Check value for error detection.
CRC Delimiter (DEL): A single recessive bit separating the CRC field from the acknowledgment field.
ACK Field:
ACK Slot: Indicates successful receipt of the message by setting a dominant bit.
ACK Delimiter (DEL): Follows the acknowledgment bit and is recessive.
End of Frame (EOF): Consists of seven recessive bits marking the end of the frame.
Interframe Space (ITM): A period of bus inactivity between consecutive data frames ensuring the bus is
idle before the next message.
To add termination resistors, connect a 120-ohm resistor between the CAN_H and CAN_L lines at both
ends of the CAN bus. This ensures that the electrical signals are properly terminated, preventing
reflections and maintaining signal integrity.
Max Speed:
100 meters (330 ft) at 500 kbit/s
200 meters (650 ft) at 250 kbit/s
500 meters (1600 ft) at 125 kbit/s
6 kilometers (20000 ft) at 10 kbit/s
SuperSpeed+
Speed: 12 Mbps
(SS+): 10 Gbps
Type A, Type B,
Same as USB 1.x,
Connector Types Mini-USB, Micro- Same as USB 2.0
plus Type C
USB
Backward
Yes Yes Yes
Compatibility
USB 3.x includes USB 3.0, USB 3.1, and USB 3.2. The USB 3.2 standard also includes two additional transfer
modes: SuperSpeed+ (SS+) and SuperSpeed+ (SS++) which can transfer data at up to 20Gbps and 40Gbps
respectively.