SPI Modes

SPI knows 4 "standard" modes, reflecting the SCK's polarity (CPOL) and the SCK's phase (CPHA).

SPI Mode CPOL CPHA
0 (or 0,0) 0 0
1 (or 0,1) 0 1
2 (or 1,0) 1 0
3 (or 1,1) 1 1

The meaning is:

CPOL:
  • 0 = Clock Idle low level
  • 1 = Clock Idle high level
CPHA:
  • 0 = SDO transmit edge (*) active to idle
  • 1 = SDO transmit edge idle to active
(*): the transmit edge is the clock edge at which the SDO level changes.

In a timing diagram this looks like(only one clock pulse shown here):


The Transmit edge is the clock edge at which the SPI output data changes,
The Sampling edge is the clock edge at which the sampling of the SPI input data takes place.
The sampling edge is normally the opposite one of the transmit edge.


References: www.rosseeld.be, dlnware.com

No comments:

Post a Comment