Project

General

Profile

Hardware Communication Protocols

Microcontrollers can talk between each other in a variety of ways. Described here are the most popular hardware protocols that can be implemented on nearly all microcontrollers.

Serial (UART, USART)

  • Fast communication (1kHz to 200kHz+)
  • Usually two devices
  • Both devices can send data to the other without prompt
  • Can be used over short and medium distance
  • Error checking possible through parity bit
  • Simple interface to USB, RS-232, RS-422, RS-485
  • UART: 2-wire (Rx, Tx)
  • USART:

Serial communication is useful for a dedicated communication line between two devices. It sends data in packets of usually 8-bits. Each wire is unidirectional but with Rx and Tx, data can be sent in both directions. Both devices must be set to read and write data at the same speed (baud rate). If working with a hardware UART, the software required is very simple.

Serial on AVR devices with USI module
Serial on AVR devices with UART module
Serial on MSP430 devices with USI module
Serial on MSP430 using the USCI module

Inter Integrated Circuit (I2C, TWI, SMBus)}

  • Medium speed (up to 100kHz, with fast I2C up to 400kHz)
  • Up to 127 devices (more with 10-bit addressing)
  • Master-slave operation: Master can send and request data from slaves at any time, but slaves must be prompted to send information
  • Short distance (limited by bus capacitance)
  • 2-wire: SDA (data) and SCL (clock)
  • Multiple masters allowed (arbitration prevents two masters from driving SDA and SCL simultaneously)
  • Clock stretching allows Slave to wait before sending data
  • ACK bit indicates if data was received

I2C is a useful protocol for a large network of devices that all communicate on the same two wires. However, software is required to control the I2C hardware module in a microcontroller.

I2C on AVR devices with USI module
I2C on AVR devices with TWI module
I2C on MSP430 devices with USI module
I2C on MSP430 using the USCI module

Serial Peripheral Interface (SPI)

  • Medium to High speed
  • 2+ devices, limited by slave enable lines
  • Short to medium distance
  • 3+ wires: MOSI (Master out Slave in), MISO (Master in Slave out), SCLK (clock), enable line for each slave (not necessary for master-slave operation)
  • Master-slave operation

SPI is essentially one shift register on each device, so the master shifts data onto the MOSI line, and reading data into the shift register from the MISO line. SPI is useful for two or a limited number of devices, since each slave must have an enable line.

SPI on AVR devices with USI module
SPI on AVR devices with SPI module
SPI on MSP430 devices with USI module
SPI on MSP430 using the USCI module

RS-232

RS-232 is a version of Serial communication designed for long distance operation. It is not directly compatible with UARTs found in microcontroller, but instead needs a dedicated RS-232 to TTL converter.

RS-422

RS-485

RS-485 is a version of Serial communication designed for long distance operation with multiple devices. It is not directly compatible with UARTs found in microcontrollers, but instead needs a dedicated RS-485 to TTL converter