SPI Modes
There are 4 SPI modes defined by the clock polarity (CPOL) and the clock phase (CPHA) which defines which edge the data is sampled on.
MODE | CPOL | CPHA |
---|---|---|
0 | 0 | 0 |
1 | 0 | 1 |
2 | 1 | 0 |
3 | 1 | 1 |
SPI Mode 0 Waveforms
SCLK starts low. Data is sampled on rising edge.
{
"signal": [
{"name":"SCLK", "wave":"l.P.......l"},
{
"name":"MOSI",
"wave":"x22222222x.", "data":["0","1","2","3","4","5","6","7"],
"phase": -0.25
},
{
"name":"MISO",
"wave":"x22222222x.", "data":["0","1","2","3","4","5","6","7"],
"phase": -0.25
},
{"name":"CS", "wave":"10........1"}
]}
SPI Mode 1 Waveforms
SCLK starts low. Data is sampled on falling edge.
{
"signal": [
{"name":"SCLK", "wave":"l.p.......l"},
{
"name":"MOSI",
"wave":"xx22222222x", "data":["0","1","2","3","4","5","6","7"],
"phase": 0.25
},
{
"name":"MISO",
"wave":"xx22222222x", "data":["0","1","2","3","4","5","6","7"],
"phase": 0.25
},
{"name":"CS", "wave":"10........1"}
]}
SPI Mode 2 Waveforms
SCLK starts high. Data is sampled on falling edge.
{
"signal": [
{"name":"SCLK", "wave":"h.N.......h"},
{
"name":"MOSI",
"wave":"x22222222x.", "data":["0","1","2","3","4","5","6","7"],
"phase": -0.25
},
{
"name":"MISO",
"wave":"x22222222x.", "data":["0","1","2","3","4","5","6","7"],
"phase": -0.25
},
{"name":"CS", "wave":"10........1"}
]}
SPI Mode 3 Waveforms
SCLK starts high. Data is sampled on rising edge.
{
"signal": [
{"name":"SCLK", "wave":"h.n.......h"},
{
"name":"MOSI",
"wave":"x.22222222x", "data":["0","1","2","3","4","5","6","7"],
"phase": 0.25
},
{
"name":"MISO",
"wave":"x.22222222x", "data":["0","1","2","3","4","5","6","7"],
"phase": 0.25
},
{"name":"CS", "wave":"10........1"}
]}
Diagrams Courtesy WaveDrom
The diagrams above are displayed using the WaveDrom javascript library.