Design of Analog SPI

Source: Internet
Author: User

Fundamentals and Structure of SPI
  • The Serial Peripheral Interface (SPI) is a low-cost, easy-to-use interface developed by Motorola to enable data exchange between microcontrollers and peripheral chips. Unlike the standard serial interface, the SPI is a synchronous protocol interface, full-duplex communication, where all transmissions refer to a common clock, and this synchronous clock signal is generated by the host. The peripheral that receives the data synchronizes the reception of the serial bit stream using the clock. The transmission speed is up to a few MB/s.

    The SPI mainly uses 4 signals: Miso (host input/slave output), MOSI (host output/slave input), SCLK (serial clock), or (peripheral chip selection or slave selection).

    The miso signal is generated by the slave under the control of the host machine. The signal is used to disable or enable the transceiver function of the peripheral. For high-level, the peripherals are forbidden to receive and transmit data, and the peripherals are allowed to receive and transmit data for low-power. Figure 1 shows that the microprocessor is connected to the peripheral through the SPI.

    Both the host and slave have a serial shift register, and the host initiates a transmission by writing a byte to its SPI serial register. The register transmits bytes to the slave via the MOSI signal line, and the slave also returns the contents of its shift register to the host (shown in 2) via the miso signal line. In this way, the contents of the two shift registers are exchanged. The write and read operations of the peripherals are synchronized.

    If only write operations, the host only need to ignore the bytes received, conversely, if the host to read a slave byte, you must send an empty byte to raise the slave transmission.

    When the host sends a continuous stream of data, some peripherals are capable of multi-byte transmission. Most memory chips with an SPI interface work in this way. In this mode of transmission, the slave's chip selection must remain low during the entire transmission process. At this point, a transmission may involve thousands of bytes of information, without having to detect the start and end bits of each byte before and after the data is sent, which is why the synchronous transmission is better than the asynchronous transmission mode.

    Although SPI has the above advantages, but in the image transmission is seldom used, the main reason is that its anti-jamming ability is poor. SPI uses a single-ended unbalanced transmission, that is, the voltage level of the transmitted data bits is publicly referenced. In this mode of transmission, the interference in the incoming signal can not be eliminated and weakened. And the signal in the transmission process will always be disturbed, and the longer the interference is more serious, so that the signal transmission caused errors. In this condition, the signal transmission becomes meaningless. In addition, because the single-ended unbalanced transmission is a common reference point, the ground is used as the signal return line, so there is also a signal current. When there is an AC potential difference between the systems at both ends of the transmission line, the potential differences will be directly channeling into the signal to form noise disturbances. Therefore, in order to solve the anti-jamming problem, usually adopt the balanced transmission (balanced transmission) way, here uses the more common RS-422.

Routines:

/*=================================================================================spi_exchangebyte (); Function:exchange a byte via the SPI Busintput:input, the input byteoutput:the output byte from the SPI bus========= ========================================================================*/ui08 spi_exchangebyte (ui08 input) {unsignedChari;      Ui08 Temp_byte,rxbyte; Temp_byte=input;  for(i =0; I <8; i++)    {                    if(temp_byte&0x80) Mosi_set;//SDI = 1;        Elsemosi_clr;//SDI = 0;Rxbyte=rxbyte<<1; SCK_CLR;//SCK = 1;Sck_set;//SCK = 0;Temp_byte <<=0x01; if(miso_sta==1) {Rxbyte|=byte_bit0; }         Else{rxbyte&=~byte_bit0; }                                      }    return(Rxbyte);}

Design of Analog SPI

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.