I2C communication interview (1)

Source: Internet
Author: User

I2C communication interview (1)

In the current SoC system, many controllers are gradually integrated into the MCU. Only some simple peripherals communicate with the MCU, using the I2C protocol is the choice of many peripherals and MCU communication protocols. Generally, TP, batteryic sensor, and other devices in embedded devices use I2C communication protocols. Therefore, the use of I2C Protocol cannot be bypassed during platform development and debugging. In this article Article . Code The communication process is described only in the light of actual examples. 1, prepare platform: rk3188 devices: isl29023 (lightsensor) Tools: scoper 2, what is I2C protocol? I will not repeat the large number of online materials. Refer:
Specification for http://www.robot-electronics.co.uk/acatalog/I2C_Tutorial.html 3, isl29023i2c communication. Read byte:
Write byte: 4. Set an operation to read the 02/03 register in the software. The read result is 0x0001. According to datasheet, the optical value is a long integer, and two senders are used for storage, that is, 02/03 Reg. 02reg is a low 8-bit, 03reg is a high 8-bit, combined with value03reg + value02reg
This is the code snippet: read_reg is set to the data Reg 0x02 register, and red_len is 2.
This is the printed result:
5. communication protocols are combined with waveform analysis. Figure 1:
1) the CLK is high, and the DAT is pulled from high to low. This is the starting signal initiated by the master. 2), then send a 7-bit I2C device address + read/write bit, that is, 1000100
0 That is, from the device address 0x44, that is, isl29023 address 3), the next CLK is low, dat is high, this is an ACK signal. See datasheet instructions.
Figure 2:
The next step is to send a register address 0x02 to be operated, which is consistent with our software operation. Figure 3:
There is always an ACK signal to answer each eight-bit message. For example, the first red box is the ACK signal after the reg address is sent. If there is an ACK signal, then the master node initiates a start signal. If there is no ACK signal, that is, the slave device does not respond, the master device then improves the end signal. It is displayed that there is a normal ack signal, so it is followed by a start signal. Figure 4:
After the start signal is sent, it is sent from the device address plus a read bit, that is, 1000 1001. Figure 5:
1), the next step is to send an ACK signal. It may be noted that this Ack is different from the previous ack when the CLK is low and the DAT is low, you can check datasheet. The two ack signals are different. This is the protocol, but I still need to confirm. At the same time, after sending 8 bits, an ACK signal is required.
2), followed by the address of 0x02 sender, 0x01. Figure 6:
1) Similarly, the first red box is the ACK of the previous data. 2) because there are two registers in the function, the next step is the 8-bit data of a 0x03 register with a value of 0x00. Figure 7:
1) The first red box should have an ACK message, but this is not an ACK message, because there is no ACK signal after the end signal, and it is merged. I don't think I have any confidence, because I have previously confirmed the I2C protocol, please help me confirm. 2) In the second red box, after the communication is completed, an end signal is sent, that is, when the CLK is high, the DAT is increased from low to high. End. At this point, the value of 0x02reg is 0x01; the value of 0x03reg is 0x00. The combination is 0x0001, which is consistent with the one we printed at the beginning. Next, Linux I2C communication subsystem

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.