Two Interfaces of a Microcontroller (MCU)
Overview and Circuit Examples of Parallel and Serial Interfaces
There are two main methods by which a microcontroller exchanges data with other devices:
- Parallel Interface
- Serial Interface
A parallel interface transmits and receives data, for example, 8-bit data in a single clock cycle. Theoretically, this allows for high transfer speeds; however, it requires as many signal lines as the data bit length, which can hinder device miniaturization. In contrast, a serial interface uses fewer signal lines to transmits and receives data. For example, with 8-bit data, it uses a single signal line and sends or receives one bit at a time in sequence, requiring a total of eight cycles.
Parallel Interface (Bus Interface) Circuit Example
Serial Interface Circuit Example
In the past, parallel interfaces were considered fast, while serial interfaces were regarded as slow. However, with advancements in device technology and the adoption of differential signaling *1 to improve noise immunity, high-speed serial interfaces operating in the MHz and GHz ranges have become common. When attempting to increase the speed of a parallel interface, synchronizing multiple signal lines becomes challenging. As a result, today, serial interfaces generally achieve higher transmission speeds compared to parallel interfaces.
*1 Differential Signaling
A method that uses two signal lines, one positive and one negative, and treats their difference as data. This approach makes communication less susceptible to external noise and enables high-speed, high-quality transmission. It is commonly adopted in high-speed serial communication.
However, when implementing a high-speed serial interface, it is essential to take measures to prevent signal line interference, and increases in power consumption and cost should be expected. On the other hand, for a serial interface that do not require high-speed transfer, interference management is minimal, and increases in power consumption and cost can be avoided. Therefore, such interfaces are still widely integrated into many microcontrollers and continue to be used in numerous applications. In this document, we will focus on general-purpose serial interfaces commonly built into microcontrollers, without the use of differential signaling.
Types and Characteristics of Serial Interfaces in Microcontrollers (MCUs)
This section provides an overview of three types of serial interfaces commonly built into general-purpose microcontrollers: UART, SPI, and I²C.
UART (Universal Asynchronous Receiver/Transmitter)
This method has long been used as an interface between personal computers and peripheral devices. Although the communication speed is relatively slow, it only requires one transmit line and one receive line in addition to a common ground level, making it suitable for many applications where high-speed transfer is not necessary. In this communication scheme, both the transmitter and receiver have their own timers and perform data transmission or reception at predetermined intervals.
-
Transmission
The initial signal must always be at a high (H) level, and the start of transmission must begin with a transition to a low (L) level. After that, data is transmitted one bit at a time at predetermined intervals. Whether the data is sent starting from the most significant bit (MSB) or the least significant bit (LSB) must be agreed upon in advance between the communicating devices. After transmission is complete, the signal must return to the high (H) level. Additionally, a parity bit can be appended to the end of the transmitted data to allow the receiver to check whether the received data is correct.
Figure 2.1 Example of UART Transmission Format -
Reception
Since the initial signal level must always be high (H), the receiver continuously waits for the signal to transition to low. This falling edge acts as a trigger to start the reception timer, which then captures data at predetermined intervals and bit lengths. Once all data has been received, the signal line returns to the high (H) level. Confirming this high level indicates that transmission and reception are complete. However, if for any reason the final signal level is not high, a framing error occurs, and error handling—such as requesting retransmission of the data—is required.
Figure 2.2 Example of UART Reception Sampling Timing
SPI (Serial Peripheral Interface)
In UART, both the transmitting and receiving devices used timers to measure time and synchronize communication. In contrast, SPI performs data transmission and reception by synchronizing both sides with a dedicated clock signal. A chip select signal can also be used, allowing communication between one master and multiple slave devices. The disadvantage compared to UART is that SPI requires more signal lines to establish communication.
-
Transmission (Master -> Slave)
The master outputs the synchronization clock and simultaneously transmits data in alignment with this clock signal.
Figure 2.4 Example of SPI Transmission Format -
Reception (Slave -> Master)
The data transmitted from the slave side is received on the rising edge of the synchronous clock.
Figure 2.5 Example of SPI Reception Format
Note that the data transmission order (whether the most significant bit or the least significant bit is sent first), the clock polarity to be used, and the edges for data transmission/reception must be predetermined and configured in advance.
I²C (Inter-Integrated Circuit)
Like SPI, I²C also supports one-to-multiple device connections. The major difference from SPI is that each slave has its own address, and the master can communicate only with the slave whose address matches by sending the desired slave's address. In addition, both the signal line and the clock line use the N-channel open-drain*2 method for output. This means the output can only drive a Low level, while during other periods, the lines are pulled up to High level by external pull-up resistors.
*2 N-Channel Open-Drain
For complementary outputs that provide both H-level and L-level signals, the method that outputs only the L-level is called N-channel open-drain, while the method that outputs only the H-level is called P-channel open-drain. In the case of the open-drain method, if it is N-channel, there is no output on the H side, so a pull-up resistor is added to bring the signal line to the H level and prevent a high-impedance state (a state that is neither H nor L).
-
Transmission (Master -> Slave)
The master first sends the slave address and receives an acknowledgment signal from the slave. After that, the master transmits the data to the slave and receives an acknowledgment signal for each data.
Figure 2.8 Transfer Format from Master to Slave in I²C -
Reception (Master <- Slave)
The master first sends the slave address and receives an acknowledgment signal from the slave. After that, the master receives the data output from the slave and sends an acknowledgment signal after each data is received.
Figure 2.9 Transfer Format from Slave to Master in I²C
Additionally, the clock (SCL), start condition, and stop condition are as follows:
When SDA falls while SCL is High, it indicates a Start condition.
When SDA rises while SCL is High, it indicates a Stop condition.
