How to determine the SPI mode?
The SPI interface is defined by two specifications, polarity and phase.
You can read more info here about the different modes.
The phase is relative to the polarity, and specifies the edge when the data is sampled.
In the sample edge the input register is shift one position. The opposite edge only refreshes the SDO pin .
From a digital point of view, we can split into fall and rise edges.
As example, If the data is sampling in the falling edge, then to ensure that the SDO pin has been refreshed correctly before we perform any readback operation, a raising edge is required first, and then for extension, the clock polarity should be 0, ensuring that the first edge will be falling.
So, the interface is defined as CPOL = 0; CPHA = 1
If not readback operation is required, then a CPOL = 1; CPHA = 0 can be used as well.
In some case, only one mode is allowed, this info is clearly specified in the datasheet.
Retrieving data ...