CN101344874A - Method and device for controlling I2C device - Google Patents
Method and device for controlling I2C device Download PDFInfo
- Publication number
- CN101344874A CN101344874A CNA2007100758654A CN200710075865A CN101344874A CN 101344874 A CN101344874 A CN 101344874A CN A2007100758654 A CNA2007100758654 A CN A2007100758654A CN 200710075865 A CN200710075865 A CN 200710075865A CN 101344874 A CN101344874 A CN 101344874A
- Authority
- CN
- China
- Prior art keywords
- data
- level
- bus
- chip
- serial ports
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Landscapes
- Information Transfer Systems (AREA)
Abstract
The invention discloses a method for controlling an I2C device, and a device thereof. The method for controlling the I2C device adopts an RS232 serial port of a computer for simulating an I2C bus. Furthermore, the device for controlling the I2C comprises a computer provided with the RS232 serial port and the I2C device provided with an I2C bus interface. The RS232 serial port of the computer, an electrical level transformation circuit, an electrical level revertive circuit and the I2C bus interface are connected in sequence. The electrical level transformation circuit transforms the electrical level logic of the RS232 serial port into the electrical level logic of TTL and the electrical level revertive circuit inverts the electrical level logic of the TTL so as to ensure that the inverted electrical level logic corresponds to the electrical level logic of the I2C bus. By utilizing the RS232 serial port for directly simulating the I2C bus to realize the control of the computer to the I2C device, no special translation chip is needed, therefore, the price of the whole transformation device and the volume of the transformation device are reduced.
Description
Technical field
The present invention relates to computer communication field, especially about a kind of device and method of in computer communication complex, controlling the I2C device.
Background technology
In recent years, along with some increased functionality of using IC, the control of IC becomes increasingly complex, and is used for the function that makes IC is easier, and IC supplier generally can do piece DEMO plate, and cooperates PC (computing machine) software interface to control its function.In general, IC is (to be I by I2C
2C) bus is controlled, and PC itself does not possess the interface of I2C agreement, so this will relate to the control signal that how control signal of PC is converted to the I2C bus protocol.The method of conversion has following several at present:
1) utilize the parallel port direct modeling I2C bus of PC, advantage is a low price, and shortcoming is that the interface device volume is bigger;
2) utilize the USB conversion chip, advantage is that volume is little, but price is more expensive;
3) utilize the RS232 serial ports to communicate by letter with MCU, again by MCU Simulation with I 2C bus, advantage is that the DEMO plate can also be controlled under the situation that breaks away from PC, but the software work amount can be bigger, also needs the software programming of MCU except the programming of PC language.
Summary of the invention
Technical matters to be solved by this invention is, overcomes the deficiencies in the prior art, and the device and method of the little control I2C device of a kind of low price and volume is provided.
The technical solution adopted for the present invention to solve the technical problems is: the method for this control I2C device is the RS232 serial ports Simulation with I 2C bus with computing machine.
The level of DTR, the CTS of described method by control RS232 serial ports, RTS, DSR handshake just comes Simulation with I 2C bus operation.
Described DTR handshake is corresponding with the output of the data line SDA of I2C bus, the DSR handshake is corresponding with the input of the data line SDA of I2C bus, the RTS handshake is corresponding with the output of the clock line SCL of I2C bus, and the CTS handshake is corresponding with the input of the clock line SCL of I2C bus.
A kind of device of the I2C of control device comprises the computing machine with RS232 serial ports and has the I2C device of I2C bus interface, the RS232 serial ports of computing machine, level shifting circuit, level negater circuit and I2C bus interface connect in turn, level shifting circuit converts the level logic of RS232 serial ports to the Transistor-Transistor Logic level logic, and the level logic after the level negater circuit makes the Transistor-Transistor Logic level logic reversal oppositely is corresponding with the level logic of I2C bus.
Described level shifting circuit is selected from: SP3232 chip, MAX232 chip, level negater circuit are the 74HC05 chip.
Described level shifting circuit is the SP3232 chip, pin DTR, the CTS of RS232 serial ports, RTS, DSR are connected with four pins of SP3232 chip respectively, two clock SCL pins of SP3232 chip are connected with other four pins of 74HC05 chip respectively with two data SDA pins, the clock pin of 74HC05 chip is connected with the clock scl line of I2C bus interface, and the data pin of 74HC05 chip is connected with the data sda line of I2C bus interface.
Obtain 5V voltage behind the output level process rectification circuit of pin DTR, the RTS of described RS232 serial ports and the mu balanced circuit, this 5V voltage is given SP3232 chip and 74HC05 chip power supply.
Two clock SCL pins of described SP3232 chip connect dichromatic LED.
The invention has the beneficial effects as follows, utilize RS232 serial ports direct modeling I2C bus, realize the control of computing machine, do not need special-purpose conversion chip, reduced the price of whole conversion equipment, and reduced the volume of conversion equipment the I2C device.
Description of drawings
Fig. 1 is the process flow diagram of the method for present embodiment control I2C device when the I2C device is carried out write operation;
Fig. 2 is the process flow diagram of the method for present embodiment control I2C device when the I2C device is carried out read operation;
Fig. 3 is the circuit theory diagrams of the device of present embodiment control I2C device.
Embodiment
The method of present embodiment control I2C device is to be used to realize the control of computing machine to the I2C device, and it is that RS232 serial ports by computing machine comes Simulation with I 2C bus.
This RS232 serial ports has nine pins, and is specifically as shown in table 1:
Table 1RS232 serial ports pin
1 | Data carrier detects | Input | DCD | Carrier Detect |
2 | Receive data | Input | RXD | Receive Data |
3 | Send data | Output | TXD | Transmit Data |
4 | Data terminal is prepared | Output | DTR | Data Terminal Ready |
5 | Signal ground | Ground wire | GND | System Ground |
6 | DSR | Input | DSR | Data Set Ready |
7 | Request sends | Output | RTS | Request to Send |
8 | Clear to send | Input | CTS | Clear to Send |
9 | The ring indication | Input | DELL | Ring Indicator |
Wherein, only need RXD, TXD, three pins of GND just can finish the communication work of RS232 serial ports.RXD, TXD pin can only can not directly be controlled its output level as the RS232 serial communication.The level of DTR, the DSR by control RS232 serial ports, RTS, CTS handshake (respectively by pin DTR, DSR, RTS, CTS output) just can Simulation with I 2C bus operation, and promptly the level of the clock line SCL of Simulation with I 2C bus and data line SDA just changes.
The corresponding relation such as the table 2 of each handshake and I2C bus:
The corresponding relation of table 2RS231 serial ports handshake and I2C bus
DTR | The output of I2C bus data line SDA |
DSR | The input of I2C bus data line SDA |
RTS | The output of I2C bus clock line SCL |
CTS | The input of I2C bus clock line SCL |
DTR, RTS handshake also bear the work of serial ports power taking when removing and exporting as the I2C bus, when not carrying out the I2C bus operation, make DTR, RTS handshake be in high level.
When by the method for present embodiment the I2C device being controlled, it comprises read operation and write operation, and write operation is that the CPU of computing machine writes data in the register of I2C device, and read operation is CPU reading of data from the register of I2C device of computing machine.
As shown in Figure 1, write operation comprises the steps: a) to send start signal, i.e. operation beginning; B) write the address of I2C device; C) CPU reads the response message of I2C device, judges whether to receiving the low level of data, if then write register address and enter step d), if not then shut-down operation (promptly sending end signal); D) CPU reads the response message of I2C device, judges whether for receiving the low level of data, if then write data and enter step e) to register, if not then shut-down operation; E) CPU reads the response message of I2C device, judges whether for receiving the low level of data, if then expression writes the data success and continues to write data, if not then shut-down operation.
As shown in Figure 2, read operation comprises the steps: a) to send start signal; B) write the address of the I2C device that need read; C) CPU reads the response message of this I2C device, judges whether for receiving the low level of data, if then write register address and enter step d), if not then shut-down operation; D) CPU reads the response message of this I2C device, judges whether for receiving the low level of data, if then send start signal once more and enter step e), if not then shut-down operation; E) address with the I2C device adds 1; F) CPU reads the response message of this I2C device, judges whether to receiving the low level of data, if then read register data and reading the back shut-down operation that finishes, if not then shut-down operation.
The method of present embodiment control I2C device can be controlled a plurality of I2C devices that hang on the same I2C bus.
As shown in Figure 3, the I2C device that the device of present embodiment control I2C device comprises the computing machine with RS232 serial ports and has the I2C bus interface, the RS232 serial ports of this computing machine, level shifting circuit, level negater circuit and I2C bus interface connect in turn.Level shifting circuit converts the level logic of RS232 serial ports to the Transistor-Transistor Logic level logic, and the level logic after the level negater circuit makes the Transistor-Transistor Logic level logic reversal oppositely is corresponding with the level logic of I2C bus.
Level shifting circuit is selected from: SP3232 chip, MAX232 chip.The level negater circuit is the 74HC05 chip.The pin DTR of RS232 serial ports JP1, CTS, RTS, DSR is four pin (pin R1IN by connecting line and SP3232 chip IC 1 respectively, T2OUT, R2IN, T1OUT) connect, two clock SCL pin (pin T2IN of SP3232 chip, R2OUT) two pin (pin 4Y by connecting line and 74HC05 chip IC 2 respectively, 3A) connect, two data SDA pin (pin T1IN of SP3232 chip, R1OUT) two pin (pin 5Y by connecting line and 74HC05 chip respectively, 2A) connect, clock pin of 74HC05 chip (pin 4A) and data pin (5A) be the pin SCL by connecting line and I2C interface plug JP2 respectively, SDA connects, and this I2C interface plug JP2 and I2C interface socket JP3 peg graft.In addition, pin DTR, the RTS of RS232 serial ports obtains stable 5V voltage through the voltage stabilizing diode D4 of 5V after by diode D2, D3 rectification again, and this 5V voltage is SP3232 chip and 74HC05 chip power supply; Two clock SCL pins of SP3232 chip are connected with dichromatic LED D1 by resistance R 5, R6 respectively, thereby indicate the associated level of I2C bus by this two-color diode D1.
In the present embodiment, SP3232 chip (or MAX232 chip) is finished level conversion, what adopt because of the level logic of RS232 serial ports is negative logic, can cause the I2C bus to be in low level during power taking and drawn dead, therefore with the 74HC05 chip that associated level is reverse, both made things convenient for the serial ports power taking, and made the high-low level of handshake corresponding again, made things convenient for the work of writing of PC Control Software with the high-low level of I2C bus.In addition, because of the handshake of RS232 serial ports is an one-way transmission, and the data line of I2C bus is a transmitted in both directions, so 74HC05 also finishes the isolation work of I2C bus input and output.
Above content be in conjunction with concrete preferred implementation to further describing that the present invention did, can not assert that concrete enforcement of the present invention is confined to these explanations.For the general technical staff of the technical field of the invention, without departing from the inventive concept of the premise, can also make some simple deduction or replace, all should be considered as belonging to protection scope of the present invention.
Claims (10)
1. a method of controlling the I2C device is characterized in that: with the RS232 serial ports Simulation with I 2C bus of computing machine.
2. the method for control according to claim 1 I2C device is characterized in that: the level of DTR, the CTS by control RS232 serial ports, RTS, DSR handshake just comes Simulation with I 2C bus operation.
3. the method for control I2C device according to claim 2, it is characterized in that: described DTR handshake is corresponding with the output of the data line SDA of I2C bus, the DSR handshake is corresponding with the input of the data line SDA of I2C bus, the RTS handshake is corresponding with the output of the clock line SCL of I2C bus, and the CTS handshake is corresponding with the input of the clock line SCL of I2C bus.
4. according to the method for any described control I2C device among the claim 1-3, it is characterized in that: when the CPU of computing machine write data in the register of I2C device, it comprised the steps:
A) send start signal;
B) write the address of this I2C device;
C) CPU reads the response message of this I2C device, judges whether for receiving the low level of data, if then write register address and enter step d), if not then shut-down operation;
D) CPU reads the response message of this I2C device, judges whether for receiving the low level of data, if then write data and enter step e) to register, if not then shut-down operation;
E) CPU reads the response message of this I2C device, judges whether for receiving the low level of data, if then expression writes the data success and continues to write data, if not then shut-down operation.
5. the method for control according to claim 4 I2C device is characterized in that: when computer CPU read data in the register of I2C device, it comprised the steps:
A) send start signal;
B) write the address of the I2C device that need read;
C) CPU reads the response message of this I2C device, judges whether for receiving the low level of data, if then write register address and enter step d), if not then shut-down operation;
D) CPU reads the response message of this I2C device, judges whether for receiving the low level of data, if then send start signal once more and enter step e), if not then shut-down operation;
E) address with the I2C device adds 1;
F) CPU reads the response message of this I2C device, judges whether to receiving the low level of data, if then read register data and reading the back shut-down operation that finishes, if not then shut-down operation.
6. device of controlling the I2C device, it is characterized in that: the I2C device that comprises computing machine and have the I2C bus interface with RS232 serial ports, the RS232 serial ports of computing machine, level shifting circuit, level negater circuit and I2C bus interface connect in turn, level shifting circuit converts the level logic of RS232 serial ports to the Transistor-Transistor Logic level logic, and the level logic after the level negater circuit makes the Transistor-Transistor Logic level logic reversal oppositely is corresponding with the level logic of I2C bus.
7. the device of control I2C device according to claim 6, it is characterized in that: described level shifting circuit is selected from: SP3232 chip, MAX232 chip, level negater circuit are the 74HC05 chip.
8. the device of control I2C device according to claim 7, it is characterized in that: described level shifting circuit is the SP3232 chip, pin DTR, the CTS of RS232 serial ports, RTS, DSR are connected with four pins of SP3232 chip respectively, two clock SCL pins of SP3232 chip are connected with other four pins of 74HC05 chip respectively with two data SDA pins, the clock pin of 74HC05 chip is connected with the clock scl line of I2C bus interface, and the data pin of 74HC05 chip is connected with the data sda line of I2C bus interface.
9. the device of control I2C device according to claim 8, it is characterized in that: obtain 5V voltage behind the output level process rectification circuit of pin DTR, the RTS of described RS232 serial ports and the mu balanced circuit, this 5V voltage is given SP3232 chip and 74HC05 chip power supply.
10. the device of control I2C device according to claim 9, it is characterized in that: two clock SCL pins of described SP3232 chip connect dichromatic LED.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2007100758654A CN101344874B (en) | 2007-07-11 | 2007-07-11 | Method and device for controlling I2C device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2007100758654A CN101344874B (en) | 2007-07-11 | 2007-07-11 | Method and device for controlling I2C device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101344874A true CN101344874A (en) | 2009-01-14 |
CN101344874B CN101344874B (en) | 2010-09-29 |
Family
ID=40246879
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN2007100758654A Expired - Fee Related CN101344874B (en) | 2007-07-11 | 2007-07-11 | Method and device for controlling I2C device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN101344874B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102866683A (en) * | 2012-07-26 | 2013-01-09 | 苏州市大富通信技术有限公司 | Signal conversion device and automatic testing system |
CN105446837A (en) * | 2015-04-02 | 2016-03-30 | 北京天诚盛业科技有限公司 | Method, device and system for detecting whether IIC (inter-integrated circuit) interface device is connected |
CN106528460A (en) * | 2016-10-11 | 2017-03-22 | 广东欧珀移动通信有限公司 | Initializing control method and device for terminal device, and terminal device |
WO2017143857A1 (en) * | 2016-02-25 | 2017-08-31 | 广州视源电子科技股份有限公司 | Data transmission method, expansion device, peripheral device and system |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN100395739C (en) * | 2004-12-17 | 2008-06-18 | 鸿富锦精密工业(深圳)有限公司 | Signal conversion circuit |
CN2888537Y (en) * | 2006-04-19 | 2007-04-11 | 武汉电信器件有限公司 | A digital communication interface conversion module |
-
2007
- 2007-07-11 CN CN2007100758654A patent/CN101344874B/en not_active Expired - Fee Related
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102866683A (en) * | 2012-07-26 | 2013-01-09 | 苏州市大富通信技术有限公司 | Signal conversion device and automatic testing system |
CN102866683B (en) * | 2012-07-26 | 2014-12-17 | 苏州市大富通信技术有限公司 | Signal conversion device and automatic testing system |
CN105446837A (en) * | 2015-04-02 | 2016-03-30 | 北京天诚盛业科技有限公司 | Method, device and system for detecting whether IIC (inter-integrated circuit) interface device is connected |
CN105446837B (en) * | 2015-04-02 | 2019-05-07 | 北京眼神智能科技有限公司 | The method, apparatus and system whether detection IIC interface device connects |
WO2017143857A1 (en) * | 2016-02-25 | 2017-08-31 | 广州视源电子科技股份有限公司 | Data transmission method, expansion device, peripheral device and system |
CN106528460A (en) * | 2016-10-11 | 2017-03-22 | 广东欧珀移动通信有限公司 | Initializing control method and device for terminal device, and terminal device |
CN106528460B (en) * | 2016-10-11 | 2019-07-19 | Oppo广东移动通信有限公司 | Initialization control method, device and the terminal device of terminal device |
Also Published As
Publication number | Publication date |
---|---|
CN101344874B (en) | 2010-09-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR101725536B1 (en) | Device, method and system for operation of a low power phy with a pcie protocol stack | |
CN101000597A (en) | IP kernel of embedded Java processor based on AMBA | |
CN112256615B (en) | USB conversion interface device | |
CN101344874B (en) | Method and device for controlling I2C device | |
CN211956463U (en) | I/O (input/output) bridge piece based on Feiteng processor | |
CN102591757A (en) | Verification method and verification environment platform based on intelligent card universal serial bus (IC-USB) interface module of verification methodology (VMM) | |
CN202026431U (en) | Debugging device and debugging system | |
CN205247378U (en) | PS2 interface changes USB interface converter based on singlechip | |
CN205942670U (en) | Multi -computer auto -change over device | |
CN102693203A (en) | Embedded USB (universal serial bus) host | |
WO2010060237A1 (en) | Network computer based on fpga | |
CN203658990U (en) | Debugging device for central processing unit | |
CN105045401A (en) | USB interface keyboard and mouse integrated system and design method therefor | |
CN206224459U (en) | A kind of SCM Based Serial Communication for Multi-computer System circuit | |
CN112968332A (en) | Compatible device and method for switching TYPE-C interface of tablet personal computer mainboard to UART serial port communication | |
CN204706031U (en) | Serial peripheral equipment interface SPI bus circuit and electronic equipment | |
CN207319229U (en) | Simple RS232 multifunctional serial port expanding units | |
CN203117963U (en) | Debugging system and device for providing graphical pin interface | |
CN102364452A (en) | Realization method for thermal plugging use of PS2 interface keyboard and mouse | |
CN201813396U (en) | CANopen-CAN (controller area network) gateway | |
CN206022836U (en) | A kind of Signals Transfer Board | |
CN211653638U (en) | Digital PCIE interface testing device | |
CN202615388U (en) | Embedded usb host | |
CN201489396U (en) | Network main board and computer | |
CN201130373Y (en) | Apparatus for converting ARINC429 device into USB interface |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
C17 | Cessation of patent right | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20100929 Termination date: 20130711 |