News Centerposition:Baoxingwei > News Center > 正文
【Tips】Microcontroller I2C and SPI communication differences
Edit:Baoxingwei Technology | Time:2023-03-30 14:26 | Number of views:117
I2C and SPI are two different communication protocols.
Hearing the agreement, it seems unattainable. In fact, the agreement is a standard defined by people. As long as we follow this standard to do things, we can. For example, the company says that we work at 9 a.m., so we work at 9 a.m., or we lose our pay. It's an agreement.
EEPROM chips are commonly used for I2C communication, such as Atmel's AT24CXX series, in addition, there are some other functional chips. The chips that use SPI to communicate are external FLASH chips, as well as chips that do other things.
I2C communication requires two pins: SDA SCL. SCL is the clock pin and SDA is the data pin.
( the EEPROM chip) ( the clock chip)
SPI communication requires 3 pins or 4 pins: CS SCK MOSI MISO. The pin names of SPI communication chips may not all be these names, there may be other names, but the meaning is the same, for example, MOSI pin means "host output from machine input", a SPI interface chip may be written as SDI, because the SPI device is a slave machine. So its SDI stands for "slave data input pin".
The SPI communication process is: pull down the CS pin, then SCK output clock, then can output data on the MOSI pin, at the same time can get data on MISO.
(This is an SPI FLASH chip, DO is MISO, DI is MOSI, CLK is SCK, the function is the same, but the name is different)
(This is an SPI interface ADC chip, Dout is MISO, DCLOCK is SCK, this chip has three SPI pins)
Most microcontrollers have I2C ports and SPI ports, and there may be several I2C ports and SPI ports. However, the microcontroller without I2C port and SPI port can also communicate by simulating their timing with common pins.
And, if you are a beginner, be sure to learn to use common pin simulation, to understand the nature of their communication more deeply.
The whole communication process is actually the process of controlling the high and low level of the pin and detecting the high and low level of the pin. In other words, controlling the high and low level of the pin of the single-chip microcomputer and detecting the high and low level of the pin can be done by the single-chip microcomputer. Therefore, there is nothing difficult about I2C communication and SPI communication.
The article and pictures are from DZSC