Electrical – How to decide CPOL and CPHA values in SPI configuration

spi

I am working on a slave device for which I have to write a Master configuration.
In the datasheet of the slave, it is mentioned, "The SDO data changes on the falling edge of the SCLK signals. The devices sample the SDI data on the rising edge of SCLK"
Can you please tell me the values of CPOL and CPHA for this slave.
Thank you

Best Answer

This is the first (oldest) answer to this question: Based only on the informations you provided (for a slave device); your statements are equivalent to:

  1. The setup of SDO (Serial Data Out) or MISO (Master In, Slave Out) occurs in the falling edge of SCK.
  2. The sample of SDI (Serial Data In) or MOSI (Master Out, Slave In) occurs in the rising edge of SCK.

This can be either Mode 0 or Mode 3 of SPI. The exact Mode depends on value of SCK in idle state .

Could be:

Mode 0: CPOL =0 (SCK=0 in idle), CPHA =0

Mode 3: CPOL=1, (SCK=1 in idle), CPHA=1

Again: Only based on informations you provided. The doubt would be removed knowing the logic state of SCK pin in idle state (no transmissions).