I2C vs. SPI vs. UART

Learn the difference between SPI, I2c and UART protocols. Each one has different strengths and tradeoffs which are appropriate for certain situations.

By Jeremy Cook

In many situations, engineers have settled upon SPI, UART, and I2C for short-distance device communications. While these protocols have all been used for decades, the benefits of SPI vs. I2C, UART vs. SPI, or any other combination, aren't entirely straightforward. Each has its strengths, as well as tradeoffs. This article will quickly outline how each works and where one might serve a project's needs better than another.

UART – Universal Asynchronous Receiver-Transmitter

Implemented in the early stages of computing development, UART's roots date back to the telegraph. When it comes to machine-to-machine communication, UART could be considered the "alpha protocol." In its modern implementation, parallel data may be passed to a UART chip. The chip turns this input into serial data to be transmitted via a single transmit (Tx) line. A single receive (Rx) line allows for data reception from another UART device. Data transmission may be simplex (single direction), half-duplex (one direction at a time), or full-duplex (both directions simultaneously) and takes place between two devices.

UART wiring is straightforward, requiring only connections for Rx and Tx. Speeds vary, depending on setup, but must be coordinated between both devices -- there's no clock signal. While 115200 baud is standard, other speeds can be used, too. This protocol is often implemented to program microcontrollers.

I2C – Inter-Integrated Circuit

Developed by Philips Semiconductor (now NXP) in 1982, I2C has become widely accepted for communication between microcontrollers and peripherals. Data is transferred via a bus consisting of two wires (SDA – serial data and SCL – serial clock) in half-duplex mode. Typically, a single master device is used to signal one or more slave devices. Each has a unique address to allow them to share the same bus. A multi-master system is also possible but less common.

I2C wiring is simple. Only a single common SDA common SCL line needs to run between the master and slave devices. The typical 7-bit addressing scheme allows up to 128 individual entities to be controlled. Pull-up resistors for the SDA and SCL lines may also be implemented.

This bus technology is generally faster than UART. Standard speeds run from 100kbit/s to as high as 5Mbit/s in ultra-fast mode. However, only half-duplex operation is available, and only one slave can be addressed at a time.

SPI – Serial Peripheral Interface

SPI was developed as a communication standard by Motorola in the mid-1980s and is now widely used for data transfer between devices. A single master device may send and receive data from one or more slaves, and data transfer speeds are dependent on the devices used.

SPI is also the most complicated wiring-wise, requiring lines from the master device for serial clock output (SCLK), master out slave in (MOSI), master in slave out (MISO), and CS/SS for chip select/slave select. CS/SS lines will be needed for every slave device; therefore, if a single master device were controlling three peripherals, you'd need to dedicate 6 IO lines for this purpose.

SPI is generally the fastest of these three protocols. With its independent MOSI and MISO lines, it's capable of sending and receiving simultaneously for full-duplex operation. SPI is often the best choice if speed is essential for a peripheral -- for example, in the case of an SD card reader, or a quickly refreshing display.

I2C vs. SPI vs. UART – What is the Appropriate Protocol to Select?

Whether it's UART's tried and true operation, the enormously expandable nature of I2C or the high-speed operation of SPI, one of these protocols will be most appropriate for your situation. However, the choice will often depend on the peripherals used, as many can communicate using only one of these protocols.

 

 

최신 뉴스

Sorry, your filter selection returned no results.

개인정보 보호정책이 업데이트되었습니다. 잠시 시간을 내어 변경사항을 검토하시기 바랍니다. 동의를 클릭하면 Arrow Electronics 개인정보 보호정책 및 이용 조건에 동의하는 것입니다.

당사의 웹사이트에서는 사용자의 경험 향상과 사이트 개선을 위해 사용자의 기기에 쿠키를 저장합니다. 당사에서 사용하는 쿠키 및 쿠키 비활성화 방법에 대해 자세히 알아보십시오. 쿠키와 추적 기술은 마케팅 목적으로 사용될 수 있습니다. '동의'를 클릭하면 기기에 쿠키를 배치하고 추적 기술을 사용하는 데 동의하는 것입니다. 쿠키 및 추적 기술을 해제하는 방법에 대한 자세한 내용과 지침을 알아보려면 아래의 '자세히 알아보기'를 클릭하십시오. 쿠키 및 추적 기술 수락은 사용자의 자발적 선택이지만, 웹사이트가 제대로 작동하지 않을 수 있으며 사용자와 관련이 적은 광고가 표시될 수 있습니다. Arrow는 사용자의 개인정보를 존중합니다. 여기에서 당사의 개인정보 보호정책을 읽을 수 있습니다.