1. SPI (serial peripheral interface of serial peripheral interface): high-speed, full-duplex, synchronous serial port.
Three or four signals are used for data exchange:
Simo: Inbound and Outbound
Somi: Inbound and Outbound
Uclk: the clock, which is driven by the host and used by the slave to send and receive data.
Ste: Allows sending from the slave machine. It is used to control multiple slaves in multiple Master/Slave systems in four-line mode.
Three-line spi: sclk, SDO, and SDI ).
The SPI bus allows multiple SPI devices to connect to each other.
The SPI device that provides the SPI serial clock is the SPI host or master, and other devices are the SPI slave or slave ).
Full duplex communication can be achieved between the master and slave devices. When there are multiple slave devices, you can also add a select line from the device. The four-line SPI mode uses an additional control line to allow sending and receiving of data from the slave machine, which is controlled by the host.
The SPI interface synchronizes serial data transmission between the CPU and peripheral low-speed devices. Under the shift pulse of the main device, the data is transmitted by bit, with the highest position in front and the lowest position in the back, full Duplex Communication.
If you use a general IO port to simulate the SPI bus, you must have an output port (SDO), one input port (SDI), and the other port depends on the type of the implemented device, if you want to implement a Master/Slave Device, You need to input the output port. If you want to implement only the master device, you need to output the port. If you want to implement only the slave device, you only need to input the port.
UART requires a fixed baud rate, while SPI does not matter because it has a clock protocol.
The SPI interface is mainly used between EEPROM, Flash, real-time clock, AD converter, digital signal processor, and digital signal decoder.
2. I2C (Inter IC Bus) interface definition:
The I2C bus is a bidirectional two-wire (SCL-serial clock, SDA-serial data line) Synchronous Serial Bus,Competitive detection and arbitration mechanismAllows multiple hosts to send data at any time without damaging the data information on the bus. It is ideal for close-range and non-regular data communication between devices. In its protocol system,The device address of the target device is included in the data transmission process.To achieve device networking.
Features:
A. Each device connected to the bus can be addressed by a unique IP address of the software and establish a simple master-slave relationship. The master device can be either a transmitter or a receiver.
B. synchronous clock allows devices to communicate with each other at different baud rates through the bus.
C. synchronous clock can be used as a handshake for stopping and restarting serial port sending
D. The number of integrated connectors connected to the same bus is limited only by the total capacity of the bus capacitor of 400pf.
If you use a general IO port to simulate I2C bus and implement bidirectional transmission, you need an input/output port (SDA) and an output port (SCL ).
Note: The serial data lines SDA and serial clock lines of the I2C bus must pass through the pull-up resistor RP and be connected to the active source, the output of the device connected to the bus must be in the form of "Opening" or "Opening" to complete the "line and" function.
I2C requires two-way Io support, and it uses up-pull resistance, which has weak anti-interference ability. It is generally used for communication between chips on the same board and is rarely used for long-distance communication.
The differences between interfaces are as follows:
1. The uart and usart areas cannot be mentioned. usart is new, but I cannot tell the difference between them. UART is a two-line interface, one sending and one receiving device can communicate with each other in full duplex mode, and the number of lines is relatively small. Data is transmitted asynchronously, with strict timing requirements on both parties, and the communication speed is not fast. It is used most frequently for multi-host communication.
2. Compared with the UART above, the SPI interface has an additional synchronous clock line. The disadvantage of the UART above is its advantages, the timing requirements of both parties are not strict and can be easily combined between different devices, and the communication speed is very fast. It is generally used for high-speed data communication between components of the product, such as large-capacity storage.
3. the I2C interface is also a two-line interface. It transmits data between two lines through a complex logical relationship. The communication speed is not high, and the programming is also complicated. Generally, the single-chip microcomputer system is mainly used to connect to small memory such as 24c02.
Instance:
Http://wenku.baidu.com/view/e1e43860caaedd3383c4d360
Use picsingle-chip serial port to implement spigot and i2cmain line communication