- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
SPIM_WriteTxData(0x80);
while((SPIM_ReadTxStatus()&8)==0);
SPIM_WriteTxData(0x10);
while((SPIM_ReadTxStatus()&8)==0);
SPIM_TxDisable();
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
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
NEVERMIND ,
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Bob