Tuesday 25 July 2017

What is the difference between UART and SPI?

UART and SPI are serial communications interfaces between two devices (such as a Wi-Fi module and a host microcontroller).

In terms of speed, simple UARTs typically operate at 0.3 Kbps to 1 Mbps whereas a SPI can operate up to 50 Mbps or sometimes more. As such, UARTs are an excellent choice for sensor type applications and SPI is better suited to high-bandwidth applications such as audio or video.

A UART is an asynchronous interface since the transmitter and receiver use independent clock sources.
SPI is an synchronous interface that uses a dedicated clock signal. 

Serial Peripheral Interface, or SPI, is a very common communication protocol used for two-way communication between two devices.Each SPI transfer is full-duplex, meaning that data is sent from the master to the slave and from the slave to the master at the same time. 
The Master device is the one which initiates the connection and controls it. Once the connection is initiated, then the Master and one or more Slave(s)can transmit and/or receive data. As mentioned earlier, this is a full-duplex connection, which means that Master can send data to Slave(s) and the Slave(s) can also send the data to the Master at the same time.

  • Master generates 8 clock pulses. After each clock pulse, one bit of information is transfer from Master to Slave and vice-versa.
  • After 8 clock pulses, Master would have received Slave’s data, whereas Slave would have Master’s data. And that’s why this is a full-duplex communication.
The Master and Slave are connected by means of four wires. Each of these wires carries a particular signal defined by the SPI bus protocol. These four signals/wires are–
  1. MOSI – Master Out Slave In: This is the wire/signal which goes from the output of Master’s shift register to the input of the Slave’s shift register.
  2. MISO – Master In Slave Out: This is the wire/signal which goes from the output of Slave’s shift register to the input of the Master’s shift register.
  3. SCK/SCLK – Serial Clock: This is the output of the clock generator for Master and clock input for Slave.
  4. SS’ – Slave Select: This is discussed in the next section of this post.

    

 

No comments:

Post a Comment