Page 1 of 1

SPI HS single transfer question

Posted: Thu Aug 11, 2016 5:39 am
by Rick Burnett
I've been reading through different messages on the board and I'm trying to figure out how to do non-DMA high speed transfers over SPI.

The board does NOT have the NSS pin running to the /SYNC pin of the DAC I am using, so I have to software toggle the SYNC pin after every 16-bit transfer.

As probably expected, using spiSend is slow for this.

What I don't understand is spiPolledExchange wants data back, but I the DAC has no communication pin to attach to MISO so how do I tell it nothing is coming back in? Not sure I understand how to work in this mode.

Rick

Re: SPI HS single transfer question

Posted: Thu Aug 11, 2016 8:25 am
by steved
It's inherent in the way SPI works that you can both send and receive data at the same time.
If you have no data to receive, just ignore it.
If MISO is brought out, just tie it to a known level (as good wiring practice). If there's no MISO pin configured, I imagine the device would do this internally.

Re: SPI HS single transfer question

Posted: Thu Aug 11, 2016 8:49 am
by Giovanni
Hi,

spiPolledExchange() is the best solution for small frequent transfers. As steved described, just ignore incoming data.

Giovanni

Re: SPI HS single transfer question

Posted: Thu Aug 11, 2016 4:32 pm
by Rick Burnett
Excellent, I didn't realize the data came back at the same time, is the full-duplex mode? In any case, implemented it last night and the performance is great.

Re: SPI HS single transfer question

Posted: Thu Aug 11, 2016 5:39 pm
by steved
SPI is implemented using a shift register, generally 8-bit on processors.
So as you clock data out, you inherently can clock data in, and save every 8 clock cycles if desired.

Re: SPI HS single transfer question

Posted: Thu Aug 11, 2016 5:40 pm
by Giovanni
SPI by its nature inputs one bit and outputs one bit on a clock edge, there is no RX and TX, it is the same thing, the two ends of a shift register.

Edit: LOL, one minute late.

Giovanni