• 0

SPI mode 0 in WaveForms SDK: what is the value of the MOSI signal during a falling edge of SCLK?


Question

If I configure the SPI with mode 0 (polarity=0 and phase=0) and LSB in WaveForms SDK in the Digital Discovery or Analog Discovery 2, and I send the byte 163=0xA3=b10100011;
I would see the following:

image.thumb.png.27ce1015691e535a5f39d16b2c3a4f78.png

Is it guaranteed that when there is a falling edge of SCLK, the MOSI takes the value just before the transition (the SCLK edge)?
What I mean is; is the following image accurate:

SPI_Mode_0_Real.thumb.jpg.6f0e0cf396fba09ebe38cac532b58479.jpg

Edited by Nicolas Gammarano
Add information about devices used
Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

The data pins must not change near where the clock has its sampling edge.

For a mode 0 SPI setup, the data is sampled on the rising edge, not the falling edge. The data changes near the falling edge.

Therefore your drawing is a bit misleading. MOSI isn't sampled just before a falling transition. It's sample a full half a clock pulse earlier. If MOSI is changing when the clock is also rising, the behavior is not well defined.

Here's a diagram.

1-21.jpg

Notice how IO is shown as changing somewhere in the middle between rising clock edges.

Here's another diagram:

4609fig03.gif

t_DS is the time before the clock edge that the data signal must have settled. t_DH is the time that the data signal must remain constant after the clock edge before the data signal is allowed to change. These are known as the setup and hold time respectively.

This diagram also shows when the other device is going to send data. For mode 0, this happens on the falling edge of the clock after a delay of TD0 like you drew in your second diagram.

I hope this helped!

Edited by maxwellfire
clarify the issue with OPs diagram
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now