A circuit for multiplexing USB interface to realize single-chip microcomputer program burning and debugging
Patent Information
- Application Number
- CN202522405428.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Utility models(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-13
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2035-11-13
AI Technical Summary
[0003]本实用新型针对现有技术的不足,提供一种复用USB接口实现单片机程序烧录和调试的电路,旨在解决传统单片机调试方案中因专用调试接口导致的硬件成本高、占用空间大、操作复杂等问题
1. 通过复用标准USB接口实现了程序烧录、在线调试和常规USB通信三重功能,无需设置专用调试接口,降低了硬件成本和PCB布局面积;
Smart Images

Figure CN224922266U_ABST
Abstract
Description
Technical Field
[0001] This utility model relates to the field of microcontroller development and debugging interface circuit technology, and in particular to a circuit that reuses a USB interface to realize microcontroller program burning, online debugging and USB communication. Background Technology
[0002] In the R&D and production stages of embedded devices, program burning and online debugging are indispensable key steps. Currently, the commonly used methods rely on dedicated debugging interfaces, such as JTAG or SWD interfaces. However, these dedicated interfaces have many drawbacks: taking a standard 20-pin JTAG interface as an example, its connector and surrounding resistors and capacitors occupy PCB layout area, increasing hardware material costs. In practice, debugging personnel need to connect multiple cables, a cumbersome process prone to connection errors. Furthermore, in terms of product design, dedicated debugging interfaces often affect the overall aesthetics of the device and limit its ability to achieve high levels of waterproof and dustproof performance. More importantly, once the device has completed mass production and is delivered for use, these debugging interfaces are usually idle, resulting in a waste of hardware resources. Summary of the Invention
[0003] This utility model addresses the shortcomings of existing technologies by providing a circuit that reuses a USB interface to enable microcontroller programming and debugging. It aims to solve the problems of high hardware cost, large space occupation, and complex operation caused by dedicated debugging interfaces in traditional microcontroller debugging solutions.
[0004] To achieve the above objectives, the present invention adopts the following technical solution: This utility model provides a circuit for reusing a USB interface to realize microcontroller program burning and debugging, including: a USB connector; a protocol identification circuit connected to the USB connector; an interface switching circuit connected to both the protocol identification circuit and the USB connector; and a protocol conversion circuit connected to the interface switching circuit.
[0005] As a further improvement of this utility model, the USB connector is a Micro-USB connector.
[0006] As a further improvement of this utility model, the USB connector is a USB Type-C connector.
[0007] As a further improvement of this utility model, the protocol identification circuit includes an auxiliary MCU.
[0008] As a further improvement of this utility model, the interface switching circuit is a high-speed analog switch.
[0009] As a further improvement of this utility model, the interface switching circuit is a multiplexer.
[0010] As a further improvement of this utility model, the protocol conversion circuit includes a USB to SWD / JTAG chip.
[0011] Compared with the prior art, the present invention has the following beneficial effects: 1. By reusing the standard USB interface, it achieves three functions: program burning, online debugging, and regular USB communication, eliminating the need for a dedicated debugging interface, thus reducing hardware costs and PCB layout area; 2. A single USB cable is all that's needed to power the device, communicate data, program the device, and debug online, simplifying the development and production process; 3. The equipment casing does not require a dedicated debugging interface, which helps to improve the structural integrity and protection level of the equipment. Attached Figure Description
[0012] Figure 1 This is a circuit diagram of a microcontroller program burning and debugging system using a reused USB interface, according to an embodiment of this utility model. Detailed Implementation
[0013] To make the objectives, technical solutions, and advantages of this utility model clearer, the present utility model will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that the circuit modules and connection relationships mentioned in the following description are merely illustrative examples and are not intended to limit the scope of protection of this utility model.
[0014] This utility model embodiment provides a circuit that reuses a USB interface to realize microcontroller program burning and debugging. For example... Figure 1 As shown, the circuit includes a USB connector USB1, a protocol identification circuit U1, an interface switching circuit U2, and a protocol conversion circuit U4.
[0015] The USB connector USB1 adopts a standard USB interface, preferably a Micro-USB interface or a USB Type-C interface in this embodiment. The connector includes a VBUS pin, a D+ pin, a D- pin, and a GND pin, wherein the VBUS pin is used to receive external power, the D+ and D- pins form a differential data signal transmission channel, and the GND pin serves as a signal reference ground.
[0016] The protocol identification circuit U1 is implemented using an auxiliary MCU, such as an STM32G0 series chip. This circuit has the following connections: its ADC sampling pin is connected to the VBUS pin of the USB connector USB1 for monitoring power status; its GPIO1 and GPIO2 pins are connected to the D+ and D- pins of the USB connector respectively for monitoring data signal characteristics; and its control output terminal GPIOS is connected to the mode selection pin S of the interface switching circuit U2 for outputting a path switching control signal.
[0017] The interface switching circuit U2 is preferably implemented using a high-speed SPDT analog switch, such as the TS3USB221 chip. Its input terminals D+ and D- are connected to the D+ and D- pins of USB1, respectively; its output terminals are divided into two paths: the first path connects to the USB function pins (USB_D+, USB_D-) of the target MCU U3, and the second path connects to the input pins (UD+, UD-) of the protocol conversion circuit U4. The path selection of the interface switching circuit U2 is governed by the control signal output by the protocol identification circuit U1.
[0018] The protocol conversion circuit U4 can be implemented using a CH347F chip. Its input terminals (UD+, UD-) are connected to the corresponding output terminals (2D+, 2D-) of the interface switching circuit U2, and its output terminals are connected to the debug interface pins of the target MCU U3, specifically including the SWCLK (debug clock) and SWDIO (debug data) pins. This circuit is responsible for converting USB data packets into SWD or JTAG debug commands.
[0019] When the system is working, the protocol identification circuit U1 executes the following identification logic: First, the VBUS pin voltage is continuously monitored by the ADC. When a +5V voltage is detected, it is determined that an external device is connected. Secondly, the signal characteristics on the D+ and D- pins are monitored in real time through GPIO1 and GPIO2, including but not limited to signal level, timing and specific data packet format; Finally, based on the above monitoring results, the protocol identification circuit U1 identifies the type and operating mode of the currently connected device by analyzing signal characteristics.
[0020] The specific work mode switching process is as follows: When the protocol identification circuit U1 detects a standard USB bus reset signal or successfully completes the USB enumeration process, it determines that it is in USB communication mode. At this time, U1 outputs a first control signal through the GPIOS pin, causing the interface switching circuit U2 to directly connect the D+ and D- signals of the USB connector USB1 to the USB DP / DM pin of the target MCU U3, thereby realizing the conventional USB data communication function.
[0021] When the protocol identification circuit U1 detects a predefined debug request signal, which includes a specific low-frequency pulse sequence or a specific data packet, it determines that debug mode has been entered. The non-specific data packet is a USB control transmission data packet containing a specific VID / PID or instruction. At this time, U1 outputs a second control signal through the GPIOS pin, causing the interface switching circuit U2 to route the D+ and D- signals to the protocol conversion circuit U4. The protocol conversion circuit U4 parses the received USB data packet and converts it into a standard SWD or JTAG debug instruction stream, enabling program burning or online debugging functions through the debug pin of the target MCU U3.
[0022] In a preferred embodiment of this invention, when a USB Type-C interface is used, the CC1 and CC2 pins of the USB connector USB1 can be further connected to the GPIO3 and GPIO4 pins of the protocol identification circuit U1. By monitoring the status of the CC1 and CC2 pins, the protocol identification circuit U1 can identify the type of connected device, including debuggers, USB hosts, or pure power devices, thereby improving the accuracy and reliability of pattern recognition.
[0023] The foregoing has shown and described the basic principles, main features, and advantages of this utility model. Those skilled in the art should understand that this utility model is not limited to the specific embodiments described above. The specific embodiments and descriptions in the specification are merely for further illustrating the principles of this utility model. Various changes and modifications can be made to this utility model without departing from its spirit and scope, and all such changes and modifications fall within the scope of this utility model as claimed.
Claims
1. A circuit that reuses a USB interface to program and debug a microcontroller, characterized in that, include: USB connector; A protocol identification circuit is connected to the USB connector; An interface switching circuit is connected to both the protocol identification circuit and the USB connector. The protocol conversion circuit is connected to the interface switching circuit.
2. The circuit for microcontroller program burning and debugging using a multiplexed USB interface according to claim 1, characterized in that, The USB connector is a Micro-USB connector.
3. The circuit for microcontroller program burning and debugging using a multiplexed USB interface according to claim 1, characterized in that, The USB connector is a USB Type-C connector.
4. The circuit for microcontroller program burning and debugging using a multiplexed USB interface according to claim 1, characterized in that, The protocol identification circuit includes an auxiliary MCU.
5. The circuit for microcontroller program burning and debugging using a multiplexed USB interface according to claim 1, characterized in that, The interface switching circuit is a high-speed analog switch.
6. The circuit for microcontroller program burning and debugging using a multiplexed USB interface according to claim 1, characterized in that, The interface switching circuit is a multiplexer.
7. The circuit for microcontroller program burning and debugging using a multiplexed USB interface according to claim 1, characterized in that, The protocol conversion circuit includes a USB to SWD / JTAG chip.