Communication Protocols in Embedded Systems

Communication protocols are rules that allow devices to communicate data via any physical medium. The rules, regulations, synchronisation between communication systems, the syntax to be followed, and semantics are all defined by the term "protocol". Software, hardware, or a combination can be used to implement protocols. Different communication protocols are frequently used in analogue and digital communication systems. Protocols need to be chosen based on device support.

The communication protocols are generally associated with a physical layer describing the signals incorporated, signal strength, handshaking mechanism, bus arbitration, device addressing, wired or wireless, data lines, etc. The application layer involves system configuration, baud rate selection, and transmitting and receiving data.

Communication protocols are broadly classified into Inter System protocol and Intra System protocol.

Inter System Protocol

Communication between two devices, such as a PC and development boards, is established using inter-system protocols. In this instance, communication is made possible using an inter-bus system. Inter-system protocols can be categorised into

  • USB
  • UART
  • USART

Intra System Protocol

The intra-system protocol establishes communication between components within the circuit board. It promises secure access to data from the peripherals. Intra-system protocols can be categorised into

  • I2C Protocol
  • SPI Protocol
  • CAN Protocol


Universal Serial Bus (USB)

  • Two-wired serial communication protocol
  • A single USB host controller can allow up to 127 connected devices.
  • USB supports plug & play functionality
  • Pins - D+ ,  D- , Vcc , GND
  • Data is transmitted in the form of packets. Data packets are 8 bits long, with the LSB transmitted first. 
  • Types of USB Ports and Connectors
  • USB uses the NRZI encoding scheme to transmit data.
(Clock synchronisation is ensured through the data recording and transmission technique known as Non-Return to Zero Inverted (NRZI). A data bit of 1 corresponds to a positive voltage, whereas a data bit of 0 corresponds to a negative voltage in the binary code Non-Return to Zero, which is utilised in communications transmission. Unlike Return to Zero (RZ) code, which features a rest state, the NRZ code does not have a neutral state.)

Universal Asynchronous Receiver/Transmitter (UART)
  • It is merely a physical piece of hardware that transforms parallel data into serial data; it is not a communication protocol.
  • Two-wired communication.
  • Tx and Rx pins manage the serial data.
  • Since UART transmits data asynchronously, neither sending nor receiving data requires the use of a clock signal. 
  • UART embeds start and stop bits with the actual data bits, defining the beginning and end of a data packet rather than using a clock signal.
  • When the receiver end detects the start bit, it starts to read the data bits at a specific baud rate.
  • The transmitter and receiver must have the same baud rate.
  • UART operates in half-duplex mode.

Universal Synchronous Asynchronous Receiver/Transmitter (USART)
  • It simply differs from UART in terms of synchronous functioning.
  • Without knowing the baud rate in advance, the transmitter will produce a clock signal that will be recovered at the receiving end of the data stream.
  • Full-duplex mode of communication.

Inter Integrated Circuit (I2C)
  • It is a serial communication protocol.
  • Developed by Philips Semiconductors.
  • This protocol's primary goal is to make it simple to connect peripheral chips to microcontrollers.
  • In embedded systems, the microcontroller is connected to all peripheral devices as memory-mapped devices.
  • SDA (Serial Data Line) and SCL (Serial Clock Line), two cables required by I2C, are used to transmit information between devices.
  • These two active wires are said to be bidirectional.
  • I2C protocol is a master to slave communication protocol. Each slave is given an unique address. The target slave address and R/W (Read/Write) flag are originally sent by the master device to initiate communication. Other devices will remain in the off state while the matching slave device switches to active mode.
  • Communication between the master and slave devices begins as soon as the slave device is prepared. If the transmitter transmits 1 byte (8 bits) of data, the receiver responds with a single bit of acknowledgement. After device-to-device communication, a stop condition is issued.
  • I2C Communication Protocols' slow speed is their greatest drawback.





Serial Peripheral Interface (SPI)
  • A serial communication protocol.
  • Developed by Motorola.
  • It is a 4-wire protocol.
  • Pins - MOSI (Master Out Slave In), MISO (Master In Slave Out, SS (Slave Select), and SCLK (Serial Clock).
  • SPI is a full duplex communication protocol.
  • SPI doesn’t limit data transfer to 8 bit words.
  • Master to slave communication protocol.
  • In SPI, the master device initially sets the clock at a specific frequency. Additionally, the SS line, which is typically held high, is pulled low to choose the proper slave.
  • As soon as the proper slave device is chosen, communication between the selected slave and the master device is established.

Here are the main characteristics and components of the SPI protocol:

  1. Communication Structure:

    • SPI typically involves a master-slave architecture, where one device (master) initiates and controls the communication, and one or more devices (slaves) respond to the master's commands.
    • The communication is based on a shared clock signal (SCK) and two data lines:
      • MOSI (Master Out Slave In): The master sends data to the slave on this line.
      • MISO (Master In Slave Out): The slave sends data to the master on this line.
  2. Chip Select (CS):

    • Each slave device connected to the SPI bus is typically assigned a chip select signal (CS) or slave select (SS).
    • The master activates the CS line for the specific slave device it wants to communicate with, while keeping other CS lines inactive.
    • Activating the CS line indicates to the selected slave device that it should pay attention to the communication.
  3. Data Transfer:

    • SPI transfers data in a full-duplex manner, meaning that data can be sent and received simultaneously.
    • The master generates clock pulses on the SCK line, and on each clock cycle, both the master and the slave exchange one bit of data.
    • The master sends data on the MOSI line while simultaneously receiving data on the MISO line.
  4. Data Frame Format:

    • The SPI protocol supports various data frame formats, including different bit lengths, clock polarities, and clock phases.
    • Commonly used formats include:
      • 8 bits with a clock polarity of 0 and a clock phase of 0 (CPOL = 0, CPHA = 0)
      • 8 bits with a clock polarity of 1 and a clock phase of 1 (CPOL = 1, CPHA = 1)
      • These settings define the idle state of the clock and the edge at which data is sampled.
  5. Speed and Synchronization:

    • The SPI communication speed is determined by the clock frequency (SCK).
    • The clock frequency is configurable and depends on the capabilities of the devices involved.
    • The master and slave devices must be configured with compatible clock frequencies to ensure proper communication.
  6. Protocol Variations:

    • While the basic SPI protocol is widely adopted, there are variations and extensions, such as modes with more data lines, multiple masters, or daisy-chaining of devices.
    • Some microcontrollers and peripheral chips may implement slight variations or additional features on top of the standard SPI protocol.

Controller Area Network (CAN)

  • It is a serial communication protocol.
  • Developed by Robert Bosch.
  • Use for intra-vehicular communication.
  • It requires two wires for data transmission.
  • Pins -  CAN High (H+) and CAN low (H-).
  • Based on a message-oriented communication protocol.


Comments

Popular Posts