A serial interface is a communication interface between two digital systems that transmits data as a series of voltage pulses down a wire. A “1” is represented by a high logical voltage and a “0” is represented by a low logical voltage. Essentially, the serial interface encodes the bits of a binary number by their “temporal” location on a wire rather than their “spatial” location within a set of wires. Encoding data bits by their “spatial” location is referred to as a parallel interface and encoding bits by their “temporal” location is referred to as a serial interface. Figure 3 graphically illustrates the difference between these two communication methods.
A key issue with a serial interface is knowing where the data is on the wire. As an example, let’s assume that the wire is initially at a low logical level. We’ll refer to this as the idle channel condition. If we now transmit a string of zeros down the wire, how can we distinguish between the string of zeros and the idle channel condition?
The answer to our dilemma lies in creating a protocol. A protocol is an agreement between two parties about how the two parties should behave. A communication protocol is a protocol about how two parties should speak to each other. Serial communication protocols assume that bits are transmitted in series down a single channel. A serial protocol has to address the following issues
- How does the receiver know when to start looking for information?
- When should the receiver look at the channel for the information bits?
- What is the bit order? (MSB or LSB first)
- How does the receiver know when the transmission is complete?
These issues can be addressed in a variety of ways, but we can usually identify two distinct approaches. The first approach is embodied in synchronous serial interfaces (usually abbreviated as SPI) and the second is in asynchronous serial interfaces (usually abbreviated as SCI). Asynchronous serial links are commonly used to communicate between two computers. You used the SCI interface when you used
OutString to write out characters to the PC’s terminal window. The synchronous serial link (SPI) is used when you transmit data between devices that may not have an internal clock. The SPI interface is what you’ll use in this lab because the parallel-to-serial shift register you’re using has no internal clock.
Asynchronous (SCI) Serial Interface: In an asynchronous serial interface (SCI), data is transmitted in well-defined frames. A frame is a complete and nondivisible packet of bits. The frame includes both information (e.g., data) and overhead (e.g. control bits). In asynchronous serial protocols the frame often consists of a single start bit, seven or eight data bits, parity bits, and sometimes a stop bit. A representative timing diagram for a frame that might be used by an SCI interface is shown in figure 4. In this figure, the frame has one start bit, seven data bits, one parity bit, and one stop bit. Most of the bits in this frame are self-explanatory. The start bit is used to signal the beginning of a frame and the stop bit signals the end of the frame. The parity bit is a special bit that is used to detect transmission errors.
Over the years, dozens of serial protocols have been crafted to meet particular needs of embedded systems. USB (universal serial bus), and Ethernet, are a couple of the more well-known computing serial interfaces. Other very common serial interfaces include SPI, I2C, and the serial standard we’re here to talk about today. Each of these serial interfaces can be sorted into one of two groups: synchronous or asynchronous.
A synchronous serial interface always pairs its data line(s) with a clock signal, so all devices on a synchronous serial bus share a common clock. This makes for a more straightforward, often faster serial transfer, but it also requires at least one extra wire between communicating devices. Examples of synchronous interfaces include SPI, and I2C.
Asynchronous means that data is transferred without support from an external clock signal. This transmission method is perfect for minimizing the required wires and I/O pins, but it does mean we need to put some extra effort into reliably transferring and receiving data. The serial protocol we’ll be discussing in this tutorial is the most common form of asynchronous transfers. It is so common, in fact, that when most folks say “serial” they’re talking about this protocol (something you’ll probably notice throughout this tutorial).
The clock-less serial protocol we’ll be discussing in this tutorial is widely used in embedded electronics. If you’re looking to add a GPS module, Bluetooth, XBee’s, serial LCDs, or many other external devices to your project, you’ll probably need to whip out some serial-fu.