fopetesl
Posts: 44
Joined: Tue Oct 20, 2015 8:08 am

SPI. Full Duplex. How??

Wed Nov 11, 2015 6:41 pm

Still a Noob :(
I understand the principle that a SPI device can supposedly read and transmit data concurrently.

Problem for me is how it CAN be concurrent when I am asking for,say, a one byte result from a status register.
I think I understand that I must send two bytes, the second being a 'dummy'? to receive the desired result?
Problem in my mind is what data do I place in 'dummy' byte without prompting more response from the SPI device.

Similar conundrum if I send a one byte string and expect a 10 byte response. I send 11 bytes 10 of which are 'dummies'.

I read, sorry re-read, the SPI spec(s) and also for the MMA7455 without it being made clear.

I missed something obvious so I should revert to being the Village Idiot?

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: SPI. Full Duplex. How??

Wed Nov 11, 2015 6:51 pm

With SPI the master sends a bit then receives a bit. Repeat that 8 times and a byte is transferred in both directions (full duplex). Repeat that for each byte.

You need to read the device datasheets to see how the bits are interpreted on a device by device basis.

You are right to suggest that a lot of bits will be irrelevant as they may contain no useful information. For instance the master might send an 8 bit command to request 100 bytes. All the bytes sent after the 8 bit command from the master to the slave would be dummies. The real data would be in the 100 bytes simultaneously sent from the slave to the master.

fopetesl
Posts: 44
Joined: Tue Oct 20, 2015 8:08 am

Re: SPI. Full Duplex. How??

Wed Nov 11, 2015 7:17 pm

Thanks, Joan.
I sort of got most of that already.

It's the part about
With SPI the master sends a bit then receives a bit.
Until the 'slave' has received the request byte, eight bits if you like, it can't respond, (unless it can see the future :) ), so the 'master' needs to send a dummy byte to see the answer.

I'll take your advice and look at the data sheet again.

I'll try and come back, it might help someone else.

Return to “Interfacing (DSI, CSI, I2C, etc.)”