Parallel port debugging method and tool based on USB virtual serial port

By using a parallel port debugging method based on a USB virtual serial port and leveraging the USB_CDC_ACM specification and microcontroller, multi-parallel port debugging without the need for dedicated drivers is achieved. This solves the problems of complex and costly debugging in existing technologies and improves debugging efficiency and flexibility.

CN121833466APending Publication Date: 2026-04-10赵明
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511934745.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-21
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

In existing technologies, parallel port debugging relies on dedicated equipment, which is complex and costly. Furthermore, different types of parallel ports require different debugging equipment, increasing the complexity and resource consumption of embedded development.

Method used

A parallel port debugging method based on a USB virtual serial port is adopted. The indirect communication between the debugging host and the device being debugged is realized through the USB_CDC_ACM specification. A communication bridge is established by using a microcontroller and a USB interface. Combined with general serial port debugging software, the debugging equipment and steps are simplified and the cost is reduced.

Benefits of technology

It achieves highly compatible and convenient debugging without the need for dedicated drivers, supports debugging of multiple parallel port types, lowers the operating threshold, improves debugging efficiency and flexibility, and expands the application scenarios of embedded development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121833466A_ABST
    Figure CN121833466A_ABST
Patent Text Reader

Abstract

The invention discloses a parallel port debugging method and tool based on a USB virtual serial port, and relates to the technical field of embedded development debugging. The core of the method is that indirect communication between a debugging host and a debugged device parallel port is realized through a USBCDCACM standard virtual serial port, and a host mode and a slave mode are supported. As special hardware, the tool comprises a microcontroller, a USB (Universal Serial Bus) interface, various bus interfaces, a control line interface, a peripheral circuit and an optional two-way selection module, and supports multiplexing of an address bus and a data bus. Dedicated drivers and dedicated debugging equipment are not needed, debugging of various parallel ports can be completed only through universal serial port debugging software, the debugging process is simplified, the development cost is reduced, the debugging efficiency is improved, application scenes such as virtual parallel port equipment software development can be expanded, and the application prospect is wide. The method is suitable for parallel port debugging scenes of peripherals such as an LCD screen, an extended memory interface (FSMC in STM32) and the like.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of embedded development debugging technology, in particular to a parallel port debugging tool and method based on a USB virtual serial port. BACKGROUND

[0002] In embedded development, 8080, 6800 and other parallel ports are widely used in communication scenarios of LCD screens, ADC chips, FPGAs and other peripherals. Currently, computers are generally equipped with only USB interfaces, lacking native parallel ports, and traditional parallel port debugging relies on special debuggers or old computers, which has problems such as complicated debugging process, high development cost, poor compatibility, etc.

[0003] In the prior art, special hardware tools and customized software are required for parallel port debugging, and different types of parallel ports require different debugging devices, further increasing the complexity and resource consumption of embedded development, and restricting the development progress. SUMMARY

[0004] In view of the problems of relying on special equipment, complicated process and high cost in the prior art, the present application proposes a parallel port debugging tool and method based on a USB virtual serial port to simplify the debugging equipment and steps, reduce the cost and improve the debugging efficiency.

[0005] I. Parallel port debugging method based on USB virtual serial port

[0006] This method is applicable to the scenario of debugging a host machine to debug a parallel port of a device under test through a special debugging tool, and the core is to realize indirect communication between the host machine and the parallel port of the device under test through a USB_CDC_ACM standard virtual serial port. The specific steps are as follows: 1) Connect the address bus, data bus and corresponding control signal lines of the device under test and the debugging tool, and then connect the debugging tool and the debugging host with a standard USB data line that can match the USB interface of the debugging tool. At this time, the debugging tool is powered on; 2) After the debugging tool is powered on, at least one serial port (default 1, supporting extension) is automatically virtualized based on the USB_CDC_ACM standard, serving as a communication bridge between the debugging host and the debugging tool; 3) The debugging personnel starts a general serial port debugging software (such as SSCOM) or a special serial port debugging software supporting standard asynchronous serial port communication on the debugging host, identifies all serial ports of the debugging tool through the software, selects the target virtual serial port to be debugged and opens it; the debugging host only needs to install a standard USB_CDC_ACM driver to establish communication, without the need for additional special drivers;

[0007] 4) After the debugging tool detects the opening instruction of the target virtual serial port, it immediately sends configuration auxiliary information to the serial port to guide the debugging personnel to use the tool, which specifically includes: the mapping relationship between the interface parameters and the serial port parameters, the supported specific instructions, and a brief debugging instruction;

[0008] 5) The serial port debugging software receives and displays the above-mentioned configuration auxiliary information, and the debugging personnel directly configures the parallel port parameters based on the displayed parameter mapping relationship or using specific instructions according to the interface type of the device being debugged and the debugging requirements; 6) After the configuration is completed, the debugging tool completes the data management and forwarding between the USB_CDC_ACM data channel and the parallel port according to the configured working mode, data format, and other related parameters, and realizes the bidirectional data interaction between the debugging host and the device being debugged.

[0009] The specific instruction configuration process is as follows: 1) Send global specific instruction 1 to the debugging tool to trigger the data channel to enter the configuration mode; 2) Send a configuration instruction to the debugging tool to complete the parameter configuration of the parallel port; 3) Send global specific instruction 2 to the debugging tool, and the data channel exits the configuration mode and restores to the data transparent transmission mode, and the configuration parameters take effect immediately.

[0010] The working mode includes host mode and slave mode.

[0011] The data format includes general data format and simplified data format.

[0012] General data format: the data exchanged between the debugging host and the debugging tool contains address information; specifically as follows: The format of the host sending data and the slave receiving and sending data is: Address1 Data1 Address2 Data2... Addressn Data n Special note: the address in the data sent by the slave is the offset address relative to the cache area.

[0013] The host needs to send the address when reading data, and the slave uploads the received address when being read data, and the format is: Address1 Address2... Addressn The above information needs to be sent in the read-only host mode, and only single-address reading is supported in the general host mode; The format of the returned data when reading is: Data1 Data2... Data n Simplified data format: the data exchanged between the debugging host and the debugging tool does not involve address information, specifically as follows: The host sends data, and the slave receiving and sending data only contains data information, and the format is: Data1 Data2... Data n The general host mode cannot read data, and the read data of the only read host mode needs to send placeholder data, The format is: placeholder data1 placeholder data2... placeholder data n The return data format is: data1 data2... data n There is no upload information when the slave is read data; The number of bytes occupied by each address and the number of bytes occupied by each data are respectively limited by the number of address bus / data bus bits. An 8-bit bus occupies 1 byte, a 16-bit bus occupies 2 bytes, a 32-bit bus occupies 4 bytes, and so on. Data forwarding logic in each working mode Slave mode

[0014] In this mode, the address valid, write data valid and read data request signals of the parallel port are detected by setting three special pins on the debugging tool and setting the corresponding edge detection parameters. Before debugging, the debugging personnel need to connect the corresponding control signals to these three special pins according to the parallel port timing.

[0015] Upstream data (debugged device→debugging host): The debugging tool receives the address bus data and data bus data sent by the debugged device through the slave parallel port transceiver program running in real time, and uploads to the debugging host through the slave parallel port data forwarding program running in real time, which is directly displayed in the serial port debugging software receiving area; Downstream data (debugging host→debugged device): The debugging tool stores the data sent by the debugging host into the slave parallel port data buffer area according to the configured data format, and waits for the debugged device to read it actively. When the debugged device reads it, the debugging tool receives the address information sent by the debugged device through the slave parallel port transceiver program, and sends the data in the buffer area to the data bus. If the data format is configured as the general data format, the debugging tool will upload the received address information to the debugging host.

[0016] The slave parallel port receiving program steps are as follows: 1) If the data format is the general data format, wait for the address valid signal to arrive, otherwise go to step 3); 2) Read the data on the address bus and store it in the parallel port receiving buffer area; 3) Wait for the write data valid signal to arrive or the read data request signal to arrive; 4) If the write data valid signal arrives, execute the next step, otherwise execute step 6); 5) Read the data on the data bus and store it in the parallel port receiving buffer area, and go to step 1); 6) The data in the parallel port pending data buffer area is transferred to the data bus in turn, and if the parallel port pending data buffer area is empty, the sending is recycled; 7) Jump to step 1).

[0017] The slave machine parallel port data forwarding procedure is as follows: 1) Wait for the virtual serial port uplink data channel to be idle or the uplink data buffer area to be not full; 2) Wait for the parallel port receiving buffer area to be not empty; 3) Send the parallel port receiving buffer area to the virtual serial port uplink data channel or uplink data buffer area and start sending; 4) Jump to step 1); Master mode

[0018] This mode includes a general master mode and a read-only master mode.

[0019] In this mode, a set of control signal output interfaces are set on the debugging tool to drive the control signal lines, and control sequence parameters are set to adapt to a wider range of debugging scenarios, including the following node sequences: address bus driving before control sequence, address bus driving after control sequence, data bus driving before control sequence, data bus driving after control sequence, read data before control sequence, and read data after control sequence; The driving order and driving value of each node sequence of the control signal line can be flexibly configured, and is assisted by control signal holding time, address signal holding time, and data signal holding time, and can produce a variety of timing. The following is a debugging process based on this control signal driving mode: Send data (address bus and data bus are driven by the debugging tool): use the serial port debugging software to configure the debugging tool as a general master mode, and send data to the debugging tool using the set parameter data format, and the debugging tool calls the corresponding parallel port sending program according to the set data format to send data to the debugged device through the parallel port.

[0020] Read data (address bus is driven by the debugging tool, and data bus is driven by the debugged device): use the serial port debugging software to send read instructions to the debugging tool according to the master mode and data format parameters, and the debugging tool reads data from the debugged device according to the set data format and uploads it to the debugging host through the virtual serial port channel.

[0021] The parallel port sending program is divided into a parallel port general sending program and a parallel port simplified sending program according to the data format.

[0022] The parallel port general sending program steps are as follows: 1) According to the set parameter address bus drive before the control sequence corresponding to the control signal line, each drive signal line, supplemented by a period of time delay, delay time specified by the parameter control signal hold time; 2) Send address information to the address bus; 3) Delay, delay time specified by the parameter address signal hold time; 4) According to the set parameter address bus drive after the control sequence corresponding to the control signal line, each drive signal line, supplemented by a period of time delay, delay time specified by the parameter control signal hold time; 5) According to the set parameter data bus drive before the control sequence corresponding to the control signal line, each drive signal line, supplemented by a period of time delay, delay time specified by the parameter control signal hold time; 6) Send data information to the data bus; 7) Delay, delay time specified by the parameter data signal hold time; 8) According to the set parameter data bus drive after the control sequence corresponding to the control signal line, each drive signal line, supplemented by a period of time delay, delay time specified by the parameter control signal hold time; 9) Jump to the first) step, until the data is sent; 10) End of sending; The parallel port simplified sending procedure steps are as follows: 1) According to the set parameter address bus drive before the control sequence corresponding to the control signal line, each drive signal line, supplemented by a period of time delay, delay time specified by the parameter control signal hold time; 2) Send fixed address information to the address bus, fixed address information is specified by the parameter simplified data format address; 3) Delay, delay time specified by the parameter address signal hold time; 4) According to the set parameter address bus drive after the control sequence corresponding to the control signal line, each drive signal line, supplemented by a period of time delay, delay time specified by the parameter control signal hold time; 5) According to the set parameter data bus drive before the control sequence corresponding to the control signal line, each drive signal line, supplemented by a period of time delay, delay time specified by the parameter control signal hold time; 6) Send data information to the data bus; 7) Delay, delay time specified by the parameter data signal hold time; 8) According to the parameter data bus drive after the control sequence drive corresponding control signal line in turn, each drive signal line, supplemented by a period of time delay, delay time specified by the parameter control signal holding time; 9) Jump to step 5) until the data is sent; 10) End of sending; The parallel port reading program is divided into parallel port general reading program and parallel port simplified reading program according to data format.

[0023] The parallel port general reading program steps are as follows: 1) According to the parameter address bus drive before the control sequence drive corresponding control signal line in turn, each drive signal line, supplemented by a period of time delay, delay time specified by the parameter control signal holding time; 2) Send address information to the address bus; 3) Delay, delay time specified by the parameter address signal holding time; 4) According to the parameter address bus drive after the control sequence drive corresponding control signal line in turn, each drive signal line, supplemented by a period of time delay, delay time specified by the parameter control signal holding time; 5) According to the parameter data bus drive before the control sequence drive corresponding control signal line in turn, each drive signal line, supplemented by a period of time delay, delay time specified by the parameter control signal holding time; 6) Read data information on the data bus; 7) According to the parameter read data after the control sequence drive corresponding control signal line in turn, each drive signal line, supplemented by a period of time delay, delay time specified by the parameter control signal holding time; 8) Jump to step 1) until the data is read; 9) End of reading; The simplified parallel port reading program steps are as follows: 1) According to the parameter address bus drive before the control sequence drive corresponding control signal line in turn, each drive signal line, supplemented by a period of time delay, delay time specified by the parameter control signal holding time; 2) Send fixed address information to the address bus, fixed address information specified by the parameter simplified data format address; 3) Delay, delay time specified by the parameter address signal holding time; 4) According to the parameter address bus drive after the control sequence drive corresponding control signal line in turn, each drive signal line, supplemented by a period of time delay, delay time specified by the parameter control signal holding time; 5) Before reading data according to the set parameters, the control sequence drives the corresponding control signal line in turn, and each time the signal line is driven, a time delay is added, and the delay time is specified by the parameter control signal holding time; 6) Read data information on the data bus; 7) After reading data according to the set parameters, the control sequence drives the corresponding control signal line in turn, and each time the signal line is driven, a time delay is added, and the delay time is specified by the parameter control signal holding time; 8) Jump to step 5) until the data reading is completed; 9) End of reading; The parameter data format, address bus driving control sequence before driving, address bus driving control sequence after driving, data bus driving control sequence before driving, data bus driving control sequence after driving, control signal holding time, address signal holding time, data signal holding time, control sequence before reading data, and control sequence after reading data can be configured through the specific instruction configuration process; II. Parallel port debugging tool based on USB virtual serial port

[0024] The debugging tool is a special hardware for implementing the above debugging method, including a microcontroller, a USB interface, an address bus interface, a data bus interface and a control line interface, a detection interface, a peripheral circuit and an optional signal selection module. The specific structure and functions are as follows: Microcontroller: core control unit, with kernel, RAM, FLASH, GPIO function, external interrupt function, timer / counter function and USB slave function, used for running the above debugging method program, realizing parameter configuration management, parameter mapping conversion and data forwarding logic.

[0025] USB interface: used for establishing physical connection and communication link between the debugging tool and the debugging host, so that the debugging host can establish stable communication with the microcontroller through the standard USB_CDC_ACM driver without the need for a special driver.

[0026] Address bus interface: according to needs, partially or wholly physically connected with the corresponding interface of the device being debugged; Data bus interface: according to needs, partially or wholly physically connected with the corresponding interface of the device being debugged; Control line interface: applied to host mode, according to needs, partially or wholly physically connected with the corresponding interface of the device being debugged; Detection interface: applied to slave mode, which at least includes three sub-interfaces of address valid signal detection interface, write data valid signal detection interface and read data request detection interface.

[0027] Peripheral circuit: including voltage stabilizing component, clock component, resistance and capacitance, providing stable power supply, clock signal and signal matching support for microcontroller, ensuring stable operation of debugging tool; wherein the voltage stabilizing component adopts voltage stabilizing chip, and the clock component adopts oscillation circuit composed of crystal oscillator and capacitance.

[0028] The debugging tool supports address bus and data bus multiplexing, and in the multiplexing mode, the data bus interface is disabled, and the address and data are transmitted by the address bus interface.

[0029] Expansion component adaptation:

[0030] If the debugging scene is that the debugging tool is a slave, and the same action of the A signal line of the debugged host machine represents different functions according to the level of the B signal line (such as the pulse signal (E) and the read-write indication signal (R / W) in the 6800 timing), the two signal lines need to be connected to the write data trigger end and the read data trigger end of the debugging tool through a two-way selection switch, wherein the A signal line is connected to the common end of the two-way selection switch, the B signal is connected to the control end of the two-way selection switch, and the write data trigger end and the read data trigger end of the debugging tool are respectively connected to the two gating channels of the two-way selection switch according to the truth table of the A / B signal line.

[0031] Advantages of the present application Strong compatibility: supporting debugging of 8080, 6800, extended memory interface (such as FSMC interface in STM32F103) and other parallel ports, without the need to provide independent debugging equipment for different interfaces, greatly simplifying the debugging tool configuration.

[0032] Debugging software generalization: the debugging host does not need to install special drivers and special debugging software, only needs to have a standard USB_CDC_ACM driver, and can use general software such as serial debugging assistant to realize debugging of all supported interfaces, saving debugging preparation time and reducing operation threshold.

[0033] Convenient debugging: supporting verification of parallel port communication function of development program on a single embedded core board, weakening the dependence on special embedded hardware, and the configuration method is displayed in the receiving area of the serial debugging software, without additional instruction file, avoiding the trouble of debugging personnel searching for instruction file and repeatedly jumping between applications, greatly improving the debugging flexibility and efficiency.

[0034] Digital terminal virtualization: based on the debugging method of the present application, virtual parallel port device software (such as virtual 8080 device, virtual SRAM, etc.) can be developed on the debugging host, without developing special drivers, further expanding the application scenarios of embedded development, and improving the development efficiency. BRIEF DESCRIPTION OF DRAWINGS

[0035] Figure 1This is a link diagram for debugging the parallel port host device of the present invention, showing the connection relationship between the debugging host, the debugging tool and the device being debugged (host); Figure 2 This is a link diagram for debugging parallel port slave devices according to the present invention, showing the connection relationship between the debugging host, debugging tool and the device being debugged (slave); Figure 3 This is a schematic diagram of the debugging tool for the present invention, with detailed annotations of the component connections of the microcontroller, USB interface, address bus interface, data bus interface, control line interface, and peripheral circuits. Figure 4 This is a schematic diagram of the signal selection module of the present invention, with the pin functions of the dual-channel selection switch chip U3 (BL1551) and interface P8 / P9 marked. Figure 5 This is a parallel port configuration parameter mapping table used in the embodiments of the present invention. Detailed Implementation

[0036] I. Hardware Connection Hardware configuration details of debugging tools

[0037] like Figure 3 The schematic diagram of the debugging tool shown includes a microcontroller U1, a voltage regulator chip U2, a USB interface P1, an address valid signal detection interface P2, a write data valid signal detection interface P3, a read data request signal detection interface P4, a data bus interface P5, a control line interface P6, an address bus interface P7, a crystal oscillator Y1, resistors R1 to R2, and capacitors C1 to C13.

[0038] Pins 6, 11, 21, 22, 28, 50 / 75, and 100 of the microcontroller U1 are connected to power supply VDD; pins 10, 19, 20, 27, 49, 74, and 99 are grounded; pin 12 is connected to pin 13 via a parallel circuit of crystal oscillator Y1 and resistor R1; pin 14 is grounded via capacitor C5; pins 15 to 18, 33, 34, 66, and 80 serve as control signal output pins and are connected to pins 2 to 9 of control line interface P6; pins 23 to 24 serve as address valid signal detection pins and are connected to pins 3 to 4 of address valid signal detection interface P2. Pins 35 to 37, 89 to 93, 95 to 96, 47 to 48, and 51 to 54 are connected to pins 2 to 17 of data bus interface P5 as 16-bit data bus ports respectively. Pins 63 to 64 are connected to pins 3 to 4 of write data valid signal detection interface P3 respectively as write data valid signal detection pins. Pins 67 to 68 are connected to pins 3 to 4 of read data request signal detection interface P4 respectively as read data request signal detection pins. Pins 11 and 12 are connected to pins A7 and A6 of USB interface P1 respectively as USB communication pins. Pin 94 is grounded through resistor R2. The microcontroller U1 can be a microcontroller of model such as AT32F403AVGT7; The capacitor C1 is connected between pin 12 of U1 and ground; The capacitor C2 is connected between pin 13 of U1 and ground; The capacitor C3 is connected between pin 6 of U1 and ground; The capacitor C4 is connected between pin 11 of U1 and ground; The capacitor C5 is connected between pin 14 of U1 and ground; The capacitor C6 is connected between pin 21 of U1 and ground; The capacitor C7 is connected between pin 22 of U1 and ground; The capacitor C8 is connected between pin 99 of U1 and ground; The capacitor C9 is connected between pin 28 of U1 and ground; The capacitor C10 is connected between pin 50 of U1 and ground; The capacitor C11 is connected between pin 75 of U1 and ground; Pins 1 and 2 of the address valid signal detection interface P2 are grounded, and pins 5 and 6 are connected to the power supply VDD. Pins 1 and 2 of the write data valid signal detection interface P3 are grounded, and pins 5 and 6 are connected to the power supply VDD. Pins 1 and 2 of the read data request signal detection interface P4 are grounded, and pins 5 and 6 are connected to the power supply VDD; the address valid signal detection interface, the write data valid signal detection interface, and the read data request signal detection interface all support the detection of two input signals. Pins 1 and 18 of the data bus interface P5 are grounded; Pins 1 and 10 of the control line interface P6 are grounded; Pins 1 and 34 of the address bus interface P7 are grounded; The USB interface P1 is a TYPEC female connector, with pins A1, A12, B1 and B12 grounded, and pins A4, A9, B4 and B9 connected to the power supply VCC. The Vin pin of the voltage regulator chip U2 is connected to the power supply VCC, the Vout pin is connected to the power supply VDD, and the GND pin is grounded. The capacitor C12 is connected in parallel between the Vout pin of U2 and ground; The capacitor C13 is connected in parallel between the Vin pin of U2 and ground; Dual-channel selection module

[0039] like Figure 3 The schematic diagram of the dual-channel selection module shown is used as an extended optional component in the following situations: Debugging scene is debugging tool as a slave, while the same action of A signal line of the debugging host represents different functions according to the level of B signal line (such as pulse signal (E) and read-write indication signal (R / W) in 6800 timing); The dual-path selection module includes a dual-path selection switch chip U3, a source signal input interface P8, a selection signal output interface P9, and a capacitor C14.

[0040] The dual-path selection switch chip U3 is of BL1551 type, the 1 pin of which is connected to the 3 pin of the selection signal output interface P9 as a low-level selection output end, the 2 pin is grounded, the 3 pin is connected to the 2 pin of P9 as a high-level selection output end, the 4 pin is connected to the 3 pin of the source signal input interface P8 as a common end, the 5 pin is connected to a power supply VDD, and the 6 pin is connected to the 2 pin of P8 as a selection end. The 1 pin of the source signal input interface P8 is grounded, the 2 pin is a selection end, and the 3 pin is a common end. The 1 pin of the selection signal output interface P9 is grounded, the 2 pin is a high-level selection output end, the 3 pin is a low-level selection output end, and the 4 pin is connected to a power supply VDD. The capacitor C14 is connected between the 5 pin of U3 and the ground.

[0041] Connection of the debugging host and the debugging tool:

[0042] The USB interface of the debugging host is connected to the USB interface (TYPEC socket) of the debugging tool using a USB data line, and the debugging host establishes a stable communication channel with the virtual serial port built in the debugging tool through a USB_CDC_ACM virtual serial port driver.

[0043] Connection of the debugging tool and the device under debugging:

[0044] The address bus interface pins of the device under debugging are connected to the address bus interface pins of the debugging tool one by one. The data bus interface pins of the device under debugging are connected to the data bus interface pins of the debugging tool one by one. The address bus and the data bus of the debugging tool support multiplexing, which can be configured through related parameters. In the multiplexing mode, the data bus is disabled, and both the address and the data are transmitted by the address bus.

[0045] Connection of the control lines according to the debugging scene: Debugging tool as host: connect all the control lines of the device under debugging to the pins of the control line interface of the debugging tool one by one. The debugging tool supports a maximum of 8 control lines. After connection, remember the connection order, which will be used to configure the control signal sequence parameters.

[0046] Debugging tool slave: Connect the pin of the device to be debugged that can indicate the address valid signal (edge signal generated during the address life cycle on the bus) to the corresponding pin of the address valid signal detection interface of the debugging tool, connect the pin of the device to be debugged that can indicate the write data valid signal (edge signal generated during the output data life cycle on the bus) to the corresponding pin of the write data valid signal detection interface of the debugging tool, and connect the pin of the device to be debugged that can indicate the read data request signal (edge signal indicating the read data request after adding a delay to the edge signal output by the device to be debugged) to the corresponding pin of the read data request signal detection interface of the debugging tool.

[0047] II. Parameter conversion and mapping rules

[0048] Since the parameter definition of the virtual serial port is based on the UART interface characteristics, and the communication parameters of the parallel port differ from those of the UART, the debugging tool has a built-in parameter conversion program that completes the adaptive conversion of the parallel port parameters based on "Table 1 - Parallel port configuration parameter mapping table", Figure 5 which also illustrates the mapping relationship.

[0049] Table 1 - Parallel port configuration parameter mapping table Baud rate parameter Data bits parameter Stop bits parameter Parity parameter Flow control parameter bit[0..7]=control signal hold time; bit[8..15]=address hold time; bit[16..24]=data hold time Data bits (8=8 bits, non-8=16 bits) Master / slave mode (0 (1 stop bit) = slave, 1 (1.5 stop bits) = read-only master mode, 2 (2 stop bits) = universal master mode) Bus multiplex mode (0 (None) = no multiplexing, non-0 (other) = multiplexing, data bus inactive) Data format (0 (None) = universal data format; non-0 (other) - compact data format) Note: The baud rate parameter is only applicable to the host mode.

[0050] III. Debugging process example

[0051] After the debugging tool is powered on, it automatically virtualizes 1 virtual serial port and binds it to the parallel port, with the default parallel port being in slave mode. Debugging example 1 - host mode (32-bit address, 16-bit data)

[0052] 1) Start the serial port debugging software on the debugging host, and the software identifies the 1 virtual serial port provided by the debugging tool through the "USB_CDC_ACM virtual serial port driver" of the debugging host, selects the virtual serial port in the software, sets it to text display mode, and then opens it. 2) After the debugging tool detects the serial port opening instruction, it sends configuration assistance information (GB2312 encoding) to the serial port: "Current working mode: slave mode; Parameter mapping: baud rate = hold time (bit[0..7]= control signal hold time / 10ns, Bit[8..15]= address hold time / 10ns, Bit[16..24]= data hold time / 10ns), data bits = parallel port data bits (8=8 bits, non-8=16 bits), stop bits = master-slave mode (0 (1-bit stop bit) = slave, 1 (1.5-bit stop bit)= read-only host mode, 2 (2-bit stop bit)= general host mode), parity bit = bus multiplex mode (0 (None)= no multiplexing, others= multiplexing, data bus inactive), flow control = data format (0= general data format, others= compact data format); Debug data description: * Host mode please configure control signal sequence and hold time parameters first; The supported data channel specific instructions are as follows: Global specific instruction 1: enter configuration mode Global specific instruction 2: exit configuration mode 3) Debugging personnel refer to the auxiliary configuration information sent by the virtual serial port, configure data format, communication parameters, address bus bit number, address bus drive before control sequence, address bus drive after control sequence, data bus drive before control sequence, data bus drive after control sequence, control signal hold time, address signal hold time, data signal hold time, read data before control sequence and read data after control sequence parameters; The main interface parameters are: address bits = 32 bits, data bits = 16 bits, and it works in general host mode; 4) Ensure that the working mode is general host mode, and input the downlink data according to the configured data format in the software sending area: General data format: 00 02 03 04 05 06 10 12 13 14 15 16 The meanings are as follows: 00 02 03 04: first address 0x04030200; 05 06: first data 0x0605; 10 12 13 14: second address 0x14131210; 15 16: second data 0x1615; Compact data format: 05 06 15 16 The meanings are as follows: 05 06: first data 0x0605; 15 16: second data 0x1615; Then send; 5) Data is transmitted to the debugging tool through the "debugging software -> virtual serial port driver -> debugging tool virtual serial port" channel, and the debugging tool calls the corresponding parallel port sending program according to the configured data format parameters to send data; General data format: call parallel port general sending program; Simplified data format: call parallel port simplified sending program; 6) According to the configured data format, select the appropriate host mode, and input the downlink data in the software sending area: General data format, general host mode (only supports reading a single data): 00 02 03 04 The meanings are as follows: 00 02 03 04: The first address is 0x04030200; General data format, only receive host mode: 00 02 03 04 10 12 13 14 The meanings are as follows: 00 02 03 04: The first address is 0x04030200; 10 12 13 14: The second address is 0x04030200 Simplified data format, only receive host mode: FF FF FF FF The meaning is: read 2 data.

[0053] Then send; 7) Data is transmitted to the debugging tool through the "debugging software -> virtual serial port driver -> debugging tool virtual serial port" channel, and the debugging tool calls the parallel port reading program according to the set data format to send the address and read the data; 8) The read data is transmitted to the debugging software receiving area and displayed through the "debugging tool virtual serial port -> virtual serial port driver -> debugging software" channel: General data format, general host mode (only supports reading a single data): 05 06 General data format, only receive host mode: 05 06 15 16 Simplified data format, only receive host mode: 05 06 15 16 9) Complete debugging.

[0054] Core features: real-time transmission of uplink data, downlink data stored in cache area waiting for host reading; Operation steps: 1) - 3) Complete parameter configuration, such as address valid signal detection parameter, write data valid signal detection parameter and read data request signal detection parameter, according to 1) - 3) of debugging example 1; Main communication parameters are: data bit = 16 bits, working in slave mode; 4) The debugged parallel port device continuously sends two groups of write data to the debugging tool, which are: General data format: Send write address 0X60000000 and write data 0X0201; Send write address 0X60000002 and write data 0X0403; Simplified data format: Send write data 0X0201; Send write data 0X0403; 5) After receiving by the slave parallel port transceiver program of the debugging tool, the slave parallel port data forwarding program is used to transmit to the debugging software through the virtual serial port channel; 6) The receiving area of the debugging software displays: General data format: 00 00 00 60 01 02 02 00 00 60 03 04 Simplified data format: 01 02 03 04 7) Input the downlink data in the software sending area: General data format: 00 00 00 00 01 02 00 00 00 02 03 04 The address here is the offset address relative to the cache area.

[0055] Simplified data format: 01 02 03 04 Then send; 8) After receiving the data by the debugging tool, save the data to the corresponding interval of the cache area according to the configured data format, reset the cache area parameters (such as read index), and run the slave parallel port transceiver program in real time to wait for the debugged device to read; 9) The debugged device reads data from the debugging tool, which is divided into the following cases: The debugged device sends address information: address 1 = 0x60000000, address 2 = 0x60000002, at this time the debugging tool should be configured as general data format; The debugged device does not send address information, at this time the debugging tool should be configured as simplified data format; 10) If the data format is simplified data format, the debugged device will not send address information, and the debugging is completed; if the data format is general data format, the debugging tool will send the read address to the debugging software through the virtual serial port channel; 11) Debugging software receives area display: 00 00 00 60 02 00 00 60 12) Debugging is completed Specific instruction configuration flow

[0056] 1) Use the serial port debugging software to select the virtual serial port to be configured, use text mode for both transmission and reception, and then open the serial port; 2) Send the string "Enter configuration mode" (global specific instruction 1) to the debugging tool through the data channel, so that the data channel enters the configuration mode; 3) The debugging tool returns the supported configuration instruction information through the data channel, as follows: "Supported configuration instructions are as follows: Configuration instruction 1: communication parameters = control signal hold time / 10ns, address hold time / 10ns, data hold time / 10ns, data bits, master mode flag, bus multiplexing flag, data format For example: communication parameters = 30, 50, 100, 16, 2, 1, 0 This represents setting the communication parameters as: control signal hold time = 300ns, address hold time = 500ns, data hold time = 1us, 16-bit data bus, working in general master mode, bus multiplexing (data bus is disabled, using address bus to transmit address and data), and using general data format; The supported data formats are as follows (taking 32-bit address bus and 32-bit data bus as an example): 0 - general data format, the host sends data and the slave transmits data containing address information and data information, and the address and data appear in pairs, such as (hexadecimal): 00 02 03 04 05 06 07 08 10 12 13 14 15 16 17 18 00 02 03 04: first address 0x04030200; 05 06 07 08: first data 0x08070605; 10 12 13 14: second address 0x14131210; 15 16 17 18: second data 0x18171615; Special note: the address in the data sent by the slave is the offset address relative to the buffer area.

[0057] The host needs to send the address when reading data, and the slave uploads the received address when being read data, such as: 00 02 03 04 10 12 13 14 00 02 03 04: first address 0x04030200; 10 12 13 14: second address 0x14131210; The above information is sent in the read-only host mode, and the general host mode only supports single address reading; The read return data format is: 05 06 07 08 15 16 17 18 05 06 07 08: first data 0x08070605; 15 16 17 18: second data 0x18171615; The data format is simplified, and the host sends data, and the slave transmits data only containing data information, such as: 05 06 07 08 15 16 17 18 05 06 07 08: first data 0x08070605; 15 16 17 18: second data 0x18171615; The general host mode cannot read data, and the read-only host mode needs to send placeholder data when reading data, and the slave has no upload information when being read data, such as: FF FF FF FF FF FF FF FF Indicates that two data are read, and the return data format is: 05 06 07 08 15 16 17 18 05 06 07 08: first data 0x08070605; 15 16 17 18: second data 0x18171615; Configuration instruction 2: address bus drive control sequence = control line number | value, control line number | value... control line number | value Explanation: When setting, group according to ‘,’ from front to back, and set the control line number in the control bus interface, and the value after ‘|’ is the level to be set, such as: Address bus drive control sequence = 1|0, 2|1, 3|1, 0|1 It represents setting four control lines, control line 1 = 0, control line 2 = 1, control line 3 = 1, and control line 0 = 1.

[0058] If the signal line number is 0xFF, it means that all control lines are set, in this case, each control line is set at the same time, the value of each control line corresponds to each bit in the set value, and the above example can also be written as: send address control signal = 0xFF | 0x0E; Configuration instruction 3: address bus driving control sequence = control line number | value, control line number | value... control line number | value The format is the same as above. Configuration instruction 4: data bus driving control sequence = control line number | value, control line number | value... control line number | value The format is the same as above. Configuration instruction 5: data bus driving control sequence = control line number | value, control line number | value... control line number | value The format is the same as above. Configuration instruction 6: read data control sequence = control line number | value, control line number | value... control line number | value The format is the same as above. Configuration instruction 7: read data control sequence = control line number | value, control line number | value... control line number | value The format is the same as above. Configuration instruction 8: address valid signal detection parameter = detection edge 1, detection edge 2, count value, delay time after detection Configuration instruction 9: write data valid signal detection parameter = detection edge 1, detection edge 2, count value, delay time after detection Configuration instruction 10: read data request signal detection parameter = detection edge 1, detection edge 2, count value, delay time after detection Description: The three parameters are used in slave mode, each parameter supports detection of 2 edges, after the specified edge is detected by the debugging tool, the counting starts, and the count is reset to zero, and then the data on the address bus is read / the data on the data bus is read / the data is transferred to the data bus after a specified delay time; Detection edge value range: 0-not used, 1-rising edge, 2-falling edge; Delay time after detection unit: nanosecond. 4) According to the actual needs, set the relevant parameters of the parallel port according to the configuration instruction information sent by the debugging tool; 5) Send exit configuration mode (global specific instruction 2) to the debugging tool through the data channel, so that the data channel exits the configuration mode and restores the data transparent transmission mode.

[0059] Working principle of the application

[0060] Current based on asynchronous serial port general debugging software is very common, if can use serial port debugging software debugging parallel port, will greatly improve the efficiency of debugging. Considering that most parallel port, are including a group of address bus, a group of data bus and a group of control signal line, in embedded field, address bus generally will not more than 32 bit, data bus will not more than 16 bit, the present application supports 8 bit, 16 bit, 32 bit address bus / data bus, adapt to different embedded peripheral requirements. Read and write timing is actually using the level and edge of control signal line indicates the state of data on address bus and data bus. For the host, the indispensable parameter is the order and level value of each control signal output before and after sending address and data, as well as the holding time of control signal, address and data. For slave, most cases are to get address according to the edge of a certain control signal, get data according to the edge of a certain control signal and send data to data bus according to the edge of a certain control signal.

[0061] Based on the above common features of parallel port, it is completely possible to use microcontroller to realize the read and write operation of parallel port in master-slave mode, and the operation instruction, data source and destination can be completely connected to USB.

[0062] The USB_CDC_ACM specification based on USB serial universal bus is an abstraction of asynchronous serial port, mainly used for realizing virtual serial port. By mapping the common configuration parameters of parallel port to the configuration parameters of asynchronous serial port in USB_CDC_ACM specification, and then converting through program, the problem of configuring parallel port parameters through serial debugging software can be solved. The data transmission of parallel port is embodied as data intercommunication between memory and GPIO register in microcontroller, so the data intercommunication channel can be established for USB virtual serial port and parallel port through program control, which has no essential difference from establishing data intercommunication between USB virtual serial port and asynchronous serial port.

[0063] In summary, by selecting appropriate microcontroller and writing corresponding program, the purpose of debugging parallel port through serial debugging software can be realized. At the same time, the data channel can transmit any data, and through program control, the information of use instruction can be sent on it, and specific instruction can be sent, which undoubtedly can increase the convenience of debugging.

Claims

1. A parallel port debugging method based on a USB virtual serial port, characterized in that, This is suitable for scenarios where the debugging host debugs the parallel port of the device being debugged using a dedicated debugging tool. The core functionality involves using a virtual serial port based on the USB_CDC_ACM specification to achieve indirect communication between the debugging host and the parallel port of the device being debugged. Specific steps include: 1) Connect the address bus, data bus, and corresponding control signal lines of the device under test and the debugging tool according to the debugging mode. Connect the debugging tool to the debugging host via USB cable and power on the debugging tool. 2) After the debugging tool is powered on, it automatically creates at least one virtual serial port based on the USB_CDC_ACM specification to serve as a communication bridge; 3) The debugging host starts the general serial port debugging software or the dedicated serial port debugging software, identifies and opens the target virtual serial port. The debugging host only needs to install the standard USB_CDC_ACM driver to establish communication; 4) After the debugging tool detects the serial port open command, it sends configuration auxiliary information to the serial port, including the mapping relationship between interface parameters and serial port parameters, supported specific commands, and debugging instructions; 5) The debugging personnel configure the parallel port parameters based on the interface type of the device being debugged and the debugging requirements, either by using the displayed parameter mapping relationship or by using specific commands; 6) After configuration, the debugging tool will manage and forward data between the USB_CDC_ACM data channel and the parallel port in real time according to the configured working mode, data format and other related parameters, so as to realize bidirectional data interaction between the debugging host and the device being debugged.

2. The parallel port debugging method based on a USB virtual serial port according to claim 1, characterized in that, The working modes include master mode and slave mode. The master mode is divided into general master mode and read-only master mode. The data formats include a general data format and a simplified data format. The general data format includes address information when the debugging tool interacts with the debugging host, while the simplified data format only contains data information. Furthermore, the support for the data format varies under different host modes.

3. The parallel port debugging method based on a USB virtual serial port according to claim 1, characterized in that, The specific instruction configuration process includes the following steps: 1) Send a globally specific command 1 to enter configuration mode; 2) Send configuration commands to complete parameter configuration; 3) Send a global specific command 2 to exit configuration mode and make the parameters effective.

4. The parallel port debugging method based on a USB virtual serial port according to claim 2, characterized in that, In slave mode, the debugging tool detects the address validity, write data validity, and read data request signals of the parallel port through dedicated pins and corresponding edge detection parameters. Before debugging, the corresponding control signals need to be connected according to the parallel port timing sequence. During uplink data transmission, the debugging tool runs the slave parallel port transceiver program to receive the address bus data and data bus data of the device under debugging, and then uploads them to the debugging host through the slave parallel port data forwarding program. During downlink data transmission, the debugging tool stores the data sent by the debugging host into the slave parallel port data buffer according to the configured data format. When the device under debugging actively reads the data, it receives the address information and sends the buffer data. At the same time, if the data format is configured as a general data format, it also uploads the address information to the debugging host.

5. The debugging method according to claim 4, characterized in that, The steps of the slave parallel port receiving program are as follows: 1) If the data format is a general data format, wait for the address valid signal to arrive; otherwise, jump to step 3). 2) Read the data on the address bus and store it in the parallel port receive buffer; 3) Wait for the write data valid signal or read data request signal to arrive; 4) If a write data valid signal arrives, proceed to the next step; otherwise, proceed to step 6). 5) Read the data on the data bus and store it in the parallel port receive buffer, then jump to step 1); 6) Transfer the data in the parallel port's pending data buffer to the data bus. If the buffer is empty, re-cycle the data transmission and jump to step 1). The steps of the slave parallel port data forwarding program are as follows: 1) Wait for the virtual serial port uplink data channel to become idle or for the uplink data buffer to be partially full; 2) Waiting for the parallel port receive buffer to be not empty; 3) Send the data from the parallel port receive buffer to the virtual serial port uplink data channel or uplink data buffer and start sending; Jump to step 1).

6. The parallel port debugging method based on a USB virtual serial port according to claim 2, characterized in that, In the host mode, the debugging tool drives the control signal lines through a set of control signal output interfaces, and sets parameters for the control sequence before address bus drive, the control sequence after address bus drive, the control sequence before data bus drive, the control sequence after data bus drive, the control sequence before reading data, and the control sequence after reading data. The driving order and driving value of the control signal lines for each control sequence parameter can be flexibly configured to achieve flexible control timing output. It also sets parameters for control signal hold time, address signal hold time, and data signal hold time, which can also be flexibly configured. When sending data, the debugging tool calls the corresponding parallel port sending program according to the set data format and sends the data to the device being debugged through the parallel port; When reading data, the debugging tool calls the corresponding parallel port reading program according to the set data format to read data from the device being debugged, and then uploads it to the debugging host via the virtual serial port channel.

7. The parallel port debugging method based on a USB virtual serial port according to claim 6, characterized in that, The parallel port sending program includes a general parallel port sending program and a simplified parallel port sending program; The steps of the parallel port universal sender program are as follows: 1) Drive the control signal lines according to the address bus drive sequence, and add a delay for the control signal hold time after each drive; 2) Send address information to the address bus; 3) Delay based on address signal hold time; 4) Drive the control signal lines according to the address bus and then drive them in sequence. Each drive is accompanied by a delay for holding the control signal. 5) Drive the control signal line according to the control sequence before driving the data bus, and add a delay for the control signal holding time after each drive; 6) Send data information to the data bus; 7) Delay according to the data signal hold time; 8) Drive the control signal line according to the control sequence after driving the data bus, and add a delay for the control signal holding time after each drive; 9) Jump to step 1) until the data transmission is complete; 10) End sending; The steps of the simplified parallel port sending program are as follows: 1) Drive the control signal lines according to the address bus drive sequence, and add a delay for the control signal hold time after each drive; 2) Send fixed address information to the address bus. The fixed address information is specified by the simplified data format address parameter. 3) Delay based on address signal hold time; 4) Drive the control signal lines according to the address bus and then drive them in sequence. Each drive is accompanied by a delay for holding the control signal. 5) Drive the control signal line according to the control sequence before driving the data bus, and add a delay for the control signal holding time after each drive; 6) Send data information to the data bus; 7) Delay according to the data signal hold time; 8) Drive the control signal line according to the control sequence after driving the data bus, and add a delay for the control signal holding time after each drive; 9) Proceed to step 5) until all data has been sent; 10) End sending; The parallel port reading program includes a general parallel port reading program and a simplified parallel port reading program; The steps of the parallel port universal reading program are as follows: 1) Drive the control signal lines according to the address bus drive sequence, and add a delay for the control signal hold time after each drive; 2) Send the address information to the address bus; 3) Delay based on address signal hold time; 4) Drive the control signal lines according to the address bus and then drive them in sequence. Each drive is accompanied by a delay for holding the control signal. 5) Drive the control signal line according to the control sequence before reading data, and add a delay for the control signal holding time after each drive; 6) Read data information from the data bus; 7) Drive the control signal line according to the control sequence after reading the data, and add a delay for the control signal holding time after each drive; 8) Jump to step 1) until all data has been read; 9) End reading; The steps of the parallel port simplified read program are as follows: 1) Drive the control signal lines according to the address bus drive sequence, and add a delay for the control signal hold time after each drive; 2) Send fixed address information to the address bus. The fixed address information is specified by the simplified data format address parameter. 3) Delay based on address signal hold time; 4) Drive the control signal lines according to the address bus and then drive them in sequence. Each drive is accompanied by a delay for holding the control signal. 5) Drive the control signal line according to the control sequence before reading data, and add a delay for the control signal holding time after each drive; 6) Read data information from the data bus; 7) Drive the control signal line according to the control sequence after reading the data, and add a delay for the control signal holding time after each drive; 8) Jump to step 5) until all data has been read; 9) End reading.

8. A parallel port debugging tool based on a USB virtual serial port, characterized in that, The dedicated hardware for implementing the debugging method of any one of claims 1-7 includes a microcontroller, a USB interface, an address bus interface, a data bus interface, a control line interface, a detection interface, peripheral circuitry, and an optional signal selection module; As the core control unit, the microcontroller has kernel, RAM, FLASH, GPIO functions, external interrupt functions, timer / counter functions, and USB slave functions. It is used to run debugging method programs and implement parameter configuration management, parameter mapping conversion, and data forwarding logic. The USB interface is used to establish a physical connection and communication link between the debugging tool and the debugging host, enabling the debugging host to communicate with the microcontroller through the standard USB_CDC_ACM driver; The address bus interface and data bus interface are partially or fully physically connected to the corresponding interfaces of the device being debugged; The control line interface is used in host mode and, as needed, achieves partial or complete physical connection with the corresponding interface of the device being debugged; Detection interface: Applied to slave mode, it includes at least three sub-interfaces: address valid signal detection interface, write data valid signal detection interface, and read data request detection interface; The peripheral circuitry includes voltage regulator components, clock components, resistors, and capacitors, providing the microcontroller with a stable power supply, clock signal, and signal matching support.

9. The parallel port debugging tool based on a USB virtual serial port according to claim 8, characterized in that, The debugging tool supports address bus and data bus multiplexing. Multiplexing mode can be enabled through parameter configuration. In multiplexing mode, the data bus interface is disabled, and both address and data are transmitted through the address bus interface.

10. The debugging tool according to claim 8, characterized in that, The signal selection module is a dual-channel selection module, used in scenarios where the debugging tool acts as a slave and the host being debugged has the same action on signal line A, but different functions are represented by the level of signal line B. These two signal lines need to be connected to the write data valid signal detection interface and read data request signal detection interface of the debugging tool through a dual-channel selection switch. Signal line A is connected to the common terminal of the dual-channel selection module, and signal line B is connected to the selection terminal of the dual-channel selection module. The write data valid signal detection interface and read data request signal detection interface of the debugging tool are respectively connected to the two selection channels of the dual-channel selection switch according to the truth table of signal lines A / B.