Serial Communication Interfaces Design Quick Reference Guide

Serial-interface hardware converts protocol rules into digital circuits.

1. Serial Communication Hardware Design Fundamentals
Timing Source for Each Interface
| Interface | Timing Source | Hardware Action |
|---|---|---|
| UART | Local clock | Rebuild the receive sample timing. |
| SPI | Host-generated SCK | Generate sample and change events. |
| I²C | Shared SCL | Release SCL, then observe SCL_Bus. |
| CAN | Local bit timer | Synchronize to shared-bus edges. |
Timing Measurement Terms
| Interface | Preferred Term | Meaning |
|---|---|---|
| UART | Baud rate | Symbols per second |
| UART | Bit rate | Bits per second |
| SPI | SCK frequency | Clock cycles per second |
| I²C | SCL frequency | Clock cycles per second |
| CAN | Bit rate or bit time | Bits per second or time per bit |
In binary UART, one symbol normally carries one bit.
Therefore, its baud rate and bit rate have the same numerical value.
Serial Bit Order
| Interface | Bit Order |
|---|---|
| UART | D0 first, D7 last |
| SPI | 8-bit word, MSB first in this architecture |
| I²C | MSB first |
| CAN | Defined by the frame fields |
Important: The TX and RX datapaths must use the same bit order.
Common Serial Controller Hardware

| Protocol Need | Digital Hardware |
|---|---|
| Bit timing | Counter and tick generator |
| Frame position | Bit counter and state register |
| TX bit selection | MUX or shift register |
| RX bit capture | Sample enable and receive register |
| Bus ownership | Output-enable or release control |
| Error detection | Comparator and status register |
Circuit scope: Each figure shows one learning-focused circuit block rather than a complete UART, SPI, I²C, or CAN peripheral.
2. UART Hardware Design
UART Frame Format
| Name | Idle | Start Bit | Data Bits | Parity Bit | Stop Bit |
|---|---|---|---|---|---|
| Labels / Values | Idle = 1 | 0 | D0 to D7, LSB first | P = Even/Odd, or omitted | 1 |
UART Transmitter Hardware
A TX request is accepted only while the transmitter is idle.
TX_Accept = TX_Start · Busy'
At TX_Accept:
- Capture
TX_Data. - Capture the parity setting.
- Clear the frame counter.
- Set
Busy = 1.
Later input changes do not affect the active frame.
A new request during Busy = 1 is ignored unless a buffer is provided.
| Block | Function |
|---|---|
| TX data register | Holds the accepted byte |
| Parity logic | Generates P |
| Frame counter | Selects the active frame field |
| Frame MUX | Selects 0, D0...D7, P, or 1 |
| Baud-tick input | External Baud_Tick advances the active frame |
| TX register | Holds one serial bit |
| Control logic | Generates Busy and Done |
Even_Parity = D0 ⊕ D1 ⊕ D2 ⊕ D3 ⊕ D4 ⊕ D5 ⊕ D6 ⊕ D7
Odd_Parity = Even_Parity'
If parity is disabled, the frame MUX skips P.


Direct-I/O simplification:
TX_Start,TX_Data, parity settings, andBaud_Tickare shown as direct inputs. In a complete system, control/configuration registers and the baud generator normally provide them.
UART Baud-Tick Generation
For an integer divider:
Baud_Divider = f_CLK_SYS / f_BAUD
The implemented learning circuit uses a 4-bit programmable Baud_Divider. It first generates the terminal limit:
Baud_Limit = Baud_Divider - 1
Implementation note:
1111, the 4-bit two's-complement value of-1, is wired directly to the adder'sBinput whileBaud_DividerdrivesA. The normal adder therefore computesBaud_Divider - 1; no controlled SUB configuration is used.
The value of Baud_Divider must not be 0000
The four counter D flip-flops expose Baud_Count[3:0]. A second 4-bit full adder forms:
Count_Sum = Baud_Count + Enable
Thus Enable = 0 holds the count, while Enable = 1 increments it. A 4-bit magnitude comparator produces:
Terminal_Count = (Baud_Count = Baud_Limit)
Baud_Tick = Enable · Terminal_Count
Each counter-register input masks its corresponding Count_Sum bit with Baud_Tick':
Baud_Count_Next[i] = Count_Sum[i] · Baud_Tick'
Consequently, the counter increments while enabled and below Baud_Limit, generates a one-CLK_SYS-cycle Baud_Tick at the terminal count, and synchronously returns to 0000.
Active-LOW nRESET also clears the four counter flip-flops. The separate UART transmitter circuit receives Baud_Tick as an input, keeping frame sequencing independent of the selected system-clock and baud-rate values.

Direct-I/O simplification:
Baud_DividerandEnableare direct inputs in this circuit. A complete UART normally receives them from configuration and control logic.
UART Receiver Sampling
The learning circuit is a fixed 8-N-1 receiver. It uses a synchronized RX input and an external 16× Oversample_Tick.
It generates one Sample_Enable near the center of each bit.
Why wait half a bit? The detected falling edge marks the approximate start-bit boundary and may also be caused by a short disturbance. Waiting eight oversample ticks moves the check to the center of the start bit, away from either edge. If RX_SYNC is still LOW there, the start bit is accepted; otherwise it is rejected as a false start.

| Block | Function |
|---|---|
| RX synchronizer | Produces stable local RX |
| Start detector | Finds a possible start edge |
| 4-bit sample counter | Locates the bit center and full-bit boundaries |
| Sample decoder | Pulses Sample_Enable |
| 3-bit bit counter | Selects data bits D0 through D7 |
| RX register | Captures data bits |
| Four-state one-hot controller | Sequences IDLE, START, DATA, and STOP |
| Stop check | Produces RX_VALID or FRAME_ERROR |
1. Synchronize and detect the start edge
Two D flip-flops synchronize RX; a previous-value register then detects the HIGH-to-LOW transition:
Start_Detect = RX_PREV · RX_SYNC'
2. Enable receiver timing
The sample counter runs only while the receiver is validating or receiving a frame:
Timing_Enable = S_START + S_DATA + S_STOP
Count_Enable = Oversample_Tick · Timing_Enable
3. Validate the start-bit center
Count 8 represents half of a 16× bit interval:
Count_8 = C3 · C2' · C1' · C0'
Half_Bit = S_START · Oversample_Tick · Count_8
At Half_Bit, LOW accepts the start bit and HIGH returns the controller to idle as a false start.
4. Sample the eight data bits
After start validation, count 15 produces one full-bit sampling interval:
Count_15 = C3 · C2 · C1 · C0
Bit_Time = Oversample_Tick · Count_15
Sample_Enable = S_DATA · Bit_Time
Bit_Count[2:0] selects D0 through D7. The RX register loads only the selected bit when Sample_Enable = 1.
5. Finish the frame and check the stop bit
Last_Data_Sample = Sample_Enable · B2 · B1 · B0
Stop_Sample = S_STOP · Bit_Time
RX_VALID = Stop_Sample · RX_SYNC
FRAME_ERROR = Stop_Sample · RX_SYNC'
Sample_Count[3:0] and Bit_Count[2:0] are exposed as learning/debug outputs.
Important: The RX register captures only when
Sample_Enable = 1.

Direct-I/O simplification:
Oversample_Tickis supplied directly. A complete UART normally derives this 16× timing pulse from its programmable baud-rate generator.
UART Receive Status
| Signal | Set When | Included in the learning circuit? |
|---|---|---|
FRAME_ERROR | Sampled stop bit is 0 | Yes |
RX_VALID | Sampled stop bit is 1 and reception completes | Yes |
PARITY_ERROR | Received parity does not match | No; the circuit is 8-N-1 |
OVERRUN | New data arrives before old data is read | No; buffering is omitted |
False starts do not assert RX_VALID.
Scope note: A production receiver must protect unread data and report overrun. The pictured learning circuit intentionally omits that buffer/handshake layer.
UART Implementation Steps
- Build the standalone baud-tick divider shown above.
- For TX, capture the active byte and parity configuration only on
TX_Accept. - Advance the TX frame counter with external
Baud_Tickand select start, data, optional parity, and stop fields. - For RX, synchronize
RXand detect its falling start edge. - Use external
Oversample_Tick, the 4-bit sample counter, and the four-state controller to validate the start bit and generateSample_Enable. - Count and store
D0throughD7, then sample the stop bit. - Generate TX
Busy/Doneand RXRX_VALID/FRAME_ERROR. - Verify reset, idle, complete stop-bit timing, and false-start behavior.
3. SPI Hardware Design
SPI Transfer Format
| Property | Value |
|---|---|
| Word size | 8 bits |
| Bit order | MSB first |
| Data flow | Full duplex |
| Clock source | Host-generated SCK |
| Target select | Active-low CS_n |
SPI can also use another bit order when required by the connected device.
Clock Idle and Active Edges
CPOL selects the idle level of SCK.
CPOL | SCK Idle | Idle → Active | Active → Idle |
|---|---|---|---|
0 | LOW | Rising edge | Falling edge |
1 | HIGH | Falling edge | Rising edge |
CPHA selects the action performed on each edge.
CPHA | Idle → Active | Active → Idle | First TX Bit |
|---|---|---|---|
0 | Sample | Change | Preload before the first edge |
1 | Change | Sample | Launch on the first edge |
- Sample: Capture the input bit into the RX register.
- Change: Update the output bit from the TX register.
SPI Mode Mapping
| Mode | CPOL | CPHA | SCK Idle | Idle → Active | Active → Idle |
|---|---|---|---|---|---|
| 0 | 0 | 0 | LOW | Rising: Sample | Falling: Change |
| 1 | 0 | 1 | LOW | Rising: Change | Falling: Sample |
| 2 | 1 | 0 | HIGH | Falling: Sample | Rising: Change |
| 3 | 1 | 1 | HIGH | Falling: Change | Rising: Sample |
Configurable SPI Edge Generator
| Signal | Meaning |
|---|---|
Clock | System clock for the phase flip-flop |
nRESET | Active-LOW reset that returns Phase to 0 |
Enable | Allows SPI phase changes while a transfer is active |
Half_Tick | One-cycle event marking one half of an SCK period |
CPOL | Selects the idle level of SCK |
CPHA | Selects which phase transition samples data and which changes data |
Phase | Stored half-cycle state; 0 is idle phase and 1 is active phase |
SCK | Generated SPI serial clock, CPOL ⊕ Phase |
Idle_to_Active | Pulse for the first transition away from the idle clock level |
Active_to_Idle | Pulse for the return transition to the idle clock level |
Sample_Edge | Event used to capture the received data bit |
Change_Edge | Event used to update the transmitted data bit |
The learning circuit treats Half_Tick as an external half-period timing pulse. A complete SPI host may generate it with a separate divider, but that divider is not part of this circuit.
The phase T flip-flop toggles only while the controller is enabled:
T_Phase = Enable · Half_Tick
Phase = 0 means the idle half-cycle.
SCK = CPOL ⊕ Phase
The phase transition creates two internal events:
Idle_to_ActiveActive_to_Idle
CPHA maps these events to the datapath enables.
Idle_to_Active = Enable · Half_Tick · Phase'
Active_to_Idle = Enable · Half_Tick · Phase
Sample_Edge = CPHA'·Idle_to_Active + CPHA·Active_to_Idle
Change_Edge = CPHA·Idle_to_Active + CPHA'·Active_to_Idle
| Event | Datapath Action |
|---|---|
Sample_Edge | Capture MISO |
Change_Edge | Update MOSI |

Direct-I/O simplification:
Enable,Half_Tick,CPOL, andCPHAare direct inputs, whileSample_EdgeandChange_Edgeare exposed outputs. In a complete SPI host, the transfer controller, timing divider, configuration registers, and datapath connect these signals internally.
SPI Transfer Sequence

SPI TX and RX Datapaths
| Path | Source | Enable | Action |
|---|---|---|---|
| TX | TX register MSB | Change_Edge | Advance MOSI |
| RX | MISO | Sample_Edge | Capture into RX register |
For CPHA = 0, preload the first MOSI bit before the first sample.
For CPHA = 1, the first Change_Edge launches the first bit.
Target Selection and Completion
| Stage | Controller Action |
|---|---|
| Start | Latch the target and assert one CS_n |
| Transfer | Hold the selected target constant |
| Final sample | Finish the required clock phase |
| Complete | Set SCK = CPOL, release CS_n, pulse Done |
Caution: Do not release
CS_nbefore the last clock phase is complete.
Mode-0 Target Behavior
| Condition | Target Action |
|---|---|
CS_n = 1 | Ignore SCK |
| Target selected | Preload first MISO bit |
Rising SCK edge | Sample MOSI |
Falling SCK edge | Update MISO |
SPI Implementation Steps
- Supply
Enableand the external half-period pulseHalf_Tick. - Toggle the phase flip-flop with
T_Phase = Enable · Half_Tick. - Generate
SCK = CPOL ⊕ Phaseso disabled/reset phase returns the clock to its configured idle level. - Decode
Idle_to_ActiveandActive_to_Idlefrom the current phase. - Map the two transition events to
Sample_EdgeandChange_EdgewithCPHA. - In a larger SPI design, use those outputs as RX-capture and TX-update enables.
4. I²C Hardware Design
Open-Drain Bus Operation
| Control Value | Participant Action |
|---|---|
0 | Pull the line LOW |
1 | Release the line |
The participant does not actively drive HIGH.
| Participant Outputs | Resolved Bus |
|---|---|
| Every participant releases | HIGH |
| Any participant pulls LOW | LOW |
Resolved SDA and SCL Hardware
For release-valued controls:
SDA_Bus = Controller_SDA_Release
· Target0_SDA_Release
· Target1_SDA_Release
SCL_Bus = Controller_SCL_Release
· Target0_SCL_Release
· Target1_SCL_Release
Every device observes SDA_Bus and SCL_Bus.
It does not rely only on its intended output.
The learning circuit implements these equations with two independent native 3-input AND gates: one for SDA and one for SCL. It models one controller and two targets and contains no clock, state machine, or physical pull-up resistor model.

Direct-I/O simplification: The controller and target SDA/SCL release controls are direct inputs here. In a complete I²C design, each participant's protocol controller generates these signals.
Important: Intended output and observed bus value may be different.
I²C Bus Events
| Event | SDA_Bus Action | SCL_Bus Level |
|---|---|---|
| START | HIGH → LOW | HIGH |
| STOP | LOW → HIGH | HIGH |
| Data | Stable | HIGH |
| Repeated START | HIGH → LOW | HIGH, without STOP |
The implemented timing circuit observes the resolved bus with previous-value D flip-flops:
START_Detect = SDA_PREV · SDA_Bus' · SCL_Bus
STOP_Detect = SDA_PREV' · SDA_Bus · SCL_Bus
SCL_Rise = SCL_PREV' · SCL_Bus
START_Detect sets an Active transaction register, and STOP_Detect clears it. While active, a 4-bit full-adder-based counter increments on each SCL_Rise:
D_Active = START_Detect + Active · STOP_Detect'
Count_Enable = Active · SCL_Rise
Count_Clear = START_Detect + ACK_Sample + STOP_Detect
The counter uses Bit_Count + Count_Enable and a synchronous clear mask; protocol events are not connected to the counter's asynchronous clear pins. After eight data clocks:
Byte_Complete = B3 · B2' · B1' · B0'
ACK_Window = Active · Byte_Complete
ACK_Sample = ACK_Window · SCL_Rise
ACK_Detect = ACK_Sample · SDA_Bus'
NACK_Detect = ACK_Sample · SDA_Bus
The ninth rising SCL edge therefore samples ACK or NACK and synchronously restarts the byte counter. The same START detector also recognizes a repeated START while Active = 1.

Direct-I/O simplification:
SDA_BusandSCL_Busare direct inputs to this timing circuit. In the combined system, they come from the open-drain bus resolver or physical input interface.
Address and ACK Ownership
The controller sends a 7-bit address and R/W.
The address is sent MSB first.
| Bus Phase | SDA Owner | SDA Action |
|---|---|---|
| Address or data bits | Byte transmitter | Pull LOW for 0; release for 1 |
| ACK bit | Byte receiver | Pull LOW for ACK; release for NACK |
The ownership circuit is a single 2:1 MUX using release-valued logic:
SDA_Release = ACK_Window' · TX_Bit
+ ACK_Window · ACK_Release
When ACK_Window = 0, TX_Bit controls SDA. When ACK_Window = 1, the byte receiver's ACK_Release value controls SDA. This circuit does not generate the address, data, or ACK decision; it only performs the ownership handoff.
A target ACKs only a matching address and supported direction.
After a mismatch, it releases SDA until STOP or a new START.

Direct-I/O simplification:
TX_Bit,ACK_Release, andACK_Windoware direct inputs. A complete I²C controller normally generates them from its shift register, ACK decision logic, and timing state.
Caution: The byte transmitter must release SDA during the ACK bit.
I²C Controller Sequence

A normal transaction starts only when both bus lines are HIGH.
Repeated START is the exception.
Clock-Stretch Detection
When the controller wants SCL HIGH, it sets SCL_Release = 1.
The controller then checks the resolved bus.
Advance_High_Phase = SCL_Release · SCL_Bus
SCL_Release | SCL_Bus | Action |
|---|---|---|
| 1 | 0 | Wait |
| 1 | 1 | Advance or sample |
Arbitration-Loss Detection
Check arbitration during controller-owned address and data bits.
Arbitration_Lost_Detect =
Arbitration_Enable · SDA_Intent · SDA_Bus'
| Local Intent | Observed Bus | Result |
|---|---|---|
0 | 0 | Continue |
1 | 1 | Continue |
1 | 0 | Arbitration lost |
On loss:
- Set
Arbitration_Lost. - Release SDA and SCL.
- Stop participating.
- Do not generate STOP.
I²C Implementation Steps
- Build the two 3-input open-drain bus resolvers for SDA and SCL.
- Register previous SDA and SCL values and decode START, STOP, and SCL rising edges.
- Track the active transaction and count eight SCL rising edges.
- Generate the ninth-clock
ACK_Window,ACK_Sample,ACK_Detect, andNACK_Detectsignals. - Use the SDA ownership MUX to select
TX_BitorACK_Release. - In a larger controller, shift the address/data, observe
SCL_Busfor stretching, and compare intended SDA with the resolved bus for arbitration.
5. CAN and CAN FD Hardware Design
Controller Area Network (CAN) Overview
Controller Area Network (CAN) is a message-based serial interface for a shared bus.
Frame identifiers select the message and take part in arbitration.
CAN Controller and Transceiver

The controller handles the digital protocol.
The transceiver connects it to the physical bus.
Dominant and Recessive Bits
| Bit | Name | Meaning |
|---|---|---|
0 | Dominant | Forces the resolved bus LOW |
1 | Recessive | Releases the bus |
A dominant bit wins when nodes transmit different values.
BUS_BIT = Node0_TX · Node1_TX · ...
CAN Arbitration Hardware
The controller compares TX_BIT with BUS_BIT during the arbitration field.
ARB_LOST_Detect =
Arbitration_Enable · TX_BIT · BUS_BIT'
The learning circuit implements this expression with one native 3-input AND gate and a bubbled BUS_BIT input. It is a combinational detector only: it does not latch the event, stop the transmitter, or implement retry and fault-state behavior.
TX_BIT | BUS_BIT | Result |
|---|---|---|
| 0 | 0 | Continue |
| 1 | 1 | Continue |
| 1 | 0 | Arbitration lost |
On loss, the node stops transmitting for that attempt.
It continues observing the winning frame.
Important: Arbitration loss is not a frame error.

Direct-I/O simplification:
Arbitration_Enable,TX_BIT, andBUS_BITare direct inputs. In a complete CAN node, they come from the protocol controller and the observed transceiver/bus path;ARB_LOST_Detectthen feeds the controller's arbitration state logic.
CAN Bit Timing
| Timing Part | Function |
|---|---|
| Time quantum | Basic timing step |
| Timing segments | Divide one bit time |
| Sample point | Captures BUS_BIT |
| Synchronization | Aligns local timing to bus edges |
| Resynchronization | Applies a limited timing correction |
CAN Bit-Stuffing Sequence

The transmitter inserts one complementary bit after five equal bits.
The inserted bit does not advance the original frame counter.
The receiver removes a valid stuff bit.
It asserts STUFF_ERROR when the complement is missing.
CAN Errors and Fault States
| Error | Short Meaning |
|---|---|
| Bit error | TX and bus differ unexpectedly |
| Stuff error | Expected complement is missing |
| CRC error | CRC comparison fails |
| Form error | Fixed field has an illegal value |
| ACK error | Required acknowledge is missing |
| Fault State | Meaning |
|---|---|
| Error Active | Normal error signalling allowed |
| Error Passive | Restricted error signalling |
| Bus-Off | Node stops bus participation |
The counter rules and thresholds depend on the controller specification.
CAN Acceptance Filter
Accept = (RX_ID · MASK) == (FILTER_ID · MASK)
Accept = 1 stores the valid received frame.
Controller Area Network with Flexible Data Rate (CAN FD)
CAN FD means Controller Area Network with Flexible Data Rate.
| Feature | CAN FD Change |
|---|---|
| Payload | Larger data field |
| Data phase | Optional faster bit rate |
| Bit-rate switching | Selects the faster data phase |
| Frame control | Additional control differences |
CAN Implementation Steps
- Build the local bit-time counter and sample event.
- Generate the original frame-bit stream.
- Add dominant/recessive bus resolution.
- Compare
TX_BITwithBUS_BITduring arbitration. - Stop TX participation after
ARB_LOST_Detect. - Add the run counter and stuff-bit selector.
- Add receive de-stuffing and error checks.
- Apply the acceptance filter before RX storage.
- Store error and fault-state status.
6. Serial Interface Integration, Buffering and Reliability
Status-Signal Behavior
| Type | Behavior | Examples |
|---|---|---|
| Level | Active while the condition exists | Busy, buffer full |
| Pulse | Active for one CLK_SYS cycle | Done, event pulse |
| Sticky | Held until cleared | Error, Overrun, Timeout |
Buffer Selection
| Buffer | Use |
|---|---|
| Single register | One word at a time |
| Double buffer | Transfer one word while preparing another |
| FIFO | Store bursts or rate mismatch |
TX and RX Data Protection
| Risk | Required Protection |
|---|---|
| Active TX word overwritten | Lock it or use a separate buffer |
| Unread RX word overwritten | Preserve it and set Overrun |
| RX buffer full | Set Overflow or apply backpressure |
Clock-Domain Crossing Reuse
| Transfer Type | Reused Structure |
|---|---|
| Single asynchronous bit | Synchronizer |
| Controlled multi-bit value | Stable-data handshake |
| Continuous stream | Asynchronous FIFO |
Configuration Update Protection
Do not change active protocol settings during a transaction.
| Policy | Action |
|---|---|
| Idle-only write | Reject changes while Busy = 1 |
| Deferred update | Apply after completion |
| Shadow and commit | Copy settings at a safe boundary |
Protected settings include:
- UART baud divider
- SPI
CPOLandCPHA - I²C address
- CAN acceptance filter
Timeout and Safe Abort

The abort action must not create an illegal bus event.
Reset and Idle Outputs
| Interface | Idle Output |
|---|---|
| UART | TX = 1 |
| SPI | CS_n = 1, SCK = CPOL |
| I²C | SDA and SCL released |
| CAN | Recessive, released, or TX disabled |
Interface Selection
| Requirement | Interface |
|---|---|
| Point-to-point link without clock | UART |
| Full-duplex peripheral link | SPI |
| Addressed two-wire bus | I²C |
| Multi-node bus with arbitration | CAN or CAN FD |
Integrated Serial Interface Hardware

The protocol engine controls bit-level operation.
The buffers and status logic connect it safely to the surrounding system.
Concept understood? Let's apply and learn for real