USB interface and USB serial port switching circuit
By combining a voltage detection chip and a CPLD chip, automatic identification and switching of USB device types are achieved, solving the compatibility and stability issues in switching between USB interfaces and serial ports, expanding the applicability of USB interfaces, and improving the intelligence and power management accuracy of devices.
Patent Information
- Application Number
- CN202520314797.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Utility models(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2035-02-26
AI Technical Summary
In existing technologies, switching between USB interface and serial port debugging suffers from limitations in physical interface form, impact on signal integrity, compatibility issues, and a single dependence on ID pins, resulting in poor device compatibility and stability.
A voltage detection chip and a CPLD chip are used to automatically determine the type of the inserted USB device. The power supply chip provides precise power control and automatically switches the working mode, avoiding dependence on the ID pin.
It improves system compatibility and stability, expands the adaptability of USB interfaces, reduces human error, saves energy, and enables intelligent device switching.
Smart Images

Figure CN223770630U_ABST
Abstract
Description
Technical Field
[0001] This utility model relates to the field of electronic communication technology, and more specifically, to a USB interface and USB serial port switching circuit. Background Technology
[0002] Serial port debugging is an important operation in the development and maintenance of electronic devices. Traditional serial port debugging often requires a specific serial port connection, which may be limited by hardware layout, number of interfaces, etc. in some devices. With the widespread use of USB interfaces, USB interfaces are used as serial ports for serial debugging. However, for USB interfaces, it is necessary to automatically switch between serial port debugging and ordinary USB interface. How to automatically identify whether the inserted USB device is for serial port debugging or ordinary USB interface is a problem that needs to be solved.
[0003] refer to Figure 1 When the circuit is designed to connect to other USB devices via a Micro / Mini USB interface, the master / slave status of the inserted device is determined by judging the ID pin value ("1" for Slave, "0" for Host). This signal is connected to the power control circuit and the SGM7227. Figure 1 The U1 chip (DPDT: Dual USB Analog Switch). When a host device is connected, the NMOS transistor disconnects the power input and pulls the S (strobe pin) of the SGM7227 chip low, connecting the data of channel one to the USB interface. Figure 1 When the device is connected as a slave device, the NMOS transistor turns on the power input to ensure Vbus power supply and pulls the S (strobe pin) of the SGM7227 chip high, connecting the data (TX, RX) of channel two to the D+ and D- pins of the USB interface, thus enabling serial port mode. This achieves the multiplexing of USB and serial port functions.
[0004] The above design has the following problems: 1. Limited physical interface form factor: The above solution is only applicable to Micro / Mini-USB interfaces. Only Micro / Mini-USB interfaces support ID pin exposure, while common USB peripherals mainly use USB Type A interfaces, which do not support ID pin exposure, thus making it impossible to switch between USB and serial port functions. 2. Impact on signal integrity: During function switching, signal integrity may be affected. For example, when the power input is disconnected or connected via the NMOS transistor, instantaneous voltage fluctuations or glitches may occur, which may potentially affect the data transmission stability of the USB interface and serial port. 3. Compatibility issues: This design may have compatibility issues and may not work properly for certain special USB or serial devices. Different USB or serial devices may have different requirements for power input, signal levels, data transmission protocols, etc. This circuit design is based on specific ID pin logic and chip function multiplexing. If the device requirements do not match the design assumptions, it may lead to malfunction. 4. Single dependence on the ID pin: The entire judgment mechanism depends entirely on the value of the ID pin. If the ID pin malfunctions or is misoperated, it will cause the master and slave devices to make incorrect judgments, thereby affecting the function switching of the entire circuit. Summary of the Invention
[0005] To address the aforementioned technical problems in related technologies, this utility model proposes a USB interface and USB serial port switching circuit, comprising: a USB interface module, a USB controller, a voltage detection chip, a CPLD chip, a multiplexer, and a power supply chip. The input terminal of the voltage detection chip is connected to the VBUS of the USB interface module, and the output terminal of the voltage detection chip is connected to the I / O group of the CPLD chip.
[0006] The six signal lines D+, D-, SSTX-, SSTX+, SSRX-, and SSRX+ of the USB interface module are connected to the output of the multiplexer.
[0007] The data strobe signal S of the CPLD chip is connected to the strobe pin S of the multiplexer, and the TX and RX signals of the CPLD chip are connected to PORT A of the multiplexer; the D+, D-, SSTX-, SSTX+, SSRX-, and SSRX+ signals of the USB controller are connected to PORT B of the multiplexer.
[0008] The EN pin of the power chip is connected to the GPIO of the CPLD chip; the 5V output pin of the power chip is connected to the VBUS pin of the USB interface module.
[0009] When the output voltage value Vout of the voltage detection chip is within the first voltage range, the device is the master device; when Vout is within the second voltage range, the device is the slave device. The first voltage range is (4.8V-5.2V), and the second voltage range is (0V-0.3V).
[0010] When the master device is inserted, the CPLD pulls the select pin S of the multiplexer low;
[0011] When inserted as a slave device, the CPLD pulls the EN pin of the power supply chip high, and then pulls the S strobe pin of the multiplexer high.
[0012] This invention's USB interface and USB serial port switching circuit automatically determines the type of the inserted USB device (master or slave) using a voltage detection chip and a CPLD, and automatically switches the operating mode based on the determination result, improving system compatibility and stability. In traditional USB device connection schemes, manual settings or additional devices may be required to distinguish between master and slave devices and switch modes. This automatic determination and mode switching method improves the device's intelligence and ease of use, and reduces errors that may result from human operation. Furthermore, this invention's CPLD precisely controls the MUX's selection pin based on the device type determination result, ensuring that different signals can be connected to the USB port through the MUX in the correct mode. This avoids complex manual circuit switching or the use of multiple independent circuits to implement different modes. Further, the EN pin of the power chip HZP2003 is controlled by the CPLD to supply power based on the device type (slave). This power management method, combined with device type determination, ensures that power is only supplied to a slave device when it is inserted, saving energy and improving the accuracy of power management. This invention eliminates the need to detect the ID pin value (the ID pin is only used in Micro USB interfaces), greatly expanding the compatibility of USB interfaces. The USB interface in this embodiment can use the TYPE-A type, which can be used with most USB devices. Attached Figure Description
[0013] To more clearly illustrate the technical solutions in the embodiments of this utility model or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this utility model. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0014] Figure 1 It is an existing technology for automatic interface switching circuits suitable for Micro / Mini-USB;
[0015] Figure 2 This is one of the schematic diagrams of a USB interface and USB serial port switching circuit provided in this utility model embodiment;
[0016] Figure 3 This is the second schematic diagram of a USB interface and USB serial port switching circuit provided in this embodiment of the present invention. Detailed Implementation
[0017] The technical solutions of the present utility model will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present utility model, and not all embodiments. Based on the embodiments of the present utility model, all other embodiments obtained by those skilled in the art are within the protection scope of the present utility model.
[0018] refer to Figure 2-3 This embodiment discloses a USB interface and USB serial port switching circuit, which includes: a USB interface module, a voltage detection chip, a CPLD chip, a multiplexer, a power supply chip, and a USB controller.
[0019] The input terminal of the voltage detection chip is connected to the VBUS of the USB interface module, and the output terminal of the voltage detection chip is connected to the I / O group of the CPLD chip.
[0020] The six signal lines D+, D-, SSTX-, SSTX+, SSRX-, and SSRX+ of the USB interface module are connected to the output of the multiplexer.
[0021] The data strobe signal S of the CPLD chip is connected to the strobe pin S of the multiplexer, and the TX and RX signals of the CPLD chip are connected to PORT A of the multiplexer; the D+, D-, SSTX-, SSTX+, SSRX-, and SSRX+ signals of the USB controller are connected to PORT B of the multiplexer.
[0022] The EN pin of the power chip is connected to the GPIO of the CPLD chip; the 5V output pin of the power chip is connected to the VBUS pin of the USB interface module.
[0023] When the output voltage value Vout of the voltage detection chip is within the first voltage range, the device is the master device; when Vout is within the second voltage range, the device is the slave device.
[0024] The first voltage range of this embodiment is (4.8V-5.2V), which is the high voltage threshold of 5V; the second voltage range is (0V-0.3V), which is the low voltage threshold.
[0025] When the master device is inserted, the CPLD pulls the select pin S of the multiplexer low;
[0026] When inserted as a slave device, the CPLD pulls the EN pin of the power supply chip high, and then pulls the S strobe pin of the multiplexer high.
[0027] The USB interface module uses a USB-Type A female connector. It is used to connect other USB peripherals (such as mice, keyboards, and USB flash drives).
[0028] The voltage detection chip in this embodiment is the FS7033 from Shenzhen Pan-Hai Microelectronics. The FS7033 is a low-power three-terminal voltage detection chip based on CMOS technology. The voltage detection range of the FS7033 chip is 0.9~9V. The FS7033 voltage detector integrates a high-precision, low-power reference source, a comparator, a delay circuit, and an output driver. The voltage detection chip in this embodiment can detect the voltage value of the VBUS pin of the USB interface module and input the detected voltage to the CPLD chip. The voltage detection chip in this embodiment determines whether the inserted USB device is a master or slave device by detecting the voltage value of the VBUS pin.
[0029] Specifically, to adapt to the voltage of the CPLD chip I / O BANK, this embodiment also includes a voltage resistor network. The voltage resistor network is connected to the output terminal of the voltage detection chip and the CPLD I / O BANK respectively. It is used to divide the detected VBUS voltage and input it to the CPLD to adapt to the voltage value of the CPLD I / O BANK.
[0030] The voltage resistor network in this embodiment is constructed using existing voltage resistor networks. This network is used for voltage division. In one embodiment, the voltage resistor network may consist of two resistors, the values of which can be set according to specific circuit requirements. The voltage resistor network can divide the voltage output by the voltage detection chip to adapt to the voltage value of the CPLD I / O BANK.
[0031] In this embodiment, the CPLD chip is Gowin's GW2AN-UV9X. It is responsible for switching signals based on the results from the voltage detection chip. The CPLD can flexibly change the internal circuit connections according to a pre-written logic program, thereby switching the debug serial port to different interfaces when different devices are plugged in, or connecting the USB signal as required.
[0032] The multiplexer (MUX) is TI's SN74LS158N (2-to-1 8-channel data selector). CPLD logic control enables switching between serial port signals and USB signals.
[0033] The power supply chip in this embodiment is HZP2003.
[0034] The USB controller in this embodiment is the XUSB2104H from Chengdu Electric Power Science & Technology Xingtuo.
[0035] The working principle of the USB interface and USB serial port switching circuit in this embodiment is as follows: When a USB device is inserted, the voltage detection chip first performs a precise voltage measurement on the VBUS pin and sends the voltage output value to the CPLD for judgment. When Vout is between the 5V high and low thresholds, it is considered that the inserted device is the master device; when Vout is 0V, it is considered that the inserted device is the slave device.
[0036] When the master device is inserted, the CPLD pulls the S strobe pin of the MUX low, and then the serial port signals TX and RX are connected to the D+ and D- of the USB port through the MUX, which means that the debug serial port mode is in this time.
[0037] When inserted as a slave device, the CPLD supplies power to the USB device by pulling the EN pin of the power chip HZP2003 high to ensure normal operation. Then, the strobe pin S of the MUX is pulled high, allowing the D+, D-, SSTX-, SSTX+, SSRX-, and SSRX+ signals of the USB controller XUSB2104H to be connected to the USB port through the MUX, thus functioning as a standard USB interface module.
[0038] The USB interface and USB serial port switching circuit in this embodiment automatically determines the type of the inserted USB device (master or slave) through a voltage detection chip and a CPLD, and automatically switches the operating mode based on the determination result, improving system compatibility and stability. In traditional USB device connection schemes, manual settings or additional devices may be required to distinguish between master and slave devices and switch modes. This automatic determination and mode switching method improves the intelligence and ease of use of the device and reduces errors that may be caused by human operation. In addition, the CPLD in this embodiment accurately controls the selection pin of the MUX based on the device type determination result, so that different signals can be connected to the USB port through the MUX in the correct mode. This avoids complex manual circuit switching or the use of multiple independent circuits to implement the functions of different modes. Furthermore, the EN pin of the power chip HZP2003 is controlled by the CPLD to supply power according to the device type (slave device). This power management method, combined with device type determination, ensures that power is only supplied to the slave device when it is inserted, saving energy and improving the accuracy of power management. This embodiment does not require detecting the ID pin value (the ID pin is only used by Micro USB interfaces), which greatly expands the compatibility of the USB interface. The USB interface in this embodiment can use the TYPE-A type, which can be used with most USB devices.
[0039] The above description is only a preferred embodiment of the present utility model and is not intended to limit the present utility model. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present utility model should be included within the protection scope of the present utility model.
Claims
1. A USB interface and USB serial port switching circuit, comprising: The USB interface module, the USB controller, characterized in that: further comprising: a voltage detection chip, a CPLD chip, a multiplexer, a power supply chip, the input end of the voltage detection chip is connected with the VBUS of the USB interface module, the output end of the voltage detection chip is connected with the I / O group of the CPLD chip; The D+, D-, SSTX-, SSTX+, SSRX-, SSRX+ of the USB interface module are connected to the output end of the multiplexer; The data selection signal S of the CPLD chip is connected to the selection pin S of the multiplexer, the TX, RX of the CPLD chip are connected to the PORT A of the multiplexer; the D+, D-, SSTX-, SSTX+, SSRX-, SSRX+ of the USB controller are connected to the PORT B of the multiplexer; The EN pin of the power supply chip is connected with the GPIO of the CPLD chip; the 5V output pin of the power supply chip is connected with the VBUS pin of the USB interface module; When the output voltage value Vout of the voltage detection chip is in the first voltage range, the main device is inserted, when Vout is in the second voltage range, the slave device is inserted; When the main device is inserted, the CPLD pulls down the selection pin S of the multiplexer; When the slave device is inserted, the CPLD pulls up the EN pin of the power supply chip, and then pulls up the selection pin S of the multiplexer.
2. The USB interface and USB serial port switching circuit according to claim 1, characterized in that: Further comprising: A voltage dividing resistor network, the voltage dividing resistor network is connected with the output end of the voltage detection chip and the I / O group of the CPLD respectively.
3. The USB interface and USB serial port switching circuit according to claim 1, characterized in that: The USB interface module is a USB-Type A type interface.
4. The USB interface and USB serial port switching circuit of claim 1, wherein: The voltage detection chip is FS7033.
5. The USB interface and USB serial port switching circuit according to claim 1, characterized in that: The CPLD chip is GW2AN-UV9X.
6. The USB interface and USB serial port switching circuit of claim 1, wherein: The multiplexer is SN74LS158N.
7. The USB interface and USB serial port switching circuit according to claim 1, characterized in that: The power supply chip is HZP2003.
8. The USB interface and USB serial port switching circuit of claim 1, wherein: The USB controller is XUSB2104H.