Module 10: Capstone Projects · Project 2 — UART Controller

Project 2, Part 1: The UART Protocol

A Universal Asynchronous Receiver-Transmitter (UART) transmits serial binary data without a shared clock signal. Transmitter and receiver modules establish synchronization using timed bit transitions. This article defines the 8N1 serial protocol specification, bit-timing calculations, and receiver error detection rules.

Frame Format Specification

An idle UART line remains in a continuous logic 1 (mark) state. Transmission begins when the transmitter pulls the line low to logic 0.

A UART frame: idle, start, eight data bits LSB first, stop, with the receiver’s sample points
Figure 1: One 8N1 frame with the sample points marked

The 8N1 frame consists of the following sequential fields:

Field Width (Bits) Nominal Value Functional Purpose
Start bit 1 0 Signals the start of a frame and triggers receiver timing counters.
Data bits 8 Variable Transmits the data byte, sending the least significant bit (LSB) first.
Parity bit 0 None Omitted in standard 8N1 configurations.
Stop bit 1 1 Verifies frame completion and returns the serial bus to idle high.

Bit-Timing Calculations

Because UART interfaces omit a common clock wire, both endpoints must configure matching baud rates:

$$T_{\text{bit}} = \frac{1}{\text{Baud Rate}}$$

At a transmission speed of 9600 baud, each bit occupies $104.17,\mu\text{s}$. Local frequency dividers derive these intervals from system oscillator clocks.

Receiver Mid-Bit Sampling Strategy

Asynchronous clocks drift due to temperature, voltage, and crystal tolerances. To maximize timing margin, the receiver samples each incoming bit at its midpoint (50 percent point). When a falling edge occurs on the idle line, the receiver waits one half-bit period ($0.5,T_{\text{bit}}$). If the line remains logic 0, the receiver confirms a valid start bit. The receiver then samples incoming data bits at integer bit intervals ($1.0,T_{\text{bit}}$).

Protocol Error Conditions

Robust UART controllers detect and report three primary protocol errors:

  1. Framing Error: The receiver samples the stop bit position and detects a logic 0 instead of logic 1. This failure indicates baud rate mismatches or line noise.
  2. False Start Glitch: A transient noise pulse pulls the serial line low. The receiver samples the line at $0.5,T_{\text{bit}}$. If the line returns to logic 1, the controller rejects the glitch and returns to idle.
  3. Baud Rate Drift: Clock mismatches greater than approximately 3 percent cause sampling points to drift into adjacent bit windows.

Practice Exercise

The system clock operates at 50 MHz. The UART communicates at 115200 baud. Calculate the number of clock cycles required for one full bit period and one half-bit period.

Solution

Calculate the full bit period in clock cycles:

$$\text{Bit Period} = \frac{50{,}000{,}000}{115200} \approx 434.03 \text{ cycles}$$

Round the divisor to an integer value of 434 cycles.

Calculate the half-bit period for start bit verification:

$$\text{Half-Bit Period} = \frac{434}{2} = 217 \text{ cycles}$$

The receiver waits 217 clock cycles after detecting a falling edge before sampling the start bit center.

The UART protocol packages data bytes into serial frames bounded by start and stop bits. Receivers eliminate clock drift errors by sampling at the midpoint of each bit interval. The next article implements the parameterized baud rate generator that drives serial timing.

← Project 1, Part 4: Assembly and Verification Project 2, Part 2: The Baud Rate Generator →