My ethernet device states this in the datasheet:
SCL is expected to stay low when SPI operation is idle. SPI operations start with the falling edge of SCS_N and end with
the rising edge of SCS_N. A single read or write access consists of a 27-bit command/address phase, then a 5-bit turnaround (TA) phase, then an 8-bit data phase. For burst read or write access, SCS_N is held low while SCL continues to
toggle. For every 8 cycles of SCL, the device will increment the address counter, and the corresponding data byte will
be transferred on SDI or SDO in succession.
All commands, addresses and data are transferred most significant bit first. Input data on SDI is latched on the rising
edge of clock SCL. Output data on SDO is clocked on the falling edge of SCL.
Is this mode 0?
My LCD device datasheet states this:
Only SPI mode 0 is supported.
So do I need the clk line transitioning half way through the data bit?
Thanks,
G
Yes, CLK line must transition half way through the data bit. The only question is whether 0->1 or 1->0 is
the transition we talk about. Other transition happens simultaneously with data bit changing. That is the wrong transition.
After the polarity (half-cycle timing shift) is correct, then clock phase configuration is a shift of a full clock cycle. it isn't, see edit below
It is normal that slave devices are hard-wired to support only one mode. I would do the same as slave device designer. Change the clock polarity/phase configuration of SPI peripheral on the master side.
No one remembers the mode numbers and I have seen at least once if not twice that a datasheet specification does not match reality (manufacturer copy-pasted a wrong timing diagram etc.), so just go change CPOL (working on assumption that it is definitely wrong) and go through the remaining two modes (different CPHA) to find the one of the two which works.
Edit: Fuck, I got even the CPOL / CPHA names backwards compared to Wikipedia. If I do this mistake, I'm sure many others do it as well. So just test all four combinations until it works.
Edit 2: So from the Wikipedia table, it becomes obvious that swapping
either one of the two bits swaps the sampling edge, they do not represent simply half-cycle and full-cycle delays like I initially wrote. So test all four combinations.