The use of CPOL/CPHA settings in SPI communication

The Byzantine picture The Byzantine · Oct 21, 2012 · Viewed 10.1k times · Source

Could any one please give me real life examples where the 4 modes of CPOL/CPHA configuration in SPI communication are useful? I understand how they work but fail to know when to use them. I have read some refer shortly for compatibility purposes due to non-standard implementations, how is this so?

Thanks

Answer

Venkat Ram picture Venkat Ram · Jul 25, 2013

SPI interface allows to transmit and receive data simultaneously on two lines (MOSI and MISO). Clock polarity (CPOL) and clock phase (CPHA) are the main parameters that define a clock format to be used by the SPI bus. Depending on CPOL parameter, SPI clock may be inverted or non-inverted. CPHA parameter is used to shift the sampling phase. If CPHA=0 the data are sampled on the leading (first) clock edge. If CPHA=1 the data are sampled on the trailing (second) clock edge, regardless of whether that clock edge is rising or falling.