CN215494580U - Single-wire simulation device of microcontroller - Google Patents

Single-wire simulation device of microcontroller Download PDF

Info

Publication number
CN215494580U
CN215494580U CN202122323626.4U CN202122323626U CN215494580U CN 215494580 U CN215494580 U CN 215494580U CN 202122323626 U CN202122323626 U CN 202122323626U CN 215494580 U CN215494580 U CN 215494580U
Authority
CN
China
Prior art keywords
microcontroller
simulator
controller
pin
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202122323626.4U
Other languages
Chinese (zh)
Inventor
张立新
刘阳阳
杨棒棒
宁尚波
赵海
吕超英
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiangsu Jicui Intelligent Integrated Circuit Design Technology Research Institute Co ltd
Original Assignee
Jiangsu Jicui Intelligent Integrated Circuit Design Technology Research Institute Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jiangsu Jicui Intelligent Integrated Circuit Design Technology Research Institute Co ltd filed Critical Jiangsu Jicui Intelligent Integrated Circuit Design Technology Research Institute Co ltd
Priority to CN202122323626.4U priority Critical patent/CN215494580U/en
Application granted granted Critical
Publication of CN215494580U publication Critical patent/CN215494580U/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The utility model discloses a single-wire simulation device of a microcontroller, which is convenient for connecting the simulator with the microcontroller and can reduce the development difficulty of the simulator.

Description

Single-wire simulation device of microcontroller
Technical Field
The utility model relates to the technical field of microcontrollers, in particular to a single-wire simulation device of a microcontroller.
Background
A Microcontroller (MCU) is a single chip microcomputer integrating the main part of a microcomputer on one chip, and its development requires the use of corresponding development tools and simulation tools. At present, a simulation tool in the market is mainly a simulator, a simulation interface adopted when the simulator communicates with a microcontroller mainly comprises a JTAG interface and an SWD interface, the JTAG interface is a four-wire system protocol, and the SWD interface is a three-wire system protocol (excluding a power line VCC and a ground line GND). Developers can download programs through the simulation interface, and can realize operations such as breakpoint setting, variable viewing, full-speed running, single-step running and the like through the Keil system.
The number of pins of the JTAG interface and the SWD interface is large, when a low-cost microcontroller is developed, if the number of reserved chip pins is small, the connecting wires need to be repeatedly disassembled and assembled, and additional connecting wires and connecting equipment are needed to realize interface connection communication, so that the mode is complex in operation and occupies more resources. In addition, the connection between the simulator and the PC is generally realized through a USB interface, and when the USB is started, a driver needs to be installed in the corresponding PC, so that a manufacturer provided with the simulator needs to design a specific driver, the application range and the use flexibility of the simulator are limited, and the workload of the manufacturer and the development difficulty of the simulator are increased.
SUMMERY OF THE UTILITY MODEL
The utility model provides a single-wire simulation device of a microcontroller, which is simple and reasonable in structural design, facilitates connection of the simulator and the microcontroller and can reduce development difficulty of the simulator, and aims to solve the problems that in the prior art, the operation of a mode of connecting the simulator and the microcontroller through a JTAG interface or an SWD interface is complex and the occupied resources are more, and the development difficulty of the simulator is increased due to the fact that a driving program needs to be installed when the simulator is connected with an upper computer PC through a USB interface.
In order to achieve the purpose, the utility model adopts the following technical scheme:
the utility model provides a single line simulation device of microcontroller, its includes the simulator, the simulator is arranged in microcontroller's development, the simulator is connected respectively microcontroller, host computer, its characterized in that, the simulator with microcontroller is single line connection, the single line is a communication line, the one end of single line is connected microcontroller's debugging port, the other end is connected the communication pin of simulator, the simulator pass through USB HID equipment with the host computer is connected, the simulator includes controller, clock, timer all with the controller is connected.
It is further characterized in that the method further comprises the steps of,
the 12 pins of the controller are connected with the microcontroller through the single wire;
the model of the controller is STM32F 103;
the USB HID equipment is connected with a 29 pin of the controller of the emulator through a USB HID equipment connecting circuit, and the USB HID equipment connecting circuit comprises a triode Q1, a resistor R15, a resistor R23, a resistor R26, a resistor R34 and a resistor R35;
the LED display device also comprises a light prompting module, wherein the light prompting module comprises a light emitting diode YELLOW, a light emitting diode RED, a light emitting diode GREEN, resistors R36, R53, R54, R21 and a capacitor C21, and is connected with pins 7, 31 and 45 of the controller;
the peripheral circuit is connected to the periphery of the controller and comprises a crystal oscillator Y1, one end of the crystal oscillator Y1 is connected with a capacitor C23, a resistor R37 and a 5-pin of the controller respectively, the other end of the crystal oscillator Y1 is connected with one end of a resistor R37, one end of a capacitor C28 and a 6-pin of the controller respectively, the other ends of the capacitors C23 and C28 are grounded, a 9-pin of the controller is connected with one ends of capacitors C29 and C30 respectively, the other ends of the capacitors C29 and C30 are grounded, a 44-pin of the controller is connected with one end of a resistor R3, and the other end of the resistor R3 is grounded.
The coding and decoding method based on the single-wire simulation device comprises a coding method, a communication method and a decoding method of a simulator and a microcontroller, and is characterized in that,
in the encoding method, the communication protocol of the simulator and the microcontroller adopts Manchester encoding;
in decoding the manchester code, performing single-wire communication with the microcontroller through a communication pin of a controller in the emulator using a capture function of a timer of the emulator, the communication method including: controlling an output mode and an input mode of a communication pin of the simulator, wherein when the communication pin is in the output mode, the simulator sends data to the microcontroller, and when the communication pin is in the input mode, the microcontroller sends data to the simulator;
when the simulator receives the data sent by the microcontroller, the decoding is carried out through the interrupt of the capture mode of the second timer, and the decoding method comprises the following steps: b1, initializing data, wherein the data includes the number of received data bits, which is recorded as count _ int (i.e. the number of interrupts), an initial value is 0, a period in which the microcontroller sends one bit of data is recorded as capture _ T, a half period in which the microcontroller sends one bit of data is recorded as in _ half _ T, the initial value is 0, a decoding error is recorded as debug _ error, a previous count value of the timer is recorded as capture _ value1, a current count value of the timer is recorded as capture _ value2, the initial values are all 0, a time difference capture _ value between a rising edge and a falling edge of the communication pin, a level value of the current communication pin is recorded as io _ value, a high level is 1, a low level is 0, and an array of 256 received data [256], and the data is used for storing the received data;
b2, enter interrupt;
b3, judging whether the voltage of the communication pin meets the condition, that is, judging whether the level of the communication pin is high level 1, if so, setting the falling edge of the clock signal of the communication pin to trigger, and if not, setting the high level value of the communication pin to be 1, otherwise, setting the rising edge of the clock signal of the communication pin to trigger, and the level value of the communication pin to be 0;
b4, acquiring the current counting value of the timer, wherein the time difference between the rising edge and the falling edge of the communication pin is the current counting value of the timer minus the previous counting value of the timer;
b5, judging whether the digit of the received data is equal to zero, if so, the digit group of the received data is equal to the level value of the current communication pin, the digit of the received data is accumulated and added by 1, the interruption is returned, and if not, the step B51 is executed:
b51, if capture _ T-2< ═ capture _ value < ═ capture _ T +2, then:
a. if in _ half _ T is equal to 1, debug _ error is equal to 1, and the return is interrupted;
b. if in _ half _ T is 0, capture _ data [ count _ int ] ═ io _ value, adding 1 to the bit number accumulation of the received data, and interrupting the return;
b52, if capture _ T/2-2< ═ capture _ value < ═ capture _ T/2+2, then:
a. if in _ half _ T is 0, in _ half _ T is 1, and the return is interrupted;
b. if in _ half _ T is 1, capture _ data [ count _ int ] ═ io _ value, the number of bits of the received data is cumulatively added to 1, and in _ half _ T equals 0, and the return is interrupted;
b53, if the capture _ value exceeds the preset threshold range, setting debug _ error to 1, and interrupting the return;
b6, returning from the interrupt, and repeating the step B1 when receiving the interrupt signal next time;
and after the data reception is finished, combining the values in the array capture _ data [256] to obtain the required decoding data.
It is further characterized in that the method further comprises the steps of,
in the communication method, the communication frequency of the simulator and the microcontroller is 10 k-500 kHz;
in the communication method, the control of the output mode and the input mode of the communication pin of the simulator through a clock and a timer comprises the following steps: a1: before a controller in the simulator reads and writes the microcontroller normally, the frequency of the microcontroller is measured, handshake connection is established, and the microcontroller sends out a clock signal when being powered on or reset;
a2, when a communication pin of the simulator is in an input mode, capturing through the timer, capturing the rising edge of the clock signal through the timer, and meanwhile, calculating the time length between two adjacent edges as a clock cycle;
a3, when a communication pin of the simulator is in an output mode, sending a plurality of '0's to the microcontroller, wherein the number of the '0's is the same as the number of the clock signals, and after receiving the '0's, the microcontroller sends a handshake connection signal to the simulator;
and A4, after the simulator and the microcontroller handshake successfully, the simulator reads and writes the relevant debugging register of the microcontroller, wherein the reading and writing comprises writing data and reading data.
In step a3, the handshake connection signal is an ECHO, and the ECHO consists of 010;
in step a4, if the data writing is performed, the emulator sends a write command and writes data to be written, and the microcontroller replies a first response signal after receiving the write command and the data;
if the data is read, the simulator sends a read instruction, the microcontroller sends response data after receiving the read instruction, and the simulator gives a second response signal after receiving the response data;
the microcontroller sends out the response data when a communication pin of the simulator is in an output mode, the response data comprises 0 or 1, and the mode of sending out 0 or 1 by the microcontroller comprises the following steps:
when 0 is sent, the communication pin outputs high level, the time is delayed, and the communication pin outputs low level, and the time is delayed;
when 1 is sent, the communication pin outputs low level, the time is delayed, and the communication pin outputs high level, and the time is delayed;
the length of the delay time is required to ensure that the output frequency of the emulator is equal to the frequency sent by the microcontroller when the handshake connection is established.
By adopting the structure of the utility model, the following beneficial effects can be achieved: this application simulator among single line simulation device is single line connection with microcontroller, and the single line is single communication line, and microcontroller's debugging port is connected to the one end of single line, and the communication pin of simulator is connected to the other end to realized simulator and microcontroller's communication connection through a communication line, this connection has only taken the communication pin of simulator, need not to occupy more pin or port resource, simple structure, and connection operation is simple swift.
The simulator is connected with the upper computer through the USB HID equipment, the USB HID equipment is a human-computer interface equipment which accords with HID category specifications and can be used without installing a driver, and therefore when the simulator is connected with the upper computer through the USB HID equipment, a special driver does not need to be developed, the driver does not need to be installed in the upper computer, and development difficulty is reduced.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required to be used in the description of the embodiments are briefly introduced below, the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings may be obtained according to the drawings without creative efforts.
FIG. 1 is a block diagram of a connection structure of a single-wire emulation device according to the present invention;
FIG. 2 is a schematic circuit diagram of the controller interface circuit and its peripheral circuits in the emulator according to the present invention;
FIG. 3 is a flow chart of the operation of the simulator of the present invention;
FIG. 4 is a diagram of the clock signals of Manchester encoding in the encoding and decoding method of the present invention;
FIG. 5 is a flow chart of the microcontroller for decoding received data according to the present invention;
FIG. 6 is a schematic circuit diagram of the USB HID device connection circuit of the present invention;
FIG. 7 is a schematic circuit diagram of a light prompting module of the present invention;
fig. 8 is a signal diagram transmitted between the emulator and the microcontroller captured by the logic analyzer after the single-wire emulation device and the encoding and decoding method of the present invention are used (i.e., a communication effect diagram between the emulator and the microcontroller).
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "comprises" and "comprising," and any variations thereof, in the description and claims of the present invention and the above-described drawings, are intended to cover a non-exclusive inclusion, such that a process, method, apparatus, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In an embodiment of the present invention, a single-wire emulation device for a microcontroller is provided, see fig. 1 and fig. 2, which includes an emulator 1, where the emulator 1 is used in development of a microcontroller 2, the emulator 1 is connected to the microcontroller 2 and an upper computer 4 respectively, the emulator 1 and the microcontroller 2 are connected by a single wire 5 (excluding a power line VCC and a ground line GND), the single wire 5 is a signal wire, one end of the single wire 5 is connected to a debugging port of the microcontroller 2, and the other end of the single wire 5 is connected to a communication pin PA2 of the emulator 1, data exchange between the emulator and the microcontroller is realized by the single wire 5, when the emulator 1 is connected to a USB of the upper computer 4 (i.e., a PC), a standard USB HID device 3 is used, so that development of a special driver for the emulator is not required, because Windows of the upper computer 4 is driven by a USB.
The simulator 1 comprises a controller, a clock and a timer, wherein the clock and the timer are connected with the controller, the model of the controller is STM32F103 in the embodiment, firmware is written, the controller is in data communication with the microcontroller 2 for simulation through a GPIO pin (namely a communication pin PA2), the microcontroller is an 8051 type microcontroller, a Debug hardware module is arranged in the microcontroller, and the Debug hardware module is responsible for communicating with the simulator and can control the execution process of the microcontroller.
The USB HID device is connected to pins 29, 32 and 33 of the controller through a USB HID device connection circuit, which includes a transistor Q1, a resistor R15, R23, R26, R34 and R35, as shown in fig. 6; the specific connection structure of the USB HID equipment connection circuit comprises: the 12 pins of the controller are connected with the other end of the single wire, the 29 pins of the controller are connected with one end of a resistor R15, the other end of a resistor R15 is respectively connected with one end of a resistor R23 and the base of a triode Q1, the emitter of a triode Q1 and the other end of a resistor R23 are both connected with a voltage source VDD, the drain of a triode Q1 is connected with one end of a resistor R26, the other end of the resistor R35 is respectively connected with one end of a resistor R35 and the 33 pins of the controller, the other end of the resistor R35 is connected with the 3 pins of a USB HID J2, the 2 pin of the USB HID J2 is connected with one end of a resistor R34, the other end of a resistor R34 is connected with the 32 pins of the controller, the power supply port VCC of the USB HID J2 is connected with a voltage source VBUS, the 5 pins of the USB HID J2 are respectively connected with the 6 pins, one end of a capacitor C74 and one end of a resistor R31, one end of a capacitor C74 and the other end of the resistor R31 are grounded. The triode Q1 has a switching function and is used for controlling the on or off of the USB HID, and the resistors R15, R23, R26, R34 and R35 have a voltage division and current limiting function.
The LED lighting prompting device also comprises a lighting prompting module, as shown in FIG. 7, wherein the lighting prompting module comprises a light emitting diode YELLOW, a light emitting diode RED, a light emitting diode GREEN, resistors R36, R53, R54, R21 and a capacitor C21, and the lighting prompting module is connected with pins 7, 31 and 45 of the controller; the concrete connection circuit structure of each electronic component in the light prompt module includes: the 31 pin of the controller is connected with the cathode of the light emitting diode YELLOW, the anode of the light emitting diode YELLOW is connected with one end of a resistor R36, the other end of a resistor R36 is respectively connected with one end of a resistor R53 and a voltage source VDD, the other end of a resistor R53 is connected with the anode of a light emitting diode RED, the cathode of the light emitting diode RED is grounded, the cathode of the light emitting diode GREEN is connected with the 45 pin of the controller, the anode of the light emitting diode GREEN is connected with one end of a resistor R54, the other end of the resistor R54 is connected with a voltage source VDDO, the 7 pin of the controller is respectively connected with one end of a resistor R21 and one end of a capacitor C21, the other end of the capacitor C21 is grounded, and the other end of a resistor R21 is connected with the voltage source VDD. The light emitting diodes YELLOW, RED and GREEN are used for displaying the working state of the controller, whether the simulator is in normal communication with the microcontroller, the simulator and the upper computer or not is judged according to the light emitting diodes, if the simulator is in normal communication with the upper computer, the normal communication is indicated, otherwise, the communication is indicated to be abnormal, the operator is prompted to reconnect or overhaul, the resistors R36, R53, R54 and R21 are used for voltage division and current limitation, and the capacitor C21 is used for filtering.
The periphery of the controller is connected with a peripheral circuit, the peripheral circuit comprises a crystal oscillator Y1, one end of a crystal oscillator Y1 is respectively connected with a capacitor C23, a resistor R37 and a 5-pin of the controller, the other end of the crystal oscillator Y1 is respectively connected with one end of a resistor R37, one end of a capacitor C28 and a 6-pin of the controller, the other ends of the capacitors C23 and C28 are grounded, a 9-pin of the controller is respectively connected with one ends of capacitors C29 and C30, the other ends of the capacitors C29 and C30 are grounded, a 44-pin of the controller is connected with one end of a resistor R3, and the other end of the resistor R3 is grounded. The capacitors C23, C28, C29 and C30 are used for filtering and filtering interference signals in communication data, so that the accuracy of development and debugging of the simulator is further ensured, and the stability of the operation of the controller is ensured.
Referring to fig. 3, a work flow of writing the firmware of the emulator specifically includes: the method comprises the steps of sequentially realizing clock initialization, port initialization, timer initialization, USB initialization and data processing, wherein the data processing comprises the steps of sequentially realizing receiving a USB data transmission command, sending the command to a microcontroller through a single line, decoding a data signal sent by the microcontroller in an interrupt and replying the USB data transmission command, and the replying of the USB data transmission command is mainly realized in a mode that a simulator sends a USB data packet to the microcontroller.
The simulator is connected with an upper computer through a USB and is identified as a USB HID device, the upper computer runs Keil software, and a DLL plug-in is compiled according to Keil AGDI documents and called by the Keil. Keil calls a function in a DLL plug-in, and the DLL calls a USB HID function to communicate with the simulator.
The following is a specific embodiment of a data encoding and decoding method during data processing in the running process of emulator firmware, based on the encoding and decoding method of the above single-wire emulation device, where the encoding and decoding method includes an encoding method, a communication method, and a decoding method of an emulator and a microcontroller, in the encoding method, a communication protocol of the emulator and the microcontroller adopts Manchester encoding, referring to fig. 4, data has a falling edge change of 0 in one cycle, and a rising edge change of 1 in one cycle, in fig. 4, clock is a clock signal, data is a data change (data is represented by 0 and 1), Manchester encoding complies with IEEE802.3 standard, and a curve corresponding to Manchester in fig. 4 represents a distance between the rising edge and the falling edge, and the distance is capture _ T or capture _ T/2.
When the Manchester code is decoded, the first timer capture function of the controller is used, and the communication pin PA2 of the controller in the simulator is used for communicating with the microcontroller, wherein the communication method comprises the following steps: controlling the output mode and the input mode of a communication pin PA2 of the simulator, wherein when the communication pin PA2 is in the output mode, the simulator sends data to the microcontroller, and when the communication pin PA2 is in the input mode, the microcontroller sends data to the simulator; the communication frequency of the simulator and the microcontroller is 10 k-500 kHz.
In the communication method, the control of the output mode and the input mode of the communication pin PA2 of the simulator through a clock and a timer comprises the following steps: a1: before a controller in the simulator reads and writes the microcontroller normally, the frequency of the microcontroller is measured, handshake connection is established, and 64 clock signals are sent out when the microcontroller is powered on or reset; a2, when a communication pin PA2 of the simulator is in an input mode, capturing by a timer, wherein the timer captures 64 rising edges of a clock signal, and simultaneously calculates the time length between two adjacent edges as a clock period;
a3, enabling a communication pin PA2 of the simulator to be in an output state, and sending 64 '0's to the microcontroller, wherein the sending frequency of the microcontroller is approximately equal to the output frequency of the microcontroller, namely the number of the '0's is the same as the number of clock signals, after the microcontroller receives the 64 '0's, the microcontroller sends a handshake connection signal to the simulator, the handshake connection signal is ECHO, and the ECHO is composed of 010;
and A4, after the simulator and the microcontroller handshake successfully, the simulator reads and writes the relevant debugging registers of the microcontroller, wherein the reading and writing comprises writing data and reading data. Specifically, the method comprises the following steps: if the data is written, the simulator sends out a write command, the data to be written is written, and the microcontroller replies a first response signal after receiving the write command and the data; if the data is read, the simulator sends a reading instruction, the microcontroller sends response data after receiving the reading instruction, and the simulator gives a second response signal after receiving the instruction and the response data;
the microcontroller sends out response data when the communication pin PA2 of the emulator is in an output mode, the response data comprises 0 or 1, and the mode of sending out 0 or 1 by the microcontroller comprises the following steps: when 0 is sent, the communication pin PA2 outputs high level and delays, and the communication pin PA2 outputs low level and delays; when 1 is sent, the communication pin PA2 outputs low level and delays, and the communication pin PA2 outputs high level and delays; the time length of the delay is required to ensure that the output frequency of the emulator is equal to the frequency sent by the microcontroller when the handshake connection is established.
Referring to fig. 5, when the emulator receives data transmitted by the microcontroller, the emulator is performed by an interrupt function of the second timer capture mode, the communication pin PA2 is switched to the input mode, and a falling edge is captured first (the manchester protocol specifies that the first bit of data transmitted by the microcontroller is 0, and the falling edge is captured for the first time), and the data decoding method includes: b1, initializing data; the data specifically includes: the number of received data bits, count _ int (i.e. the number of times of interruption) received by the emulator is initially 0;
the period of sending one bit of data by the microcontroller is recorded as a variable capture _ T;
the microcontroller sends a half period of one bit of data, which is marked as a variable in _ half _ T, and the initial value is 0;
decoding error, and recording as a variable debug _ error;
the values of the first timer are recorded as a variable capture _ value1, the values of the second timer are recorded as a variable capture _ value2, and the initial values are all 0;
the time difference between the rising edge and the falling edge of the communication pin PA2 is recorded as a variable capture _ value;
the level value of the current communication pin PA2 is marked as a variable io _ value, the high level is 1, and the low level is 0;
an array of 256 received data, denoted as variable capture _ data [256], for storing the received data;
the decoding is carried out according to the following steps: b2, enter interrupt;
b3, determining whether the voltage of the communication pin PA2 meets the condition, that is, determining whether the level of the communication pin PA2 is high level 1, if yes, setting the falling edge of the clock signal of the communication pin PA2 to trigger, the high level value of the communication pin PA2 is 1, that is, io _ value is 1, otherwise, setting the rising edge of the clock signal of the communication pin PA2 to trigger, and the level value of the communication pin PA2 is 0, that is, io _ value is 0;
b4, acquiring a current count value of the timer, namely, capture _ value2 is the current count value of the timer TIM2, and the time difference between the rising edge and the falling edge of the communication pin is the current count value of the timer minus the previous count value of the timer, namely, capture _ value2-capture _ value 1;
b5, determining whether the bit number of the received data is equal to zero, if so, then count _ int is equal to 0, then the array of the received data is equal to the level value of the current communication pin PA2, i.e., capture _ data [ count _ int ] ═ io _ value, the bit number of the received data is added to 1 in an accumulated manner, i.e., count _ int + +, and the interrupt returns, if not, i.e., count _ int! If 0, go to step B51:
b51, if capture _ T-2< ═ capture _ value < ═ capture _ T +2, then:
a. if in _ half _ T is equal to 1, debug _ error is equal to 1, and the return is interrupted;
b. if in _ half _ T is 0, capture _ data [ count _ int ] ═ io _ value, the number of bits of the received data is accumulated and added to 1, namely count _ int + +, and the interruption returns; the captured data cycle at this time is capture _ T, and an error is allowed.
B52, if capture _ T/2-2< ═ capture _ value < ═ capture _ T/2+2, then:
a. if in _ half _ T is 0, in _ half _ T is 1, and the return is interrupted; a half cycle of currently received reception data, namely capture _ T/2;
b. if in _ half _ T is 1, capture _ data [ count _ int ] ═ io _ value, adding 1 to the bit number accumulation of the received data (i.e. count _ int + +), and returning interrupted when in _ half _ T is 0, which indicates that half-period data exists in the front and is half-period currently, so that one-bit data is sampled;
b53, if the capture _ value is beyond or not in the preset threshold range, namely the capture _ value is too small or too large, the debug _ error is 1, and the return is interrupted, so that the captured data period is not in the preset range;
b6, and step B1 to B, the step B1 is repeated the next time an interrupt signal is received after the interrupt returns.
After the data reception is finished, the values in the array capture _ data [256] are combined to obtain the required decoding data. In the process of receiving data, if debug _ error is 1, it indicates that the group of data has an error. The single-wire simulation device and the encoding and decoding method are applied to the development of the microcontroller, when the simulation device and the microcontroller transmit and reply data by adopting the single wire and the encoding and decoding method, a logic analyzer is adopted to collect communication waveforms between the simulator and the microcontroller, after the simulator transmits signals, the microcontroller performs rapid reply based on the encoding and decoding method, as shown in fig. 8, the horizontal axis represents time, and the curve represents communication signals, and as can be seen from fig. 8, by adopting the single-wire device and the encoding and decoding method, effective rapid transmission of data signals can be realized.
The above is only a preferred embodiment of the present application, and the present invention is not limited to the above embodiments. It is to be understood that other modifications and variations directly derivable or suggested by those skilled in the art without departing from the spirit and concepts of the utility model are to be considered within the scope of the utility model.

Claims (5)

1. The utility model provides a single line simulation device of microcontroller, its includes the simulator, the simulator is arranged in microcontroller's development, the simulator is connected respectively microcontroller, host computer, its characterized in that, the simulator with microcontroller is single line connection, the single line is a communication line, the one end of single line is connected microcontroller's debugging port, and the other end is connected a communication pin of simulator, the simulator with USB HID equipment form with the host computer is connected, the simulator includes controller, clock, timer all with the controller is connected.
2. The single-wire emulation device of microcontroller according to claim 1, wherein the 12 pin of the controller is connected to the microcontroller via the single wire.
3. The single-wire emulation device of microcontroller according to claim 1 or 2, wherein the USB HID device is connected to pin 29 of the controller of the emulator through a USB HID device connection circuit, and the USB HID device connection circuit comprises transistor Q1, resistor R15, R23, R26, R34, R35.
4. The single-wire emulation device of microcontroller according to claim 3, characterized in that it further comprises a light prompting module, said light prompting module comprises light emitting diode YELLOW, light emitting diode RED, light emitting diode GREEN, resistor R36, R53, R54, R21, and capacitor C21, said light prompting module is connected with pins 7, 31, 45 of said controller.
5. The single-wire emulation device of a microcontroller according to claim 3, wherein a peripheral circuit is connected to the periphery of the controller, the peripheral circuit includes a crystal oscillator Y1, one end of the crystal oscillator Y1 is connected to the capacitor C23, the resistor R37 and the 5-pin of the controller, the other end of the crystal oscillator Y1 is connected to the one end of the resistor R37, the one end of the capacitor C28 and the 6-pin of the controller, the other ends of the capacitors C23 and C28 are grounded, the 9-pin of the controller is connected to the one ends of the capacitors C29 and C30, the other ends of the capacitors C29 and C30 are grounded, the 44-pin of the controller is connected to the one end of the resistor R3, and the other end of the resistor R3 is grounded.
CN202122323626.4U 2021-09-24 2021-09-24 Single-wire simulation device of microcontroller Active CN215494580U (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202122323626.4U CN215494580U (en) 2021-09-24 2021-09-24 Single-wire simulation device of microcontroller

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202122323626.4U CN215494580U (en) 2021-09-24 2021-09-24 Single-wire simulation device of microcontroller

Publications (1)

Publication Number Publication Date
CN215494580U true CN215494580U (en) 2022-01-11

Family

ID=79770017

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202122323626.4U Active CN215494580U (en) 2021-09-24 2021-09-24 Single-wire simulation device of microcontroller

Country Status (1)

Country Link
CN (1) CN215494580U (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116184857A (en) * 2023-02-20 2023-05-30 深圳市鼎芯科技电子有限公司 Single-wire simulation device of microcontroller

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116184857A (en) * 2023-02-20 2023-05-30 深圳市鼎芯科技电子有限公司 Single-wire simulation device of microcontroller
CN116184857B (en) * 2023-02-20 2024-02-13 深圳市鼎芯科技电子有限公司 Single-wire simulation device of microcontroller

Similar Documents

Publication Publication Date Title
CN101840368B (en) JTAG (Joint Test Action Group) real-time on-chip debug method and system of multicore processor
CN101004707A (en) Embedded type software debugging device, and method for implementing debugging
CN103365689A (en) Singlechip parallel burning method
CN215494580U (en) Single-wire simulation device of microcontroller
CN102801818B (en) Universal sensor interface acquisition system based on ZigBee technology
CN112564882B (en) Single-wire digital communication interface based on AHB bus
CN107291647B (en) Method for reading receiving channel data in extended serial port by DSP
CN113741217A (en) Single-wire simulation device and coding and decoding method of microcontroller
CN104714907A (en) Design method for converting PCI bus into ISA bus or APB bus
CN104102160A (en) Controller area network (CAN) bus signal transceiving analysis tool
CN111679935A (en) Configuration monitoring fault-tolerant communication method based on DMA and interrupt fusion
CN103714190A (en) Simple efficient on-line simulation method and simple efficient on-line simulation interface circuit
CN205247378U (en) PS2 interface changes USB interface converter based on singlechip
CN109859454B (en) Infrared code sending circuit, chip, remote control equipment and air conditioner based on infrared protocol
CN105354157A (en) Method, device and system for configuring IIC (Inter-Integrated Circuit) device
CN109582571B (en) Online debugging method and device, debugging slave computer, debugging host computer and system
CN111327333A (en) Decoding circuit
CN113704032A (en) Embedded heterogeneous multi-core processor architecture parallel debugging system and method
CN111913899B (en) UART (universal asynchronous receiver/transmitter) expansion method based on FSMC (frequency selective multi-media card) and FPGA (field programmable gate array)
CN204740724U (en) Automatic wireless communication system of UART
US10120828B2 (en) Bridge for bus-powered peripheral device power management
CN204028612U (en) A kind of CAN signal transmitting and receiving instrument
CN104572515A (en) Tracking module, method, system and SOC (System-On-Chip)
CN204706031U (en) Serial peripheral equipment interface SPI bus circuit and electronic equipment
CN107704417A (en) The method and its communication system to be communicated with equipment under test

Legal Events

Date Code Title Description
GR01 Patent grant
GR01 Patent grant