SOLVED - SPI Clock and Modes

Thread Starter

Sparsh45

Joined Dec 6, 2021
143
I am still confused after reading the general SPI communication documents

The SPI always sends and receives a byte at the same time. at the end of the 8 pulses they will completely exchange byte.

SPI mode depends on clock edge and clock polarity

The edge of the clock can either rising or falling.

The polarity of the clock can be high or low.

If I select High Polarity and Rising edge for master and slave.

On which edge, data will in and which edge, data will out ?
 

Thread Starter

Sparsh45

Joined Dec 6, 2021
143
hi 45,
The Master and Slave have to be set to the same Mode.
Look at this link, simple breakdown of the methods.

Note the RED vertical data xfer lines.
E
https://dlnware.com/theory/SPI-Transfer-Modes
When master and slave is configured for High Polarity and Rising edge.

My understanding, data is entered on one edge, then it is out on the other edge.

On which edge, data will in and which edge, data will out ?
 

Thread Starter

Sparsh45

Joined Dec 6, 2021
143
Hi,
Setting CPOL = 1 & CPHA=1 in the REST state means the data is Clocked on the Rising edge.

E
View attachment 255805
Thanks for the posting picture.

If I'm not mistaken the SS/CS signal should be at the top of the picture because the SS/CS signals start the SPI communication. When the transaction starts it is set to low and when the transaction ends it is set to high.

I see the datasheet of the pic microcontroller, it has four modes and can be configured for any of them.

Does SPI mode depends on the slave device which mode it supports ? We can configure the pic uC for the mode it supports.
 

ericgibbs

Joined Jan 29, 2010
18,766
Does SPI mode depends on the slave device which mode it supports
hi,
The Master is so called because it controls all the data exchange signals sent to the Slave.
The Master has to be set to suit the Slave, which usually has it Mode fixed, but some Slave peripherals can be self programmed to alternate Modes,

BUT Master and Slave must be set to the same Mode.

E
 

Thread Starter

Sparsh45

Joined Dec 6, 2021
143
How far micro and slave devices can be connected? So far I see connecting in a short distance only.

Can the distance between these two be 1m, 10m, more then 30m.

I know this question doesn't make much sense. anyway Is there a reason why it can't be connected over long distances. is it possible or is it not possible to connect over long distance ?
 
Last edited:

nsaspook

Joined Aug 27, 2009
13,086
How far micro and slave devices can be connected? So far I see connecting in a short distance only.

Can the distance between these two be 1m, 10m, more then 30m.

I know this question doesn't make much sense. anyway Is there a reason why it can't be connected over long distances. is it possible or is it not possible to connect over long distance ?
https://www.ti.com/lit/an/slyt441/slyt441.pdf
 

ericgibbs

Joined Jan 29, 2010
18,766
What happens on the falling edge of the clock ?
Does Slave clocks data in on the falling edge of the clock ?
Hi S45,
Are you reading my posts.? ??

I posted:
Setting CPOL = 1 & CPHA=1 in the REST state means the data is Clocked on the Rising edge.
The data is captured on the clock's low-to-high transition

What happens on the falling edge of the clock ?
The data is internally propagated on high-to-low clock transition.

Does Slave clocks data in on the falling edge of the clock ?
No, it's already been Clocked on the Rising/Leading edge of the clock.

Read the Data Transmission section of this link.

https://embetronicx.com/tutorials/tech_devices/spi-serial-peripheral-interface-protocol-basics/
 
Top