CASE SOLVED--- SPI is not a standard serial programming interface (send byte, receive byte)
There is a huge difference... SPI alternates data senders (master/slave) every bit, not between bytes.
Hi Gytis, Please find attached example project for SPI bidirectional implementation. Kindly go through the project. As mentioned in the example project we need to clear the SPIS and SPIM FIFOs as specified and also we need to initiate a dummy SPIM write operation (when SPIM Tx is disabled) in order to generate SCLK as required by the slave. Hope the example project will be helpful for you. Thanks, Goverdhan
SPI does not 'alternate' the direction 'per bit' - its just full-duplex (which means that data can be transferred in both directions at the same time).
So when a slave transmits data to the master, the clock needs to be working, so the master needs to generate it. To do that, typically a dummy value is transmitted by the master.
When using SPI in bidirectional mode have a look at the two pictures in the SPI datasheet page 2. They show exactly what is going on.
Clock is always generated by the master.
Data is always fed back into the sender (master or slave)
The SPI interface is byte-oriented, there is no direction-switching at bit-wise level.