You are here

SPI BiDirectional Newbie in need of help! | Cypress Semiconductor

SPI BiDirectional Newbie in need of help!

Summary: 4 Replies, Latest post by Bob Marlowe on 29 Sep 2014 07:08 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
Gytis's picture
2 posts

Hello All,


I am an absolute newbie to SPI and using it with these PSoCs.

I have not found adequate documentation or examples on how to perform SPI Master READ.

I am able to write data to the SPI slave device, however how do you read data?

Using Oscilloscope, I can see that the SCLK pin is driven during a write operation, but it is not being driven during a read command!!! (It remains low)

I call:





PSOC_DEBUG_BUF[15] = SPIM_ReadRxData();

I can see SCLK and SDIO is driven during the two write cycles, and the correct bits are set, however SCLK is never driven for the SPI Slave Device to write data!!

How is SCLK driven for read mode?

-Thank you!


Gytis's picture
2 posts



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.

GORE's picture
Cypress Employee
18 posts

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.


user_78878863's picture
2553 posts

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.

user_1377889's picture
9294 posts

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.



Log in to post new comments.