A multi-channel synchronous parallel I2C communication method, system, and electronic device

By adopting multi-channel synchronous parallel method in I2C communication and using GPIO interface phase point operation, the synchronization and bandwidth occupation problems in I2C communication are solved, efficient multi-channel synchronous data test and measurement is achieved, the system load is reduced and the cost advantage is achieved .

CN117708032BActive Publication Date: 2024-10-25SUZHOU NOVOSENSE MICROELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311723748.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-14
Publication Date
2024-10-25
Estimated Expiration
2043-12-14

AI Technical Summary

Technical Problem

I2C communication is difficult to achieve synchronous communication in multi-channel scenarios, and it occupies bandwidth when communicating with high-speed devices, reducing system efficiency and making it difficult to expand the number of measurement channels.

Method used

The multi-channel synchronous parallel I2C communication method is used to generate trigger signals through preset counting cycles and sub-target numbers. The GPIO interface is used to simulate the I2C bus channel and data is written and read at three phase points to achieve synchronous parallel communication and reduce CPU resources. occupied.

Benefits of technology

It realizes multi-channel synchronous parallel I2C communication, reduces CPU resource occupation, improves test and measurement efficiency, is suitable for multi-channel synchronous data test and measurement, and has low cost and high reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117708032B_ABST
    Figure CN117708032B_ABST
Patent Text Reader

Abstract

The present application discloses a multi-channel synchronous parallel I2C communication method, system, and electronic device. The method includes counting according to a preselected clock signal within a preset counting cycle, comparing the current count value with at least three preset sub-target numbers respectively, and generating a trigger signal; using a GPIO interface to simulate multiple I2C bus channels, and the bit period of I2C communication includes at least three phase points; obtaining data pre-written to the GPIO interface at the first phase point according to a first trigger signal and storing it in the output data memory of the GPIO interface; obtaining data pre-written to the GPIO interface at the second phase point according to a second trigger signal and storing it in the output data memory of the GPIO interface; and reading data from the input data memory of the GPIO interface according to a third trigger signal. The synchronous communication of multiple I2C bus channels simulated by the GPIO interface is realized, and the CPU resource occupation is greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of data communication technology, and specifically relates to a multi-channel synchronous parallel I2C communication method, system, and electronic device. Background Art

[0002] I2C communication is one of the most basic communication methods between devices and plays an extremely important role in electronic systems. It is widely used in various electronic systems such as industrial automation, medical, consumer, test and measurement, etc. These systems include scenarios where an I2C master device communicates with a single or multiple I2C slave devices. For example, a CPU acts as an I2C master device and is connected to various I2C slave devices, including sensors, ADCs, DACs, etc. with various I2C interfaces. As a communication bridge between master devices and slave devices, I2C plays an irreplaceable role.

[0003] However, I2C communication also has many limitations in many applications. For example, multiple ADCs, DACs, and sensors with I2C interfaces are mounted in an MCU system. It is difficult to use a general solution to communicate synchronously with all I2C devices, and synchronization is a typical requirement in test measurement and industrial control. The conventional I2C operation method is serial asynchronous communication to achieve multi-channel data measurement, and each I2C device communicates in sequence. To solve the synchronization problem, additional phase compensation is often required, which is not only difficult but also not available in all systems. Another limitation of I2C communication is that I2C devices are low-speed devices, and there is a problem of occupying the bandwidth of high-speed devices when communicating with high-speed devices. For example, if the CPU runs a real-time operating system, the I2C communication thread will occupy the CPU for a long time, reducing the operating efficiency of the system.

[0004] In the field of test and measurement, increasing the number of DUTs that can be measured simultaneously is the main means to reduce measurement costs. For devices under test with I2C interfaces, increasing the number of measurement channels is also an urgent problem to be solved. Summary of the invention

[0005] Technical purpose: This application aims to provide a multi-channel synchronous parallel I2C communication method for realizing multi-channel, synchronous and parallel I2C interface communication without occupying high-speed devices for a long time.

[0006] In order to achieve the above technical objectives, this application adopts the following technical solutions.

[0007] In a first aspect, an embodiment of the present application provides a multi-channel synchronous parallel I2C communication method, comprising:

[0008] Within a preset counting period, counting is performed according to a preselected clock signal to obtain a current counting value;

[0009] Comparing the current count value with at least three preset sub-target numbers respectively to obtain comparison results, and generating at least three corresponding trigger signals respectively according to the comparison results;

[0010] Using the GPIO interface to simulate multiple I2C bus channels, the bit period of the I2C communication includes at least three phase points, the phase points correspond to the number of sub-targets one by one, wherein the first phase point is located at the beginning of the bit period, the second phase point is located at the rising edge of the signal of the I2C clock line within the bit period, and the third phase point is located at the high level of the signal of the I2C clock line within the bit period;

[0011] According to the first trigger signal, the data pre-written to the GPIO interface at the first phase point is obtained, and stored in the output data memory of the GPIO interface; according to the second trigger signal, the data pre-written to the GPIO interface at the second phase point is obtained, and stored in the output data memory of the GPIO interface; according to the third trigger signal, the data is read from the input data memory of the GPIO interface at the third phase point and stored in a designated area.

[0012] In a second aspect, an embodiment of the present application provides a multi-channel synchronous parallel I2C communication system, including:

[0013] A counting module, wherein the counting module counts according to a preselected clock signal within a preset counting period to obtain a current counting value;

[0014] A comparison module, wherein the comparison module compares the current count value with at least three preset sub-target numbers to obtain comparison results, and generates at least three corresponding trigger signals according to the comparison results;

[0015] A GPIO interface, the GPIO interface is used to simulate multiple I2C bus channels, the bit period of the I2C communication includes at least three phase points, the phase points correspond to the sub-target numbers one by one, wherein the first phase point is located at the beginning of the bit period, the second phase point is located at the rising edge of the signal of the I2C clock line within the bit period, and the third phase point is located at the high level of the signal of the I2C clock line within the bit period;

[0016] A direct access storage module, the direct access storage module is used to obtain the data pre-written to the GPIO interface at the first phase point according to the first trigger signal and store it in the output data memory of the GPIO interface; obtain the data pre-written to the GPIO interface at the second phase point according to the second trigger signal and store it in the output data memory of the GPIO interface; read the data from the input data memory of the GPIO interface at the third phase point according to the third trigger signal and store it in a designated area.

[0017] In a third aspect, an embodiment of the present application provides an electronic device, including: a multi-channel synchronous parallel I2C communication system provided by any possible embodiment of the second aspect.

[0018] Beneficial effect: Compared with the prior art, the multi-channel synchronous parallel I2C communication method provided by the embodiment of the present application presets at least three sub-target numbers related to the bit period of the I2C bus, and the three sub-target numbers are respectively related to the three phase points on the bit period of the I2C communication. The jump of the clock line and the data line of the I2C bus can be determined according to the three predetermined sub-target numbers. By counting and comparing the current count value with the three sub-target numbers to generate a corresponding trigger signal, the data of each I2C bus channel is synchronously sent to the data output register of the GPIO interface at the first phase point and the second phase point, and the signal on the data line of each I2C bus channel is read from the data input register of the GPIO interface at the third phase point. The communication protocol of the I2C bus is simulated by controlling the level change of the GPIO interface, which not only realizes the synchronous communication of multiple I2C bus channels simulated by the GPIO interface, but also greatly reduces the occupation of CPU resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0020] Figure 1 This is the schematic diagram of the NCA9548 multi-channel I2C application circuit;

[0021] Figure 2 This is a schematic diagram of FPGA / CPLD multi-channel I2C application;

[0022] Figure 3 A schematic flow chart of a multi-channel synchronous parallel I2C communication method provided in Example 1 of the present application;

[0023] Figure 4 A schematic diagram of the division of phase points in a multi-channel synchronous parallel I2C communication method provided in Example 1 of the present application;

[0024] Figure 5 A timing waveform diagram of a write operation of a multi-channel synchronous parallel I2C communication method provided in Example 1 of the present application;

[0025] Figure 6 A timing waveform diagram of a read operation of a multi-channel synchronous parallel I2C communication method provided in Example 1 of the present application;

[0026] Figure 7 A schematic diagram of the structure of a multi-channel synchronous parallel I2C communication system provided in Example 2 of the present application;

[0027] Reference numerals:

[0028] 1-multi-channel synchronous parallel I2C communication system, 11-counting module, 12-comparison module, 13-direct access storage module, 14-GPIO interface, 111-automatic reload register, 112-timer, 121-first comparison register, 122-second comparison register, 123-third comparison register, 131-first direct access storage unit, 132-second direct access storage unit, 133-third direct access storage unit, 141-output data storage, 142-input data storage, 143-GPIO pin, 151-first write data storage unit, 152-second write data storage unit, 161-read data storage module, 101-first sub-target number, 102-second sub-target number, 103-third sub-target number, 104-first trigger signal, 105-second trigger signal, 106-third trigger signal. Specific embodiments

[0029] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.

[0030] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein.

[0031] In addition, it should be understood that in the following description, "circuit" refers to a conductive loop composed of at least one element or subcircuit through electrical connection or electromagnetic connection. When an element or circuit is said to be "connected to" another element or an element / circuit is said to be "connected between" two nodes, it can be directly coupled or connected to another element or there can be an intermediate element, and the connection between the elements can be physical, logical, or a combination thereof. On the contrary, when an element is said to be "directly coupled to" or "directly connected to" another element, it means that there is no intermediate element between the two.

[0032] I2C (Inter-Integrated Circuit) is a serial communication protocol used to communicate between devices in a digital system. The I2C bus consists of two signal lines: SCL (clock line) and SDA (data line). SCL is controlled by the master device and is used to provide a clock signal. SDA is used to transfer data between the master device and the slave device.

[0033] Each device connected to the bus has an independent address, and the host can use this address to access different devices. The I2C bus adopts an open-drain design, and the bus is connected to the power supply through a pull-up resistor (the pull-up resistor is generally 4.7k). When the IC device is idle, it will output a high-impedance state, and when all devices are idle, they will all output a high-impedance state, and the pull-up resistor will pull the bus to a high level.

[0034] To facilitate understanding of this application, the I2C protocol is briefly introduced below.

[0035] When the SDA and SCL signal lines of the I2C bus are both at high level, it is defined as the idle state of the bus. At this time, the output stage field effect transistors of each device are in the cut-off state, that is, the bus is released, and the level is pulled up by the pull-up resistors of the two signal lines.

[0036] When SCL is at a high level, the jump of SDA from high to low is the start signal of the IIC bus. The start signal and stop signal are generally generated by the host. When SCL is a high level device, the jump of SDA from low to high is the stop signal.

[0037] At the beginning of communication, the master device sends a device address to select the slave device to communicate with. The device address is the unique identifier of the slave device, and each slave device has a unique address. After sending the device address, the master device sends a read / write bit to indicate the direction of communication. The read bit indicates that the master device wants to read data from the slave device, and the write bit indicates that the master device wants to send data to the slave device. After the device address and the read / write bit, data can be transferred between the master and the slave device. Data is transferred over the SDA line, and each data byte is transferred on the edge of the clock. The master and slave devices synchronize data transfer through the control of the clock signal. After each data byte is transmitted, the receiver sends an acknowledgement bit (ACK) to confirm the receipt of the data. The ACK bit is sent by the receiver pulling SDA low when SCL is low, indicating that the data has been received.

[0038] For methods of expanding multi-channel I2C, existing technologies include Figure 1 As shown in the figure, CPU or MCU is used as the I2C communication master device, and multi-channel I2C device data communication is realized through analog switch switching or I2C HUB chips such as NCA9548. This solution needs to select the channel that needs to be tested and measured according to the communication protocol specified by NCA9548, so as to realize serial I2C multi-channel test and measurement.

[0039] like Figure 1 The solution shown only solves the expansion of multiple channels, and this solution requires setting up the I2C expansion chip first and selecting the channel that needs to communicate before the I2C data test and measurement can be performed normally. Therefore, data test and measurement can only be performed in a serial manner, which not only occupies a large amount of CPU resources, but also has a slow communication efficiency, making it difficult to achieve multi-channel synchronous data test and measurement.

[0040] Existing methods for expanding multi-channel I2C also include: Figure 2 The solution shown in the figure uses FPGA or CPLD as the I2C multi-channel communication management platform, establishes an IIC connection with the communication slave device through the preset IO interface, and can synchronously obtain data information in parallel and store it in the preset storage medium. Figure 2 As shown, the coding program used inside the FPGA / CPLD can easily process and summarize information, and the IO port of the FPGA / CPLD supports most levels and can be connected to various other devices of different levels, which is also convenient for testers to test and debug IIC communication.

[0041] but Figure 2 The solution shown uses FPGA / CPLD as a platform, the system is relatively complex, the reliability cannot be effectively guaranteed, and the price is high, so it is not suitable for large-scale batch testing.

[0042] The embodiments of the present application are described in detail below in conjunction with the accompanying drawings.

[0043] Embodiment 1

[0044] This embodiment provides a multi-channel synchronous parallel I2C communication method, including:

[0045] Step S101: within a preset counting period, counting is performed according to a preselected clock signal to obtain a current counting value.

[0046] Step S102: Compare the current count value with at least three preset sub-target numbers to obtain comparison results, and generate at least three corresponding trigger signals according to the comparison results.

[0047] Step S103: Use the GPIO interface to simulate multiple I2C bus channels. The bit period of I2C communication includes at least three phase points. The phase points correspond to the number of sub-targets one by one. The first phase point is located at the beginning of the bit period, the second phase point is located at the rising edge of the signal of the I2C clock line within the bit period, and the third phase point is located at the high level of the signal of the I2C clock line within the bit period.

[0048] According to the first trigger signal, the data pre-written to the GPIO interface at the first phase point is obtained and stored in the output data memory of the GPIO interface; according to the second trigger signal, the data pre-written to the GPIO interface at the second phase point is obtained and stored in the output data memory of the GPIO interface; according to the third trigger signal, the data is read from the input data memory of the GPIO interface at the third phase point and stored in the designated area.

[0049] In step S101, a timer may be used for counting. As an example, step S101 includes: using a timer to count a preselected clock to obtain a current count value; wherein the count period of the timer is the bit period of I2C communication, and when the timing time reaches the bit period, the current count value in the timer is automatically cleared to perform timing for the next count period.

[0050] In a specific embodiment, the preselected clock may be a high-speed clock, and the high-speed clock may be an internal clock of a high-speed device (such as an MCU).

[0051] The timer period of a timer refers to the length of time it takes for the timer to complete a full count. The timing period of the timer must be equal to the period corresponding to the frequency of I2C communication, that is, the timing period of the timer is determined as the bit period of I2C communication. In I2C communication, the bit period of I2C communication refers to the time required to transmit one bit.

[0052] It is understandable that the timer needs to be pre-configured, which is not the invention point of the present application and will not be described in detail.

[0053] The at least three sub-target numbers preset in step S102 are related to the bit period of the I2C bus, and the three sub-target numbers are respectively related to the three phase points on the bit period. The jump of the clock line and the data line of the I2C bus can be determined according to the predetermined three sub-target numbers.

[0054] For step S103, as an example, Figure 4 As shown, each bit period is divided into three phase points, the first phase point phase0, the second phase point phase1 and the third phase point phase2. The first phase point phase0 is located at the beginning of the bit period, the second phase point phase1 is located at the rising edge of the signal of the I2C clock line of the bit period, and the third phase point phase2 is located at the high level of the signal of the I2C clock line of the bit period. In this embodiment, SCL and SDA are written at one phase point phase0, SCL is written at the second phase point phase1, and data is read from the data line SDA at the third phase point phase2. It can be understood that when SCL is written at the second phase point phase1, SDA also needs to be written, and SDA needs to maintain the data of the first phase point phase0.

[0055] It can be understood that according to the I2C communication protocol, data is transmitted through the SDA line, and each data byte is transmitted at the edge of the clock, so the first phase point phase0 and the second phase point phase1 are necessary, and thus it is also necessary to determine the first sub-target number and the second sub-target number of the first phase point phase0 and the second phase point phase1.

[0056] In addition, data needs to be read from the data line, so it is also necessary to set the third phase point phase2 to read the data after a certain delay of the second phase point phase1, so it is also necessary to determine the third sub-target number of the third phase point.

[0057] The embodiment of the present application uses a GPIO interface to simulate multiple I2C bus channels. The GPIO (General Purpose Input / Output) interface is a general interface for interacting with external devices for digital signals. It can be used to read the state of an external device (input) or control the state of an external device (output). The GPIO interface is usually composed of multiple GPIO pins, each of which can be independently configured as an input or output mode and connected to an external device. Each GPIO pin has a corresponding register for controlling and reading its state. GPIO-IDR (Input Data Register) is a register in the GPIO interface for reading the state of the input pin. By reading the GPIO-IDR register, the current state of the GPIO pin, that is, the input state of the external device, can be obtained. GPIO-ODR (Output Data Register) is a register in the GPIO interface for writing the state of the output pin. By writing the GPIO-ODR register, the output state of the GPIO pin can be controlled, that is, the state of the external device can be controlled. Therefore, GPIO-IDR and GPIO-ODR are two important registers in the GPIO interface, which are used to read and write the status of GPIO pins. Before using GPIO-IDR and GPIO-ODR, it is usually necessary to pre-configure the relevant GPIO pins, including GPIO mode setting, GPIO speed setting, GPIO pull-up and pull-down setting, GPIO multiplexing function setting (optional), etc.

[0058] Optionally, the GPIO interface includes multiple GPIO pins, one GPIO pin among the multiple GPIO pins simulates the clock lines of all I2C bus channels, and all or part of the remaining GPIO pins are selected to simulate the data lines of each I2C bus channel respectively.

[0059] In a specific embodiment, the preset value of the comparison register (i.e. the corresponding sub-target number) is compared with the current count value obtained by the timer, and a trigger signal is generated when it exceeds. It is understandable that the comparison register needs to be pre-configured, which is not the invention point of this application and will not be described in detail.

[0060] Optionally, the data pre-written to the GPIO interface at the first phase point phase0 is acquired according to the first trigger signal using the direct access memory and stored in the output data memory of the GPIO interface; the data pre-written to the GPIO interface at the second phase point phase1 is acquired according to the second trigger signal using the direct access memory and stored in the output data memory of the GPIO interface; the data read from the input data memory of the GPIO interface at the third phase point phase2 according to the third trigger signal is read using the direct access memory and stored.

[0061] Direct Memory Access (DMA) is a data transfer technology that allows peripherals (such as hard disks, network adapters, etc.) to transfer data directly to and from the memory without direct intervention from the CPU. Before directly accessing the memory for reading and writing, the CPU first needs to configure the DMA controller to specify the source address (such as the data buffer of the peripheral) and the destination address (such as the data buffer in the memory) of the data transfer, as well as the length of the data to be transferred. The peripheral sends a DMA request signal to the DMA controller to request data transfer. In this application, at least three trigger signals corresponding to at least three phase points in the bit period of I2C communication are respectively sent out through comparison registers. After the DMA controller receives the DMA request signal, the DMA controller directly accesses the peripheral and the memory through the bus, reads the data from the peripheral buffer into the memory, or writes the data from the memory to the peripheral buffer. This process does not require CPU intervention, and the DMA controller directly controls the transmission of data.

[0062] It can be understood that the multi-channel synchronous parallel I2C communication method provided in the embodiment of the present application can be applied to simulate one I2C channel to solve the problem that the current I2C device occupies the bandwidth of the high-speed device when communicating with the high-speed device.

[0063] Specifically, taking an I2C channel as an example, the write operation timing diagram is as follows: Figure 5 As shown, the read operation timing is as follows Figure 6As shown. When a write operation is required, the waveform data of each I2C bus channel needs to be integrated, that is, each bit of the I2C serial data to be written is sorted into a phase sequence, and the phase sequence data of the first phase point and the phase sequence data of the second phase point are sent in sequence according to the three trigger signals generated by the timer. At the third phase point, data is read from the data line, and the sequence corresponding to all bits of the data to be written is sent, that is, a complete write operation I2C waveform is sent. Take an I2C communication bit cycle as an example, write 1 to the data line SDA in the I2C communication bit cycle, such as SCL of the first phase point (phase0) is 0, and SDA of the first I2C bus channel is 1. In some embodiments, such as including 15 I2C bus channels, at the same time, all channel data are consistent, and SDA is 1, then the data of the first phase point after integration is: 0xFFFE, and 0xFFFE is stored in the first write data storage area memory-send0. If the SCL of the second phase point (phase1) is 1, and the SDA of the 15 I2C bus channels are all written as 1, then the data of the second phase point after integration is: 0xFFFF, and 0xFFFF is stored in the second write data storage area memory-send1. During the data writing process, data is read from SCL and SDA at the third phase point (phase2), and the data read at this stage is not concerned.

[0064] like Figure 5As shown, the start signal is realized by two cycles (-1 and 0), in the first cycle, both SCL and SDA are set high, in the second cycle, SCL is high and SDA is pulled low, representing the start signal of communication; the write data bit consists of one cycle, and according to the I2C communication protocol, the states of SCL and SDA in each cycle are saved in the form of data. Optionally, the data pre-written to the GPIO interface at the first phase point and the data pre-written to the GPIO interface at the second phase point can be stored in the write data storage area memory-send (which can be stored in the first write data storage area memory-send0 and the second write data storage area memory-send1 respectively), such as random access memory (Random Access Memory, RAM), waiting for DMA (Direct Memory Access (DMA) Access, DMA) moves the data to the corresponding GPIO-ODR bit; the ACK bit (also called confirmation bit or response bit) consists of a cycle, and the data read from the data line SDA at the second phase point phase2 of the cycle is used as the ACK signal. If the slave device successfully receives the data or address, it will send a low-level response signal to indicate successful reception. If the slave device fails to correctly receive the data or address, or the slave device cannot process the host's request, it will send a high-level non-response signal to indicate that the reception failed or cannot be processed. The nop signal is mainly used to distinguish each byte of data. During this cycle, SCL and SDA are both pulled low.

[0065] like Figure 6 As shown, each cycle is divided into three phase points. The first phase point phase0 is for writing SCL and SDA, and the second phase point phase1 is for writing SCL. It can be understood that when writing SCL at the second phase point phase1, SDA also needs to be written, and SDA needs to maintain the data of the first phase point phase0. The third phase point phase2 is for reading the data line SDA. When a read operation is required, the I2C waveform data also needs to be integrated, that is, the data sequences read from the first phase point phase0, the second phase point phase1, and the third phase point phase2 are sorted according to certain rules to obtain the data for the read operation.

[0066] Take an I2C communication bit cycle as an example. In this bit cycle, data is read from the data line SDA. If the SCL at the first phase point (phase0) is 0, because the I2C bus is an open-drain output, the SDA of all I2C bus channels must be written as 1. Then the data corresponding to the first phase point is: 0xFFFE, and 0xFFFE is stored in the first write data storage area memory-send0. If the SCL at the second phase point (phase1) is 1, because the I2C bus is an open-drain output, the SDA of all I2C bus channels must be written as 1. Then the data at the second phase point after integration is: 0xFFFF, and 0xFFFF is stored in the second write data storage area memory-send1. At the third phase point, data is read from SDA, and the read data is stored in the read register momory-receive.

[0067] like Figure 6 As shown, the start signal is realized by two cycles (-1 and 0). In the first cycle, both SCL and SDA are set high. In the second cycle, SCL is high and SDA is pulled low, which represents the start signal of communication. The write data bit consists of one cycle. According to the I2C communication protocol, the status of SCL and SDA in each cycle is saved in the write data storage area memory-send in the form of data, waiting for DMA to move the data to the corresponding GPIO-ODR bit. The read data bit consists of one cycle. During this cycle, the SDA status obtained at the third phase point phase2 is saved in the read data storage area memory-receive in the form of data. The ACK bit consists of one cycle, and the data read from the data line SDA at the third phase point phase2 of this cycle is used as the ACK signal. The nop signal is mainly used to distinguish each byte data. During this cycle, SCL and SDA are both pulled low.

[0068] When synchronous parallel I2C communication is required, turn on the timer and start counting to obtain the current count value. When the current count value reaches the first sub-target number and the first trigger signal is issued (corresponding to the first phase point phase0), the first direct access memory DMA1 takes the data to be sent from memory-send and moves it to the corresponding GPIO-ODR (SCL & SDA) bit to achieve the effect of simulating IO port operation. When the second sub-target number is reached and the first trigger signal is issued (corresponding to the second phase point phase1), the second direct access memory DMA2 takes the data to be sent from momory-send and moves it to the corresponding GPIO-ODR (SCL) bit. When the third sub-target number is reached and the third trigger signal is issued (corresponding to the third phase point phase2), the third direct access memory DMA3 receives the data from GPIO-IDR (SDA) and moves it to momory-receive.

[0069] Optionally, when the I2C clock line SCL signal jumps to a high level, the SDA signal may not have stabilized to the correct level. In order to make the signal on the read data line more stable, the third phase point is located at the moment after the I2C clock line signal jumps to a high level within the bit period and the delay is preset. Before reading the SDA signal, it is necessary to wait for a while to ensure that the SDA signal is stable and reaches a valid level.

[0070] In some embodiments, in order to make the timing control of the I2C bus more precise, in addition to the three phase points of the bit period corresponding to the above three sub-target numbers, more sub-target numbers can also be set to determine more phase points of the clock signal. For example, by setting the fourth sub-target number, the fourth phase point is determined. The fourth phase point can also be located at the high level of the signal of the I2C clock line, and there is a certain delay time between it and the second phase point to ensure the stability of the signal on the data line.

[0071] The multi-channel synchronous parallel I2C communication method provided in the embodiment of the present application uses GPIO group operation to simulate multi-channel I2C synchronous communication, so all channels can share the same SCL, and the number of SDAs (N-1) depends on the number of interfaces (N) of the corresponding GPIO of the hardware.

[0072] In some embodiments, since the SDA data bus status is read in each bit cycle and stored in the memory-receive buffer, the memory-receive contains a large amount of useless information when the data read operation is performed. Therefore, data parsing is required to index the single bit data of each channel in channel order for splicing to obtain the final data read from each channel.

[0073] It should be noted that the multi-channel synchronous parallel I2C communication method provided in the embodiment of the present application is marked with steps 101 to 103 only for the convenience of expression. Those skilled in the art can understand that in the above method of the specific embodiment, the writing order of each step does not mean a strict execution order and constitutes any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.

[0074] The multi-channel synchronous parallel I2C communication method provided in the embodiment of the present application realizes the transformation from existing serial communication to parallel communication, greatly improving the test and measurement efficiency; and from serial asynchronous communication to parallel synchronous communication; solves the problem of I2C occupying CPU / MCU and reduces the load of the system. The method also has the advantages of low cost and high reliability.

[0075] Embodiment 2

[0076] Corresponding to the multi-channel synchronous parallel I2C communication method provided in the above embodiment, as Figure 7 As shown, this embodiment provides a multi-channel synchronous parallel I2C communication system 1, including a counting module 11, a comparing module 12, a GPIO interface 14 and a direct access storage module 13.

[0077] The counting module 11 counts according to the preset clock signal within the preset counting cycle to obtain the current counting value; the comparison module 12 compares the current counting value with at least three preset sub-target numbers to obtain comparison results, and generates at least three corresponding trigger signals according to the comparison results.

[0078] The GPIO interface 14 is used to simulate multiple I2C bus channels. The I2C bus includes a clock line and a data line. The bit period of the I2C communication includes at least three phase points. The phase points correspond to the sub-target numbers one by one, wherein the first phase point is located at the beginning of the bit period, the second phase point is located at the rising edge of the signal of the I2C clock line within the bit period, and the third phase point is located at the high level of the signal of the I2C clock line within the bit period.

[0079] The direct access storage module 13 is used to obtain the data pre-written to the GPIO interface at the first phase point according to the first trigger signal and store it in the output data memory of the GPIO interface; obtain the data pre-written to the GPIO interface at the second phase point according to the second trigger signal and store it in the output data memory of the GPIO interface; and read the data from the input data memory of the GPIO interface according to the third trigger signal and store it in the designated area.

[0080] In some embodiments, the system further includes a write data storage module and a read data storage module.

[0081] The write data storage module is used to store the data to be written to the GPIO interface at the first phase point and the data to be written to the GPIO interface at the second phase point. It should be noted that, as described above, when a write operation is required, the waveform data of each I2C bus channel needs to be integrated. The specific integration method is as described in the above embodiment and will not be described in this embodiment.

[0082] When a read operation is required, the I2C waveform data also needs to be integrated, that is, the data sequences read from the first phase point phase0, the second phase point phase1 and the third phase point phase2 are sorted according to certain rules to obtain the data for the read operation. The details can be as described in the above embodiment, and will not be repeated in this embodiment.

[0083] The read data storage module is used to store data to be read from the GPIO interface at the third phase point.

[0084] In some embodiments, Figure 7 As shown, the counting module 11 includes an auto-reload register 111 and a timer 112 (or timer). The auto-reload register 111 is a special register used in the timer or timer 112. It is used to set the reload value of the timer or timer 112 to achieve the function of automatic reset or cyclic counting. The auto-reload register 111 allows the initial value of the timer or timer 112 to be set, and automatically resets to the initial value when the timer or timer 112 reaches the value, thereby achieving periodic timing or counting.

[0085] The comparison module 12 at least includes a first comparison register 121 , a second comparison register 122 and a third comparison register 123 .

[0086] The direct access storage module 13 includes a first direct access storage unit 131 , a direct access storage unit 132 , and a direct access storage unit 133 .

[0087] The write data storage module includes at least a first write data storage unit 151 and a second write data storage unit 152; the first write data storage unit 151 is used to store data pre-written to the GPIO interface at a first phase point; the second write data storage unit 152 is used to store data pre-written to the GPIO interface at a second phase point. The read data storage module includes at least one read data storage unit 161.

[0088] The first comparison register 121 is used to compare the current count value with the preset first sub-target number 101 to obtain a first comparison result, and generate a first trigger signal 104 according to the comparison result; the first direct access storage unit 131 obtains the data pre-written to the GPIO interface 14 at the first phase point from the first write data storage unit 151 according to the first trigger signal 104 and stores it in the output data storage 141 of the GPIO interface 14.

[0089] The second comparison register 122 is used to compare the current count value with the preset second sub-target number 102 to obtain a second comparison result, and generate a second trigger signal 105 according to the comparison result; the second direct access storage unit 132 obtains the data pre-written to the GPIO interface 14 at the second phase point from the second write data storage unit 152 according to the second trigger signal 105 and stores it in the output data storage 141 of the GPIO interface 14.

[0090] The third comparison register 123 is used to compare the current count value with the preset third sub-target number 103 to obtain a third comparison result, and generate a third trigger signal 106 according to the comparison result; the third direct access storage unit 133 is used to read data from the input data memory 142 of the GPIO interface 14 at a third phase point according to the third trigger signal 106 and store it in the read data storage unit 161.

[0091] In some embodiments, a multi-channel synchronous parallel I2C communication system 1 can be implemented using an MCU. MCU stands for Microcontroller Unit, which is an integrated circuit chip that is a special microprocessor with a CPU (central processing unit), memory (such as flash memory and SRAM), input / output interfaces, and other peripheral components. An MCU with GPIO pin requirements that meets the requirements can be selected to support the required number of I2C bus channels.

[0092] The multi-channel synchronous parallel I2C communication system 1 provided in this embodiment solves the problem of occupying CPU / MCU resources in 2-wire I2C communication. This solution is not only applicable to multi-channel synchronous test and measurement, but also to single-channel test and measurement solutions, effectively reducing the CPU / MCU load; this embodiment can realize the transition from serial asynchronous communication to parallel synchronous communication, and can support multi-channel I2C bus data-transmission, and has a wide range of applications, such as realizing multi-channel DC data synchronous acquisition.

[0093] Embodiment 3

[0094] This embodiment provides an electronic device, including: the above multi-channel synchronous parallel I2C communication system.

[0095] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A multi-channel synchronous parallel I2C communication method, characterized in that: The method comprises: Within a preset counting period, counting is performed according to a preselected clock signal to obtain a current counting value; Comparing the current count value with at least three preset sub-target numbers respectively to obtain comparison results, and generating at least three corresponding trigger signals according to the comparison results respectively; Using a GPIO interface (14) to simulate multiple I2C bus channels, the bit period of the I2C communication includes at least three phase points, the phase points correspond to the sub-target numbers one by one, wherein the first phase point is located at the beginning of the bit period, the second phase point is located at the rising edge of the signal of the I2C clock line, and the third phase point is located at the high level of the signal of the I2C clock line; According to the first trigger signal, the data pre-written to the GPIO interface (14) at the first phase point is obtained, and the data is stored in the output data memory (141) of the GPIO interface (14); according to the second trigger signal, the data pre-written to the GPIO interface (14) at the second phase point is obtained, and the data is stored in the output data memory (141) of the GPIO interface (14); according to the third trigger signal, the data is read from the input data memory (142) of the GPIO interface (14) at the third phase point and stored in a designated area.

2. The multi-channel synchronous parallel I2C communication method according to claim 1, characterized in that: The method comprises: The data pre-written to the GPIO interface (14) at the first phase point includes data pre-written simultaneously to the I2C clock line and the I2C data line; The data pre-written into the GPIO interface (14) at the second phase point includes data pre-written into the I2C clock line; The data to be read from the GPIO interface (14) at the third phase point is the data of the I2C data line.

3. The multi-channel synchronous parallel I2C communication method according to claim 1, characterized in that: The GPIO interface (14) comprises a plurality of GPIO pins (143), one GPIO pin (143) among the plurality of GPIO pins (143) simulates the I2C clock lines of all I2C bus channels, and all or part of the remaining GPIO pins (143) are selected to respectively simulate the I2C data lines of each I2C bus channel.

4. The multi-channel synchronous parallel I2C communication method according to claim 1, characterized in that: Counting is performed according to a preselected clock signal to obtain a current count value, including the following steps: Counting the preselected clock signal using a timer to obtain a current count value; the counting period of the timer is the bit period of I2C communication; When the timing time reaches the bit cycle, the current count value in the timer is automatically cleared to start the timing of the next count cycle.

5. The multi-channel synchronous parallel I2C communication method according to claim 4, characterized in that: The method comprises: and / or, using a comparison register to compare the current count value with at least three preset sub-target numbers respectively, to obtain comparison results, and generating at least three corresponding trigger signals respectively according to the comparison results; And / or, using a direct access memory to obtain data pre-written to the GPIO interface (14) at the first phase point according to the first trigger signal and store it in an output data memory (141) of the GPIO interface (14); obtaining data pre-written to the GPIO interface (14) at the second phase point according to the second trigger signal and store it in the output data memory (141) of the GPIO interface (14); and reading and storing data in an input data memory (142) of the GPIO interface (14) according to a third trigger signal.

6. The multi-channel synchronous parallel I2C communication method according to claim 5, characterized in that: The third phase point is located at a time after the signal of the I2C clock line jumps to a high level and is delayed for a preset time.

7. A multi-channel synchronous parallel I2C communication system (1), characterized in that: The system comprises: A counting module (11), wherein the counting module (11) counts according to a preselected clock signal within a preset counting cycle to obtain a current counting value; A comparison module (12), wherein the comparison module (12) compares the current count value with at least three preset sub-target numbers to obtain comparison results, and generates at least three corresponding trigger signals according to the comparison results; A GPIO interface (14), the GPIO interface (14) is used to simulate multiple I2C bus channels, the bit period of the I2C communication includes at least three phase points, the phase points correspond to the sub-target numbers one by one, wherein the first phase point is located at the beginning of the bit period, the second phase point is located at the rising edge of the signal of the I2C clock line, and the third phase point is located at the high level of the signal of the I2C clock line; A direct access storage module (13), the direct access storage module (13) is used to obtain data pre-written to the GPIO interface (14) at a first phase point according to the first trigger signal and store it in an output data storage (141) of the GPIO interface (14); obtain data pre-written to the GPIO interface (14) at a second phase point according to the second trigger signal and store it in the output data storage (141) of the GPIO interface (14); and read data from the input data storage (142) of the GPIO interface (14) at a third phase point according to the third trigger signal and store it in a designated area.

8. The multi-channel synchronous parallel I2C communication system according to claim 7, characterized in that: The system also includes a data storage writing module and a data storage reading module; The write data storage module is used to store data pre-written to the GPIO interface (14) at the first phase point and data pre-written to the GPIO interface (14) at the second phase point; The read data storage module is used for storing data to be read from the GPIO interface (14) at the third phase point.

9. The multi-channel synchronous parallel I2C communication system according to claim 8, characterized in that: The comparison module (12) comprises at least a first comparison register (121), a second comparison register (122) and a third comparison register (123); The direct access storage module (13) comprises at least a first direct access storage unit (131), a second direct access storage unit (132) and a third direct access storage unit (133); The write data storage module comprises at least a first write data storage unit (151) and a second write data storage unit (152); the first write data storage unit (151) is used to store data pre-written to the GPIO interface (14) at a first phase point; the second write data storage unit (152) is used to store data pre-written to the GPIO interface (14) at a second phase point; The read data storage module comprises at least one read data storage unit (161); The first comparison register (121) is used to compare the current count value with a preset first sub-target number (101) to obtain a first comparison result, and generate a first trigger signal (104) according to the comparison result; The first direct access storage unit (131) acquires the data pre-written to the GPIO interface (14) at the first phase point from the first write data storage unit (151) according to the first trigger signal and stores the data in the output data storage (141) of the GPIO interface (14); The second comparison register (122) is used to compare the current count value with a preset second sub-target number (102) to obtain a second comparison result, and generate a second trigger signal (105) according to the comparison result; The second direct access storage unit (132) acquires the data pre-written to the GPIO interface (14) at the second phase point from the second write data storage unit (152) according to the second trigger signal and stores the data in the output data storage (141) of the GPIO interface (14); The third comparison register (123) is used to compare the current count value with a preset third sub-target number (103) to obtain a third comparison result, and generate a third trigger signal (106) according to the comparison result; The third direct access storage unit (133) is used to read the data from the input data storage (142) of the GPIO interface (14) according to the third trigger signal and store the data in the read data storage unit (161).

10. An electronic device, characterized in that: include: A multi-channel synchronous parallel I2C communication system as claimed in any one of claims 7 to 9.