plc.myforum.ro Forum Index plc.myforum.ro
PLCs users www.plc.myforum.ro!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SPI - Serial Peripheral Interface

 
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> PLC Tutorials
View previous topic :: View next topic  
Author Message
go
Member
Member


Joined: 26 Mar 2015
Posts: 147

PostPosted: 19/02/2017 14:40    Post subject: SPI - Serial Peripheral Interface Reply with quote

SPI - Serial Peripheral Interface

The three most common multi-wire serial data transmission formats that have been in use for decades are I2C, UART, and SPI. This article looks at the Serial Peripheral Interface (SPI) Bus, which has escaped explicit standardization, so always check the datasheet of the integrated circuit that you are working with before you implement the protocol.

The Serial Peripheral Interface Bus provides full-duplex synchronous communication between a master device and a slave using four data lines.
The Serial Peripheral Interface allows bits of data to be shifted out of a master device into a slave, and at the same time, bits can be shifted out of the slave into the master.


SPI  - Serial Peripheral Interface SPI  - Serial Peripheral Interface
Animation 1 shows data shifted out of Microchip A into Microchip B, and from Microchip B into Microchip A.

SPI  - Serial Peripheral Interface SPI  - Serial Peripheral Interface
Animation 2 shows a virtual 4-channel oscilloscope trace of an SPI transaction between two microchips. Created with Mathematica by Mark Hughes

SPI  - Serial Peripheral Interface SPI  - Serial Peripheral Interface
Bits that are sampled on the rising edge of the clock cycle are shifted out on the falling edge of the clock cycle, and vice versa.

Each transaction begins when the slave-select line is driven to logic low (slave select is typically an active-low signal). The întocmai relationship between the slave-select, data, and clock lines depends on how the clock polarity (CPOL) and clock phase (CPHA) are configured.

With non-inverted clock polarity (i.e., the clock is at logic low when slave select transitions to logic low):

Mode 0: Clock phase is configured such that data is sampled on the rising edge of the clock pulse and shifted out on the falling edge of the clock pulse. This corresponds to the first blue clock trace in the above diagram. Note that data must be available before the first rising edge of the clock.
Mode 1: Clock phase is configured such that data is sampled on the falling edge of the clock pulse and shifted out on the rising edge of the clock pulse. This corresponds to the second blue clock trace in the above diagram.

With inverted clock polarity (i.e., the clock is at logic high when slave select transitions to logic low):

Mode 2: Clock phase is configured such that data is sampled on the falling edge of the clock pulse and shifted out on the rising edge of the clock pulse. This corresponds to the first orange clock trace in the above diagram. Note that data must be available before the first falling edge of the clock.
Mode 3: Clock phase is configured such that data is sampled on the rising edge of the clock pulse and shifted out on the falling edge of the clock pulse. This corresponds to the second orange clock trace in the above diagram.

Terms
CLK: Serial Clock. Controlled by the master device. A new data bit is shifted out with each clock cycle.
SSN: Slave Select (the "N" identifies it as an active-low signal). Controlled by the master device. An active slave-select line indicates that the master is sending data to or requesting data from the corresponding slave device.
MOSI: Master Out ⇒ Slave In. Data leaves the master device and enters the slave device. MOSI lines on chip A are connected to MOSI lines on chip B.
MISO: Master In ⇐ Slave Out. Data leaves the slave device and enters the master device (or another slave, in a daisy-chain configuration; see the next section). MISO lines on chip A are connected to MISO lines on chip B.
CPOL: Clock Polarity. This governs the initial logic state of the clock signal. Refer to the previous section for more information.
CPHA: Clock Phase. This governs the relationship between the data transitions and the clock transitions. Refer to the previous section for more information.
Conclusion
The Serial Peripheral Interface has been around for decades, and there is no reason to expect it to go away anytime soon. While I2C and UART might enjoy more popularity, SPI is a versatile and straightforward serial-communications interface that is excellent for certain applications.

SPISettings
https://www.arduino.cc/en/Reference/SPISettings
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> PLC Tutorials All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro