SPI-02: Timing Modes — CPOL, CPHA & the Four Modes — VLSI Trainers
SPI Series · Article 2 of 6

SPI-02: Timing Modes

CPOL, CPHA, and the four SPI timing modes — how clock polarity and phase interact to define exactly when data is driven and sampled. All four modes with waveforms and worked examples.

Why Timing Modes Exist

When two chips communicate over SPI, they must agree not just on what data to exchange, but on when the data must be stable and when it is sampled. Different SPI peripheral manufacturers made different choices here, leading to four valid timing configurations. Neither master nor slave can change this after fabrication — it is fixed in the hardware design of each peripheral.

If the master and slave are configured for different timing modes, bits will be sampled at the wrong clock edges, and every byte received will be corrupted silently — SPI has no built-in error detection. This makes understanding timing modes one of the most practically important aspects of working with SPI in real designs.

Real-world consequence: Misconfigured CPOL/CPHA is one of the most common bugs when bringing up a new SPI peripheral. If your ADC or display controller returns garbage data, check the timing mode first. Always cross-reference the datasheet’s timing diagram against your controller’s CPOL/CPHA register settings.

📶CPOL — Clock Polarity

Clock Polarity (CPOL) defines what level SCLK holds when the channel is idle — that is, when no exchange is in progress (SS is HIGH).

Figure 1 — CPOL=0 vs CPOL=1 idle states and first edges
CPOL = 0 SS SCLK 1st edge = RISING idle=0 idle=0 CPOL = 1 SS SCLK 1st edge = FALLING idle=1 idle=1 Summary: CPOL=0 → SCLK idle LOW → first clock edge is RISING CPOL=1 → SCLK idle HIGH → first clock edge is FALLING Exchange starts when SS goes LOW CPOL does NOT affect clock frequency — only idle level

CPOL determines the idle level of SCLK and therefore which edge is the “first” edge after SS asserts LOW.

📐CPHA — Clock Phase

Clock Phase (CPHA) determines the relationship between when data is driven onto the bus and when it is sampled. It answers the question: on which edge does the receiver latch each bit?

Memory aid: Think of CPHA as “does the data need a head start?” CPHA=0 → data gets a head start (set up before the first edge). CPHA=1 → data changes on the first edge, sampled on the second.
Figure 2 — CPHA=0 vs CPHA=1 data setup and sample timing (CPOL=0 shown)
CPHA = 0 (sample on 1st edge) SCLK DATA D7 D6 D5 D4 D3 ↑ sampled on 1st edge (rising) data changes on 2nd edge (falling) CPHA = 1 (sample on 2nd edge) SCLK DATA D7 D6 D5 D4 D3 data driven on 1st edge (rising) ↑ sampled on 2nd edge (falling) CPHA=1 gives a full half-period of setup time before the sample edge — better metastability margin

CPHA=0 (top): data is set up before the first clock edge; sampled on each first (rising) edge. CPHA=1 (bottom): data is driven on each first edge; sampled on each second (falling) edge — giving a full half-period of setup time.

🔢The Four Mode Combinations

CPOL and CPHA each have two possible values, giving exactly four combinations. These are commonly numbered Mode 0 through Mode 3:

ModeCPOLCPHAClock idle levelData sampled onUsed by
Mode 000LOWRising (1st) edgeMost common — Arduino default, many ADCs
Mode 101LOWFalling (2nd) edgeSome SD cards, CAN controllers
Mode 210HIGHFalling (1st) edgeSome ADCs, certain sensors
Mode 311HIGHRising (2nd) edgeST7735 display, MAX31865
MODE 0 — CPOL=0, CPHA=0 (most common)
  • SCLK idles LOW
  • Data set up before SS asserts
  • Sampled on each rising edge
  • Changes on each falling edge
MODE 1 — CPOL=0, CPHA=1
  • SCLK idles LOW
  • Data driven on first rising edge
  • Sampled on each falling edge
  • Changes on each rising edge
MODE 2 — CPOL=1, CPHA=0
  • SCLK idles HIGH
  • Data set up before SS asserts
  • Sampled on each falling edge (1st)
  • Changes on each rising edge (2nd)
MODE 3 — CPOL=1, CPHA=1
  • SCLK idles HIGH
  • Data driven on first falling edge
  • Sampled on each rising edge (2nd)
  • Changes on each falling edge (1st)
Notice Modes 0 and 3 both sample on rising edges; Modes 1 and 2 both sample on falling edges. This means a master can often switch between Mode 0 and Mode 3 by simply changing CPOL without changing which physical edge samples data — though the idle clock level changes. The same symmetry holds for Modes 1 and 2.

Mode 0 — CPOL=0, CPHA=0, MSB First

The most widely used mode. SCLK idles LOW. Data (MOSI and MISO) is set up half a clock period before the first rising edge, then sampled on each rising edge and changed on each falling edge.

Figure 3 — Mode 0: CPOL=0, CPHA=0, MSB first — complete 8-bit exchange
CPOL=0, CPHA=0, MSB first SS SCLK MOSI MISO 1 2 3 4 5 6 7 8 1 0 1 0 0 1 0 1 MOSI = 1010 0101 = 0xA5 0 0 1 1 1 1 0 0 MISO = 0011 1100 = 0x3C Purple dashed lines = rising edges = sample points. Data set up before first edge, changes on falling edges.

Mode 0 (CPOL=0, CPHA=0, MSB first). MOSI transmits 0xA5; MISO returns 0x3C. Both lines are sampled simultaneously on every rising clock edge.

Mode 1 — CPOL=0, CPHA=1, MSB First

SCLK still idles LOW (CPOL=0), but now data is driven on the rising edge and sampled on the falling edge. This gives a full half-period of setup time before each sample.

Figure 4 — Mode 1: CPOL=0, CPHA=1, MSB first
CPOL=0, CPHA=1, MSB first SS SCLK MOSI MISO 1 2 3 4 5 6 7 8 1 0 1 0 0 1 0 1 0 0 1 1 1 1 0 0 Data changes on rising edges; sampled on falling edges (2nd through 9th). Note extended DC region at start.

Mode 1 (CPOL=0, CPHA=1). Data is driven on each rising edge and sampled on the following falling edge. The don’t-care region at the start is longer than in Mode 0 — no data is ready until SS goes low AND the first rising edge occurs.

Mode 2 — CPOL=1, CPHA=0, LSB First

SCLK idles HIGH (CPOL=1). The first clock edge is therefore a falling edge. With CPHA=0, data is set up before this first falling edge and sampled on it. Data then changes on the rising edges between bits.

Figure 5 — Mode 2: CPOL=1, CPHA=0, LSB first
CPOL=1, CPHA=0, LSB first SS SCLK MOSI MISO 1 2 3 4 5 6 7 8 1 0 1 0 0 1 0 1 MOSI LSB-first 0 0 1 1 1 1 0 0 CPOL=1: SCLK idles HIGH. Sampled on FALLING edges (1st through 8th). Data changes on RISING edges.

Mode 2 (CPOL=1, CPHA=0, LSB first). Clock idles HIGH. Sampled on falling edges. Notice how the clock waveform is the inversion of Mode 0.

Mode 3 — CPOL=1, CPHA=1, LSB First

SCLK idles HIGH (CPOL=1). Data is driven on the first (falling) edge and sampled on the second (rising) edge. This is the mirror of Mode 1, and like Mode 0 and Mode 3 share the same sample edge polarity (rising).

Figure 6 — Mode 3: CPOL=1, CPHA=1, LSB first
CPOL=1, CPHA=1, LSB first SS SCLK MOSI MISO 1 2 3 4 5 6 7 8 1 0 1 0 0 1 0 1 0 0 1 1 1 1 0 0 Data driven on FALLING edges; sampled on RISING edges (2nd through 9th). Both CPOL=1 modes idle HIGH.

Mode 3 (CPOL=1, CPHA=1, LSB first). Clock idles HIGH. Data driven on falling edges, sampled on rising edges — same sample polarity as Mode 0, but inverted idle state.

🔀Bit Ordering — MSB First vs LSB First

The SPI protocol does not specify which end of a byte is transmitted first. Both master and slave must use the same bit ordering or every received byte will be bit-reversed.

🔍 Worked Example — MSB vs LSB first for the same byte

Byte to transmit: 0xA5 = 1010 0101₂

MSB first (bit 7 → bit 0): 1 0 1 0 0 1 0 1
First bit on wire = bit 7 = 1. Last bit = bit 0 = 1.

LSB first (bit 0 → bit 7): 1 0 1 0 0 1 0 1
First bit on wire = bit 0 = 1. Last bit = bit 7 = 1.

In this example both orderings happen to produce the same sequence because 0xA5 is palindromic. Try with 0xB5 = 1011 0101:
MSB first: 1 0 1 1 0 1 0 1 → receiver sees 0xB5
LSB first: 1 0 1 0 1 1 0 1 → receiver reassembles as 0xAD if it reads MSB-first

Rule: Always check whether the peripheral datasheet specifies MSB or LSB first. Most modern SPI peripherals use MSB-first. The UART and I²C protocols, by contrast, always use LSB-first.

🔬VLSI Connections

🔬 CPOL/CPHA in RTL design

When implementing an SPI master in SystemVerilog, CPOL determines the reset value of your SCLK output register (sclk_r <= CPOL), and CPHA determines whether you drive MOSI on the first or second clock edge of each bit period. A parameterised SPI master module will have CPOL and CPHA as parameters so the same RTL can target any timing mode. RTL interview questions frequently ask you to implement SPI — the first thing you say should be: "What are the CPOL and CPHA requirements?"

🔬 Setup and hold time analysis

The aperture time concept from SPI-01 maps directly to STA (Static Timing Analysis) in VLSI. CPHA=1 gives one full half-period (t_period/2) of setup time before the sample edge — this is exactly the concept of setup time margin in STA. The falling edge of SCLK (the "drive" edge in Mode 1) corresponds to the launch edge in STA, and the rising edge (the "sample" edge) corresponds to the capture edge. SCLK frequency must be low enough that propagation delay through the slave's combinational logic fits within the half-period.

🔬 Logic analyser / oscilloscope decoding

When debugging an SPI bus on a PCB with a logic analyser (e.g. Saleae, Rigol), the first configuration step is always selecting CPOL and CPHA. An incorrectly configured decoder will silently produce wrong decoded values — the most common error is leaving CPOL=0 CPHA=0 when the actual device uses Mode 3. The waveform shapes in this article give you the visual intuition to identify the mode from the oscilloscope trace before you even open a datasheet: if SCLK is HIGH between transactions → CPOL=1. If data is stable for one full half-period before and after sample edge → CPHA=0.

Summary — SPI-02 key points: CPOL sets the idle level of SCLK (0=LOW, 1=HIGH). CPHA sets which clock edge samples data (0=first edge, 1=second edge). Four modes result. Mode 0 (CPOL=0, CPHA=0) is the most common. Bit ordering (MSB vs LSB first) is independent of the mode and must also be agreed between master and slave. Misconfigured timing mode causes silent data corruption — SPI has no error detection.
Scroll to Top