Embedded Systems Communication Protocol
Embedded Systems Communication Protocol
Embedded Systems Communication Protocol
COLLEGE OF ENGINEERING
DEPARTMENT OF ELECTROMECHANICAL ENGINEERING
Start Bit
Data Frame
Parity
Stop Bits
1. The transmitting UART receives data in parallel from the data bus.
2. The transmitting UART adds the start bit, parity bit, and the stop bit(s) to the data frame.
3. The entire packet is sent serially from the transmitting UART to the receiving UART.
The receiving UART samples the data line at the pre-configured baud rate.
4. The receiving UART discards the start bit, parity bit, and stop bit from the data frame.
5. The receiving UART converts the serial data back into parallel and transfers it to the data
bus on the receiving end.
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
The main advantage of the SPI is to transfer the data without any interruption. Many bits can be
sent or received at a time in this protocol.
In this protocol, devices are communicated in the master-slave relationship. The master device
controls the slave device, and the slave device takes the instruction from the master device. The
simplest configuration of the Serial Peripheral Interface (SPI) is a combination of a single slave
and a single master. But, one master device can control multiple slave devices.
SPI Interface
The SPI protocol uses the four wires for the communication. There are shown in the figure.
1. MOSI: MOSI stands for Master Output Slave Input. It is used to send data from the
master to the slave.
2. MISO: MISO stands for Master Input Slave Output. It is used to send data from the slave
to the master.
3. SCK or SCLK (Serial Clock): It is used to the clock signal.
4. SS/CS (Slave Select / Chip Select): It is used by the master to send data by selecting a
slave.
Advantages of SPI
1. The main advantage of the SPI is to transfer the data without any interruption.
2. It is simple hardware and provides full-duplex communication.
3. There is no need for a unique address of the slave in this protocol.
4. In this, software implementation is very simple.
5. It provides high transfer speed and Signals are unidirectional.
6. It has separate lines of MISO and MOSI, so the data can be sent and received at the same
time.
Disadvantages of SPI
Applications of SPI
Compared to protocols like USB, ethernet, Wi-Fi, or Bluetooth, I2C is much slower. However, it
is a lot simpler and uses significantly less hardware and system resources. This makes it ideal for
communication between microcontrollers or microcontrollers and sensors. Much like the SPI
(Serial Peripheral Interface), I2C is intended only for short distances.
I2C interface
I2C protocol uses only two cables for the communication in which one cable is used for the data
(SDA), and another cable is used for clock (SCL). Both cables are required to pull up with a
resistor for + Vdd. It can be used to link two I2C buses with different voltages.
Applications of I2C
Advantages of I2C
1. The complexity of hardware increases when no. of master/slave devices are high in the
circuit.
2. It provides a half-duplex mode for communication.
3. It is managed by the stack.
4. Many devices have multiple addresses stored, which can cause conflicts.
To use I2C (Inter-Integrated Circuit) in a PIC16F controller, you need to configure the hardware
and software settings. Here's a brief explanation of the steps involved:
1. Configure the I2C Pins: First, you need to configure the appropriate pins for I2C
communication. In the PIC16F controller, I2C functionality is usually available on
specific pins, such as RC3 (SCL) and RC4 (SDA). Configure these pins as input or
output using the TRISC register.
2. Configure the I2C Control Registers: The I2C operation and behavior can be
controlled using several registers. The key registers to configure are:
SSPSTAT (MSSP Status Register): Configure the I2C settings, such as setting the
I2C mode (Master or Slave), enabling slew rate control, and setting the
acknowledge bit.
SSPCON (MSSP Control Register): Configure the I2C settings, such as enabling
the I2C module, selecting the I2C mode (Master or Slave), enabling interrupts if
necessary, and setting the clock frequency.
3. Configure the I2C Clock Speed: Set the desired clock speed for I2C communication by
configuring the SSPADD (MSSP Address) register. The SSPADD value is calculated
based on the desired clock speed and the controller's clock frequency.
4. Enable I2C: Enable the I2C module by setting the appropriate bits in the SSPCON
register. This action allows the I2C module to start transmitting and receiving data.
5. Write and Read Data: To write and read data via I2C, you can use the SSPBUF (MSSP
Buffer) register. Write the data you want to send into the SSPBUF register, and the I2C
module will automatically transmit it. To receive data, read the received data from the
SSPBUF register.
6. Handle Interrupts (Optional): If you want to use I2C interrupts, enable them by setting
the appropriate bits in the PIE1 (Peripheral Interrupt Enable 1) register. You will also
need to write the interrupt service routine (ISR) to handle the I2C interrupts.
.