Which Bit Transfer and Receive First

Thread Starter

Dadu@

Joined Feb 4, 2022
155
A standard SPI device will have a MISO pin, a MOSI pin, an SCLK pin, and a SS pin. It has a data register that functions as a shift register.
Initially, suppose that Master has bits 1010 0011 in its shift register, and the slave has bits 0101 1100 in its shift register:

I want to know which bit (first MSB or first LSB) the master transfers to the slave first.

What will be the voltage on MOSI and MISO pin if the master transfer the first LSB ?
 

Ya’akov

Joined Jan 27, 2019
9,143
SPI is full duplex. This means that data is sent and received simultaneously on both MISO and MOSI. If both master and slave have data to send, when the clock is sent, both begin to send data. There isn’t one before the other in the protocol. If one starts first it is because of latency on the part of that side of the conversation, not the SPI method.

This figure shows how the bits are at exactly the same time, synchronized by the clock.

1646737590076.png
 

Thread Starter

Dadu@

Joined Feb 4, 2022
155
SPI is full duplex. This means that data is sent and received simultaneously on both MISO and MOSI.

This figure shows how the bits are at exactly the same time, synchronized by the clock.
What happens in the following case

Master has bits = 1010 0011
Slave has bits = 0101 1100

What will be the value of MOSI and MISO when the master sends one clock signal over SPI.
 

Ya’akov

Joined Jan 27, 2019
9,143
What happens in the following case

Master has bits = 1010 0011
Slave has bits = 0101 1100

What will be the value of MOSI and MISO when the master sends one clock signal over SPI.
Sorry, I misread your question.

The answer to that is it is implementation specific and is not part of the SPI protocol, which, in any case is somewhat fast and loose.

So, without a specific application there is no answer to your question it could be either one.
 

Thread Starter

Dadu@

Joined Feb 4, 2022
155
That is not what he us asking, he asks whether the LSB or MSB is transferred first.

Bob
Yes that's exactly my question.
hi,
The image shows which is first.
E
View attachment 262293
Sorry, From the image i don't understand what is happening here.

So, without a specific application there is no answer to your question it could be either one.
For example you can take AVR/PIC microcontroller and SPI ADS7038 ( Take any spi device of your choice )
 

ericgibbs

Joined Jan 29, 2010
18,845
hi Dadu,
Does help.?
Leftside is time=0
E
Added:
Transmissions normally involve two shift registers of some given word-size, such as eight bits, one in the master and one in the slave; they are connected in a virtual ring topology. Data is usually shifted out with the most significant bit first. On the clock edge, both master and slave shift out a bit and output it on the transmission line to the counterpart.

ScreenHunter 18.png
 
Last edited:

Ya’akov

Joined Jan 27, 2019
9,143
For example you can take AVR/PIC microcontroller and SPI ADS7038 ( Take any spi device of your choice )
But you can’t take ”any device”. You have to read the specs of the device(s) involved and they will tell you the answer. There is no general answer, it is implementation specific so your question has to be about something specific. And there is no point in me just randomly choosing something and saying “this one is MSB first”.

In practice, it is a configurable parameter in most SPI devices.

If you have a question about something in particular, you can read the description of that device’s implementation and find out.
 

BobaMosfet

Joined Jul 1, 2009
2,113
A standard SPI device will have a MISO pin, a MOSI pin, an SCLK pin, and a SS pin. It has a data register that functions as a shift register.
Initially, suppose that Master has bits 1010 0011 in its shift register, and the slave has bits 0101 1100 in its shift register:

I want to know which bit (first MSB or first LSB) the master transfers to the slave first.

What will be the voltage on MOSI and MISO pin if the master transfer the first LSB ?
Try little-endian first.
 

Ian0

Joined Aug 7, 2020
9,803
SPI goes MSB first. Usually there is an option for LSB first in some microcontrollers, but every peripheral i have seen is MSB first. Then there are four options for the clock phase and polarity, and they are not consistent at all.
UARTs go LSB first.
 
Top