[00000]-[2015-07-13]-[00]-[SPI Basic Learning]

Source: Internet
Author: User

This article from http://www.cnblogs.com/king-77024128/articles/2203207.html

SPI (Serial peripheral Interface, serial Peripheral interface) is a synchronous serial data transmission standard proposed by Motorola, which is widely used in many devices.

1. Interface

The SPI interface is often referred to as a 4-wire serial bus that works in the master/slave mode and the data transfer process is initialized by the host. As shown in 1, the 4 signal lines used are:

1) SCLK: serial clock, used to synchronize data transmission, output by the host;

2) MOSI: Host output slave input data line;

3) Miso: Host input slave output data line;

4) SS: Chip selection, low active, output by the host.

On the SPI bus, there can be multiple slaves at a time, but only one host is available, and the host determines the slave to be communicated by the chip selection line. This requires the miso port of the slave to have a tri-state characteristic, which makes the line appear high impedance when the device is not selected.

2. Data transfer

Within an SPI clock cycle, the following actions are done:

1) The host sends 1 bits of data through the Mosi line and reads the 1 bits of data from the machine through the line;

2) The slave sends 1-bit data through the miso line, and the host reads the 1-bit data through the line.

This is achieved through a shift register. As shown in 2, there is a shift register between the host and slave, and the two are connected into a ring. With the clock pulse, the data is moved out of the host register and Slave register in order from high to low, and then to the slave register and host register in turn. When the contents of the register are all moved out, the equivalent of two register content Exchange is completed.

3. Clock polarity and clock phase

In the SPI operation, the two most important settings are the clock polarity (Cpol or UCCKPL) and the clock phase (Cpha or ucckph). The clock polarity sets the clock idle level, and the clock phase sets the clock edge to read the data and send the data.

The sending data of the host and slave is done at the same time, and the received data of both is completed simultaneously. Therefore, in order to ensure proper communication between the master and slave, the SPI should have the same clock polarity and clock phase.

[00000]-[2015-07-13]-[00]-[SPI Basic Learning]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.