SPI HS single transfer question

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
Rick Burnett
Posts: 150
Joined: Tue Jan 08, 2013 2:20 pm

SPI HS single transfer question

Post 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
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: SPI HS single transfer question

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: SPI HS single transfer question

Post by Giovanni »

Hi,

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

Giovanni
Rick Burnett
Posts: 150
Joined: Tue Jan 08, 2013 2:20 pm

Re: SPI HS single transfer question

Post 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.
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: SPI HS single transfer question

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: SPI HS single transfer question

Post 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
Post Reply