PART-B
1. Input/Output (I/O) Ports and Buses in Embedded Systems
In embedded systems, I/O ports are interfaces used to communicate with external devices or
peripherals. They allow the microcontroller or microprocessor to send or receive data from sensors,
actuators, displays, communication modules, etc.
There are two types of ports :
1. Internal Port: It connects the system's motherboard to internal devices like hard disk, CD
drive, internal Bluetooth, etc.
2. External Port: It connects the system's motherboard to external devices like a mouse, printer,
USB, etc.
Types of ports
Some important types of ports are as per follows:
1. Serial Port :
● Used for external modems and older computer mouse
● Two versions-9pin,25pin
● Data travels at 115 kilobits per second
2. Parallel Port :
● Used for scanners and printers
● 25 pin model
3. Universal Serial Bus (or USB) Port :
● It can connect all kinds of external USB devices such as external hard disks, printers,
scanners, mouse, keyboards, etc.
● Data travels at 12 megabits per second.
4. Firewire Port :
● Transfers large amounts of data at a very fast speed.
● Connects camcorders and video equipment to the computer.
● Data travels at 400 to 800 megabits per second.
5. Ethernet Port :
● Connects to a network and high-speed Internet.
● Data travels at 10 megabits to 1000 megabits per second depending upon the network
bandwidth.
2. INPUT/OUTPUT BUSES:
What is an I/O Bus?
An I/O bus is a communication system within an embedded system that transfers data between the
microcontroller/processor and peripheral devices such as sensors, actuators, memory, displays, and
other hardware modules.
● It’s like a highway or a set of lanes over which data travels.
● Buses allow multiple devices to communicate without needing separate direct connections to
every device.
● It handles three types of signals:
o Data signals (the actual information being transferred)
o Address signals (to specify which device or memory location is involved)
o Control signals (to manage timing and operation mode — e.g., read/write
commands)
2. Why Are I/O Buses Important?
● They reduce wiring complexity by enabling shared communication lines.
● They allow multiple devices to connect to the processor.
● They provide organized data flow and control in the system.
● They are critical for embedded systems to interface with external peripherals efficiently.
3. Bus Architecture Components
An I/O bus usually consists of:
a) Data Bus
● Carries actual data.
● Width can be 8, 16, 32, or 64 bits depending on the system.
● Wider buses mean more data transferred per cycle.
b) Address Bus
● Carries address info specifying target peripheral or memory location.
● Width defines the maximum addressable locations.
For example, a 16-bit address bus can address 216=65,5362^{16} = 65,536216=65,536
locations.
c) Control Bus
● Carries control signals such as:
o Read (RD)
o Write (WR)
o Chip select (CS)
o Interrupt requests (IRQ)
● These signals coordinate the timing and direction of data transfers.
4. Types of I/O Buses
A. Parallel Bus
● Transfers multiple bits simultaneously on multiple lines.
● Usually contains separate lines for data, address, and control.
● Example: An 8-bit data bus transfers 8 bits at once.
How it works:
● The CPU puts an address on the address bus.
● Sets control signals (e.g., Read/Write).
● Data is transferred over the data bus.
● All lines operate simultaneously.
Advantages:
● High data throughput (multiple bits at once).
● Fast access times.
Disadvantages:
● Requires many pins and wires.
● Complex PCB layout.
● Signal timing and synchronization are critical (skew issues).
● Not ideal for long distances.
B. Serial Bus
● Transfers data one bit at a time (bit-serial).
● Fewer wires required — simpler physical connections.
● Data bits sent sequentially, one after another.
3. SERIAL COMMUNICATION PROTOCOLS:
Serial communication protocols define how data is transmitted bit by bit over a single
communication channel between two or more devices. Unlike parallel communication (where
multiple bits are sent simultaneously over multiple wires), serial communication sends bits
sequentially, one after another, over a single or a few wires.
These protocols establish standardized rules and conventions to ensure data is exchanged reliably,
accurately, and efficiently. They cover aspects such as:
● How bits are framed (start, stop, parity bits)
● Timing and clock synchronization
● Data rates (baud rate)
● Error detection and correction
● Device addressing and handshaking
Types of Serial Communication Protocols
1. Generic Protocols
These are widely used protocols adaptable to many applications and hardware.
UART (Universal Asynchronous Receiver/Transmitter)
● Type: Asynchronous serial protocol (no clock signal).
● Key Features:
o Data sent bit-by-bit with start and stop bits.
o Both transmitter and receiver agree on baud rate (e.g., 9600 bps).
o Typically uses 2 wires: TX (transmit) and RX (receive).
● Usage: Simple communication between microcontrollers, computers, GPS modules,
Bluetooth modules.
● Pros:
o Simple hardware, minimal wiring.
o Good for short-distance communication.
● Cons:
o No clock means timing must be precise and matched.
o No addressing for multi-device communication.
SPI (Serial Peripheral Interface)
● Type: Synchronous serial protocol (uses clock).
● Key Features:
o Full-duplex communication (send and receive simultaneously).
o Uses 4 main lines: MOSI, MISO, SCLK (clock), and SS (slave select).
o Master generates clock; slaves respond accordingly.
● Usage: Communication with sensors, memory chips, LCD displays, and other peripherals.
● Pros:
o High speed.
o Simple and flexible.
o Supports multiple slaves using separate slave select lines.
● Cons:
o Requires more wires than some other serial protocols.
o No formal addressing beyond SS lines.
I2C (Inter-Integrated Circuit)
● Type: Synchronous serial protocol with clock.
● Key Features:
o Uses only 2 lines: SDA (data) and SCL (clock).
o Supports multiple masters and multiple slaves on the same bus.
o Devices are addressed by unique 7-bit or 10-bit addresses.
o Half-duplex communication (send or receive at a time).
● Usage: Connecting microcontrollers to EEPROMs, RTCs, sensors, and other ICs on PCBs.
● Pros:
o Minimal wiring for multiple devices.
o Standardized and widely supported.
● Cons:
o Slower than SPI (standard 100 kbps to 1 Mbps).
o Bus capacitance limits bus length and speed.
RS-232
● Type: Asynchronous serial communication standard.
● Key Features:
o Used historically for connecting computers to modems, printers, and terminals.
o Voltage levels differ from TTL logic, making it suitable for longer cable distances.
● Usage: Legacy PC serial ports, some industrial equipment.
● Pros:
o Simple and robust.
o Good for moderate distances (up to 15 meters).
● Cons:
o Only point-to-point (no multi-device bus).
o Bulky connectors and outdated for modern devices.
Modbus
● Type: Industrial serial communication protocol.
● Key Features:
o Master-slave architecture.
o Uses RS-232, RS-485 physical layers.
o Used extensively for industrial automation.
● Usage: Communication between PLCs, sensors, and actuators.
● Pros:
o Standardized industrial protocol.
o Simple and robust.
● Cons:
o Limited data throughput compared to modern protocols.
2. Application-Specific Protocols
Protocols tailored for specific industries or applications.
CAN (Controller Area Network)
● Type: Multi-master serial bus, differential signaling.
● Key Features:
o Used primarily in automotive and industrial control.
o Message-oriented, with unique identifiers for each message rather than node
addresses.
o Built-in error detection and fault confinement.
● Usage: Communication between vehicle ECUs, industrial machinery.
● Pros:
o Very robust and reliable.
o Supports many nodes on the bus.
● Cons:
o Complex hardware and protocol stack.
o Moderate data rate (up to 1 Mbps).
LIN (Local Interconnect Network)
● Type: Low-cost, single-wire serial network.
● Key Features:
o Typically used as a sub-bus within automotive networks.
o Lower speed and complexity than CAN.
● Usage: Controlling sensors, switches, and actuators in cars.
● Pros:
o Simple and inexpensive.
● Cons:
o Low data rates (~20 kbps).
USB (Universal Serial Bus)
● Type: Complex, layered protocol supporting plug-and-play.
● Key Features:
o Supports multiple device types and power supply.
o High speed (up to 20 Gbps in latest versions).
o Uses differential signaling on two wires plus power and ground.
● Usage: Computer peripherals, smartphones, cameras, and many consumer devices.
● Pros:
o Standardized, supports hot plugging.
o High bandwidth.
● Cons:
o Complex hardware and software stack.
Serial ATA (SATA)
● Type: Serial protocol for data transfer to storage devices.
● Key Features:
o High-speed serial interface connecting hard drives and SSDs to the motherboard.
o Uses differential signaling.
● Usage: Internal PC storage connections.
● Pros:
o High data rates, hot-swappable.
● Cons:
o Not a general-purpose communication protocol.
1-Wire
● Type: Simple, low-speed, single-wire protocol.
● Key Features:
o Uses a single data line and ground.
o Devices have unique 64-bit addresses.
o Supports parasitic power from data line.
● Usage: Temperature sensors (like DS18B20), simple identification devices.
● Pros:
o Very low cost and wiring.
● Cons:
o Low speed (~16 kbps).
o Limited to short distances.
Ethernet (in Serial Context)
● Type: Often considered parallel, but data is serialized at the physical layer.
● Usage: Network communication, sometimes used in embedded systems as serial
communication over IP.
● Pros:
o High speed, widespread.
● Cons:
o Requires complex stack and hardware.
FlexRay
● Type: High-speed deterministic serial communication.
● Key Features:
o Used in automotive safety systems and advanced control.
o Supports fault tolerance and time-triggered communication.
● Usage: Next-generation automotive communication.
● Pros:
o High reliability and speed.
● Cons:
o Expensive and complex.
4. RS232:
RS232 is an Interface and the protocol between DTE(data terminal equipment) and DCE(data
communication equipment) using serial binary data exchange, where C represents revised version of
RS-232 and RS-232C itself describes the physical and electrical characteristics of serial
communication for data transfer. Universal Asynchronous Data Receiver & Transmitter (UART),
attached in a motherboard, used in connection with RS232 for transmitting data to any serial device
like modem or printer from its DTE interface.
Electrical Specifications of RS232C for Data Transfer
Voltages
There can be two states in the signal level of RS232C pins.
● Mark state - It is the high bit which is represented by binary 1 and have negative voltages. Its
voltage limits for transmitting signal ranges from -5 to -15V. Its voltage limits for receiving
signals ranges from -3 to -25V.
● Space state - It is the low bit which is represented by binary 0 and have positive voltages. Its
voltage limits for transmitting signal ranges from +5 to +15V. Its voltage limits for receiving
signals ranges from +3 to +25V.
Cables and Wires
The maximum cable length for RS232C is equals to 15.24 meters or equal to the capacitance of
2500pF. Limits for the impedance of wires ranges from 3 ohms to 7 ohms.
Data and Slew Rates
Rate of data transmission through RS232C is up to 20Kbps. The rate of change in signal levels ie.
slew rate is up to 30V/microsecond.
Current
Maximum current rating is 3 Amps at the maximum operating voltage of 250V AC.
Pins and Working of RS232C
RS232C requires 25 pins connector for connecting DTE and DCE. Here is the list of pins and signals
of RS232C and the connection between DTE and DCE using drivers and receivers.
● TXD & RXD -
Transmit Data and Receive Data on the DTE are the serial data lines. These lines have
opposite functions on a DCE. TXT sends outgoing data to DCE. RXD receives incoming data
from DTE.
● RTS & CTS -
Transmitter activates the Request to Send when it requires to transmit data over the line. The
line itself gets deactivated when the communication stops. Receiver activates the Clear To
Send to tell the transmitter whether it is ready or not to receive the data. It remains active
during the transmission.
● DTR & DSR -
Through the Data Terminal Ready line, DTE informs the DCE that it is in online mode and
the process of communication can occur. The main task of Data Set Ready signal is to inform
that DCE is ready for communication.
● DCD -
DCE activates the Data Carrier Detect in order to show that it has been connected to DTE.
● RI -
When an incoming call on the telephone line is detected by DCE, then the Ring Indicator gets
activates.
Handshaking
Before the actual data transfer, signals are transmitted from DTE to DCE in order to make connections
by a process known as handshaking. Following is the sequence of signal handshaking:
● Initially, the computer activates RTS signal to modem when a data is transferred from
computer to modem.
● Modem in turn activates the DCD and then the CTS gets activated.
● Computer then sends data on TXD. After the data transmission is completed, the computer
deactivates the RTS which causes the modem to deactivate CTS.
Applications
● It is used in establishing communication between the computer and embedded systems.
● Due to its lower costs, It plays a vital role in CNC machines and servo controllers
● Some microcontroller boards and PLC machines use RS232C.
● RS232C ports are used to communicate in headless systems in the absence of any network
connection.
● Many Computerized Numerical Control Systems are contains RS232C port.
Limitations
● It cannot be used for chip to chip or chip to sensor device communication
● It degrades the performance of the system in the presence of noise and requires shorter cables
due to having common grounds between DTE and DCE
● The cost of system increases as RS232C interface needs separate transceiver chips.
● Its performance degrades to short distances only when transfer speed is high.
5. CAN PROTOCOL
The Controller Area Network (CAN) protocol is a communication protocol that was developed for use
in the automotive industry, but has also been used in other industries such as industrial automation and
medical equipment. It is a serial communication protocol that uses a multi-master, distributed control
system. This means that any device on the network, called a node, can initiate communication and all
other nodes on the network can participate in the communication. The protocol provides a way for
devices to share information and synchronize their actions without the need for a central controller.
The protocol uses a collision detection and arbitration method to prevent multiple nodes from
transmitting at the same time and ensure that only one node can transmit at a time.
Why CAN?
The CAN protocol was developed for use in the automotive industry to address several challenges that
arose as cars became more complex and incorporated more electronic systems. Some of the key
reasons for why the CAN protocol was developed include ?
● High reliability ? The CAN protocol is designed to be robust and fault-tolerant, making it
suitable for use in critical systems such as the engine control and braking systems in a car.
● Low cost ? The CAN protocol uses a simple and efficient signaling method that allows for
low-cost implementation, which is particularly important in the automotive industry where
costs are a major concern.
● Low weight and minimal wiring ? The CAN protocol uses a two-wire bus, which reduces
the amount of wiring needed in a car and makes the vehicle lighter, which can lead to
improved fuel efficiency.
● Scalability ? The CAN protocol is designed to support a large number of devices on a
network, making it easy to add new devices or remove existing ones as needed.
● Multi-master capability ? The ability of the any device (node) to initiate communication in
the network, this allows different systems to communicate and act upon their requirement and
also enables distributed control which is a major feature of this protocol.
Applications of CAN protocol
The Controller Area Network (CAN) protocol is widely used in a variety of applications, including ?
● Automotive ? The CAN protocol was originally developed for use in the automotive industry
and is used in a wide variety of systems in modern cars, including engine control,
transmission control, anti-lock brakes, and body electronics.
● Industrial automation ? The CAN protocol is used in industrial automation systems to allow
devices to communicate and coordinate their actions, such as controlling motors, sensors, and
other equipment.
● Medical equipment ? The CAN protocol is used in medical equipment to control various
functions and to transmit data between devices. For example, patient monitoring systems use
the protocol to transmit patient vital signs data between devices
● Avionics ? The protocol is used in avionics to control and monitor various systems such as
engine, navigation, and flight control systems.
● Building automation ? The protocol is used in building automation systems to control and
monitor various systems such as heating, ventilation, air conditioning (HVAC), lighting, and
security systems.
● Robotics ? The protocol is used in Robotics to control and monitor various systems such as
motors, sensors, and other equipment, thus allowing the robots to communicate and
coordinate their actions.
CAN Framing
In the Controller Area Network (CAN) protocol, a message is transmitted using a specific format
called a frame. The frame consists of several fields that contain information about the message, such
as the source address, destination address, and data payload.
The basic format of a CAN frame includes ?
● Start of Frame (SOF) ? Identifies the start of a frame.
● Identifier (ID) ? A unique 11 or 29-bit number that identifies the message.
● Remote Transmission Request (RTR) ? Indicates whether the frame is a data frame (0) or a
remote frame (1) requesting data.
● Identifier Extension (IDE) ? Indicates whether the ID field is 11-bit (0) or 29-bit (1)
● Data Length Code (DLC) ? Indicates the length of the data payload in bytes.
● Data ? The payload of the message, which can be up to 8 bytes.
● Cyclic Redundancy Check (CRC) ? A checksum used to detect errors in the frame.
● Acknowledge Slot (ACK) ? Acknowledge of the message transmission by the receiver node.
● End of Frame (EOF) ? Identifies the end of the frame.
A message is transmitted as a series of bits on the bus, with the most significant bit (MSB) transmitted
first. Once a message has been transmitted, all nodes on the network will receive the message, but
only the node with the matching identifier will process it.
CAN Layered Architecture
The Controller Area Network (CAN) protocol has a layered architecture that is designed to separate
the different responsibilities of the protocol. The CAN protocol is typically divided into five layers ?
● Physical Layer ? This layer is responsible for the physical transmission of bits over the
communication medium, such as a cable or wireless link. It defines the electrical, mechanical,
and operational specifications for the interface between the nodes and the communication
medium.
● Data Link Layer ? This layer is responsible for providing reliable data transfer between the
nodes. It includes error detection and correction mechanisms, such as bit stuffing and cyclic
redundancy check (CRC). It also manages the arbitration process to ensure that only one node
can transmit at a time and manages the Acknowledgement of the message.
● Network Layer ? This layer is responsible for providing a common communication format
and addressing scheme for all nodes on the network. It defines the format of the messages,
including the identifier, data payload, and priority.
● Transport Layer ? This layer defines the rules for message transmission and reception, such
as message fragmentation and retransmission, flow control, and error handling.
● Application Layer ? This layer defines the services and interfaces that are available to the
application, such as sending and receiving messages, and monitoring the status of the
network. It also provides an interface for the Application layer.
6. Serial Peripheral Interface (SPI)
Serial Peripheral Interface (SPI) is a high-speed, full-duplex, synchronous serial
communication protocol primarily used to transfer data between microcontrollers and small
peripheral devices like sensors, EEPROMs, SD cards, and displays.
Key Characteristics of SPI
Feature Description
Type Synchronous Serial Communication
Data Transfer Full-duplex
Speed High (typically up to tens of Mbps)
Number of Wires 4 (standard), but can be more with multiple slaves
Master/Slave Architecture One master, one or more slaves
Clocked Communication Yes – driven by the master
SPI Pin Configuration
A standard SPI interface consists of four main signal lines:
Pin Name Description
1 MOSI (Master Out Slave In) Carries data from master to slave
2 MISO (Master In Slave Out) Carries data from slave to master
3 SCLK (Serial Clock) Clock signal generated by the master
4 SS/CS (Slave Select/Chip Select) Used by master to enable/disable specific slave
📌 Step-by-step
SPI Working
Process:
Master initiates communication:
1.
o The master device pulls the SS/CS line LOW for the target slave.
2. Clock signal generation:
o The master provides a clock signal on the SCLK line.
3. Data transmission:
o Master sends data via MOSI line.
o Slave simultaneously sends data back via MISO line (full-duplex).
4. Bit synchronization:
o Data is transferred bit by bit on the rising/falling edge of the clock.
5. Communication end:
o Master pulls the SS/CS line HIGH, ending the transmission.
Data Transmission Modes
SPI supports 4 modes based on Clock Polarity (CPOL) and Clock Phase (CPHA):
Mode CPOL CPHA Description
0 0 0 Data sampled on rising edge, clock idle low
1 0 1 Data sampled on falling edge, clock idle low
2 1 0 Data sampled on falling edge, clock idle high
3 1 1 Data sampled on rising edge, clock idle high
Advantages of SPI
🔄
Advantage Explanation
⚡
Full-duplex Simultaneous two-way data transfer
🧰
High-speed Faster than I2C or UART
🎛
Simple hardware Fewer control lines and logic
️Flexible data
Can transfer 8, 16, 32 bits or more
length
Limitations of SPI
⛓️
Limitation Explanation
🔌
No built-in addressing Must use separate CS lines for each slave
📏
More pins required More wires compared to I2C (especially with multiple slaves)
🧠
Short distance Best for short-range, on-board communications
No error checking Unlike protocols like UART with parity, SPI lacks built-in error detection
Common Applications
● Flash memory (e.g., SPI NOR Flash)
● SD cards
● LCD displays
● Temperature sensors (like MAX6675)
● Analog-to-Digital Converters (ADCs)
● Audio DACs
7. Inter Integrated Circuits (I2C)
I2C stands for Inter-Integrated Circuit. It is a bus interface connection protocol
incorporated into devices for serial communication. It was originally designed by Philips
Semiconductor in 1982. Recently, it is a widely used protocol for short-distance
communication. It is also known as Two Wired Interface(TWI).
Working of I2C Communication Protocol
It uses only 2 bi-directional open-drain lines for data communication called SDA and SCL.
Both these lines are pulled high.
Serial Data (SDA) : Transfer of data takes place through this pin.
Serial Clock (SCL) : It carries the clock signal.
I2C operates in 2 modes
● Master mode
● Slave mode
Each data bit transferred on SDA line is synchronized by a high to the low pulse of each
clock on the SCL line.
According to I2C protocols, the data line can not change when the clock line is high, it can
change only when the clock line is low. The 2 lines are open drain, hence a pull-up resistor is
required so that the lines are high since the devices on the I2C bus are active low. The data is
transmitted in the form of packets which comprises 9 bits. The sequence of these bits are -
1. Start Condition: 1 bit
2. Slave Address: 8 bit
3. Acknowledge: 1 bit
Steps of I2C Data Transmission?
Here are the steps of I2C (Inter-Integrated Circuit) data transmission
● Start Condition: The master device sends a start condition by pulling the SDA line low
while the SCL line is high. This signals that a transmission is about to begin.
● Addressing the Slave: The master sends the 7-bit address of the slave device it wants to
communicate with, followed by a read/write bit. The read/write bit indicates whether it
wants to read from or write to the slave.
● Acknowledge Bit (ACK): The addressed slave device responds by pulling the SDA line
low during the next clock pulse (SCL). This confirms that the slave is ready to
communicate.
● Data Transmission: The master or slave (depending on the read/write operation) sends
data in 8-bit chunks. After each byte, an ACK is sent to confirm that the data has been
received successfully.
● Stop Condition: When the transmission is complete, the master sends a stop condition by
releasing the SDA line to high while the SCL line is high. This signals that the
communication session has ended.
I2C Packet Format
In the I2C communication protocol, the data is transmitted in the form of packets. These
packets are 9 bits long, out of which the first 8 bits are put in SDA line and the 9th bit is
reserved for ACK/NACK i.e. Acknowledge or Not Acknowledge by the receiver.
START condition plus address packet plus one more data packet plus STOP
condition collectively form a complete Data transfer.
Features of I2C Communication Protocol
● Half-duplex Communication Protocol -
Bi-directional communication is possible but not simultaneously.
● Synchronous Communication -
The data is transferred in the form of frames or blocks.
● Can be configured in a multi-master configuration.
● Clock Stretching -
The clock is stretched when the slave device is not ready to accept more data by holding
the SCL line low, hence disabling the master to raise the clock line. Master will not be
able to raise the clock line because the wires are AND wired and wait until the slave
releases the SCL line to show it is ready to transfer next bit.
● Arbitration -
I2C protocol supports multi-master bus system but more than one bus can not be used
simultaneously. The SDA and SCL are monitored by the masters. If the SDA is found
high when it was supposed to be low it will be inferred that another master is active and
hence it stops the transfer of data.
● Serial transmission -
I2C uses serial transmission for transmission of data.
● Used for low-speed communication.
Advantages of I2C Communication Protocol
● Can be configured in multi-master mode.
● Complexity is reduced because it uses only 2 bi-directional lines (unlike SPI
Communication).
● Cost-efficient.
● It uses ACK/NACK feature due to which it has improved error handling capabilities.
● Fewer Wires: Only two wires are needed, making it easier to set up.
● Multiple Devices: You can connect many devices to the same bus.
● Simple Communication: It’s relatively easy to program and use.
Disadvantages of I2C Communication Protocol
● Speed Limitations: I2C is slower compared to some other protocols like SPI.
● Distance: It’s not suitable for long-distance communication.
● Half-duplex communication is used in the I2C communication protocol.
8. Comparison between I2C and SPI Communication Protocols
I2C Communication SPI Communication
Features
Protocol Protocol
4 (MOSI, MISO, SCK,
Number of wires 2 (SDA and SCL)
and SS)
Communication type Half-duplex Full-duplex
Maximum number of Limited by addressing Limited by number of
devices scheme chip select (SS) lines
Data transfer speed Slower Faster
Improved due to
Error handling Not as robust
ACK/NACK feature
Cost-efficient due to More expensive due to
Cost
fewer wires additional wires
Simpler due to fewer More complex due to
Complexity
wires additional wires
Multi-master
Yes No
configuration
Synchronous
Yes Yes
communication
Clock stretching Yes No
Arbitration Yes No