A single chip computer debugging method, device, equipment and storage medium

Receive processor stop and debugging instructions through the I2C bus, realizing debugging of 8051 microcontroller, avoiding the use of JTAG emulator, reducing costs and solving the problem of data anomalies during debugging.

CN117518952BActive Publication Date: 2024-10-29无锡沐创集成电路设计有限公司
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311748538.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-18
Publication Date
2024-10-29
Estimated Expiration
2043-12-18

AI Technical Summary

Technical Problem

In the existing technology, debugging the 8051 microcontroller requires the use of a JTAG emulator, which increases labor costs and resource consumption in understanding the complex JTAG protocol.

Method used

Receive processor stop instructions and debugging instructions through the I2C bus, suspend the operation of the central processor, back up user program code and register values, and perform debugging operations based on debugging instructions until the preset exit conditions are met and the backup data is restored.

Benefits of technology

There is no need to use an additional JTAG emulator, which reduces the cost of use, and commands are transmitted through the local integrated circuit bus, avoiding the problem of data anomalies during debugging.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117518952B_ABST
    Figure CN117518952B_ABST
Patent Text Reader

Abstract

The present application discloses a single-chip debugging method, device, equipment and storage medium, which relates to the field of automation, including: receiving a processor stop instruction through a local integrated circuit bus, and suspending the operation of a central processing unit based on the processor stop instruction; judging whether the central processing unit stops operating, and if the central processing unit stops operating, backing up the current user program code and the current local register value to obtain a backup code and a backup register value; receiving a debugging instruction through a local integrated circuit bus, performing a current round of debugging operations based on the debugging instruction, and performing the next round of debugging operations after the current round of debugging operations ends, until a preset debugging exit condition is met, and restoring the backup code and the backup register value. In this way, the additional use of a JTAG emulator for debugging is avoided, effectively reducing the cost of use.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of automation, and in particular to a single chip computer debugging method, device, equipment and storage medium. Background Art

[0002] The 8051 microcontroller is an 8-bit wide chip microcontroller, which belongs to a type of MCS-51 single chip. The 8051 microcontroller is a synchronous sequential logic system. The operation of the entire system is completely dependent on the internal clock signal of the system to generate various action cycles and synchronization signals. The 8051 microcontroller has a built-in clock generator. When in use, you only need to connect a quartz crystal resonator or other oscillator and capacitor to allow the system to generate the correct clock signal. Compared with other microprocessors, the 8051 has the advantages of being simple to use and low cost.

[0003] In the prior art, debugging of an 8051 microcontroller usually requires the use of a JTAG (Joint Test Action Group) emulator. However, debugging of an 8051 microcontroller using a JTAG emulator often requires understanding of the complex JTAG protocol, which increases labor costs and resource consumption. Summary of the invention

[0004] In view of this, the purpose of the present invention is to provide a single-chip microcomputer debugging method, device, equipment and storage medium, which can debug the single-chip microcomputer through the I2C (Inter-Integrated Circuit) bus, avoid the additional use of JTAG emulator for debugging, and effectively reduce the cost of use. The specific scheme is as follows:

[0005] In a first aspect, the present application discloses a single-chip microcomputer debugging method, which is applied to an 8051 single-chip microcomputer, comprising:

[0006] receiving a processor stop instruction via a local integrated circuit bus, and suspending the operation of a central processing unit based on the processor stop instruction;

[0007] Determine whether the central processing unit stops operating, and if the central processing unit stops operating, back up the current user program code and the current local register value to obtain a backup code and a backup register value;

[0008] Debug instructions are received through the local integrated circuit bus to perform a current round of debugging operations based on the debugging instructions, and a next round of debugging operations is performed after the current round of debugging operations is completed until a preset debugging exit condition is met, and the backup code and the backup register value are restored.

[0009] Optionally, receiving a processor stop instruction through a local integrated circuit bus, and suspending the operation of a central processing unit based on the processor stop instruction, comprises:

[0010] determining whether the local integrated circuit bus receives a processor stop instruction, and if the processor stop instruction is received, sending the processor stop instruction to the test command cache through the local integrated circuit bus;

[0011] The processor stop instruction is sent to the central processing unit through the test command buffer, so that the central processing unit starts the debugging mode based on the processor stop instruction and suspends the operation.

[0012] Optionally, the determining whether the central processing unit stops operating, if the central processing unit stops operating, backing up the current user program code and the current local register value to obtain a backup code and a backup register value, includes:

[0013] Acquiring the current state of the CPU through the local state register, so as to determine whether the CPU stops operating through the current state;

[0014] If the central processing unit stops operating, the current user program code and the current local register value are backed up, so that the obtained backup code is stored in the user program memory, and the backup register value is stored in the data memory.

[0015] Optionally, receiving a debugging instruction through the local integrated circuit bus to perform a current round of debugging operation based on the debugging instruction includes:

[0016] receiving a debug instruction via the local integrated circuit bus, and sending the debug instruction to a test command cache;

[0017] The debugging instruction is sent to the central processing unit by using the test command cache, so that the central processing unit parses the debugging instruction based on a preset protocol and performs corresponding debugging operations based on the parsing result.

[0018] Optionally, using the test command cache to send the debugging instruction to the central processing unit so that the central processing unit parses the debugging instruction based on a preset protocol and performs a corresponding debugging operation based on the parsing result includes:

[0019] Using the test command cache to send the debugging instruction to the central processing unit, so that the central processing unit parses the debugging instruction based on a preset protocol to generate a corresponding parsing result;

[0020] If the analysis result indicates that the debugging instruction is the first running instruction, the backup code and the backup register value are restored, debugging is exited, a preset program counter and the current user program code are read, and the central processing unit is re-run;

[0021] If the analysis result indicates that the debugging instruction is a second running instruction, restoring the backup code and the backup register value, and modifying the current program counter value of the preset program counter;

[0022] If the analysis result indicates that the debugging instruction is a control instruction, a corresponding test program is read from a preset test program memory and the test program is executed.

[0023] Optionally, the preset debugging exit condition is receiving a debugging exit instruction in any round of debugging.

[0024] Optionally, the local integrated circuit bus is an I2C bus.

[0025] In a second aspect, the present application discloses a single-chip microcomputer debugging device, which is applied to an 8051 single-chip microcomputer, comprising:

[0026] An operation stop module, configured to receive a processor stop instruction through a local integrated circuit bus, and suspend the operation of a central processing unit based on the processor stop instruction;

[0027] A data backup module, used to determine whether the central processing unit stops operating. If the central processing unit stops operating, the current user program code and the current local register value are backed up to obtain a backup code and a backup register value;

[0028] The debugging module is used to receive debugging instructions through the local integrated circuit bus, perform this round of debugging operations based on the debugging instructions, and perform the next round of debugging operations after the current round of debugging operations ends, until the preset debugging exit condition is met, and restore the backup code and the backup register value.

[0029] In a third aspect, the present application discloses an electronic device, comprising:

[0030] Memory, used to store computer programs;

[0031] The processor is used to execute the computer program to implement the single chip microcomputer debugging method as described above.

[0032] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned single-chip microcomputer debugging method.

[0033] In the present application, firstly, a processor stop instruction is received through the local integrated circuit bus, and the operation of the central processor is suspended based on the processor stop instruction, and then it is determined whether the central processor stops operating. If the central processor stops operating, the current user program code and the current local register value are backed up to obtain the backup code and the backup register value. Finally, a debugging instruction is received through the local integrated circuit bus to perform the current round of debugging operation based on the debugging instruction, and the next round of debugging operation is performed after the current round of debugging operation is completed until the preset debugging exit condition is met, and the backup code and the backup register value are restored. It can be seen that the method of the present application needs to transmit commands through the local integrated circuit bus. In a round of debugging, when the processor stop instruction is received, the operation of the central processor is suspended, and the current user program code and the current local register value are backed up. When the debugging instruction is received, the corresponding single-chip microcomputer debugging is performed, and the next round of debugging is performed until the preset debugging exit condition is met, then the debugging is exited, and the backup code and the backup register value are restored. In this way, the single-chip microcomputer can be debugged through the local integrated circuit bus, avoiding the additional use of the JTAG emulator for debugging, and effectively reducing the use cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0035] Figure 1 A flow chart of a single chip microcomputer debugging method provided for this application;

[0036] Figure 2 A single-chip microcomputer debugging method processing timing diagram provided in this application;

[0037] Figure 3 A hardware circuit diagram of an 8051 single-chip microcomputer provided for this application;

[0038] Figure 4 A schematic diagram of the structure of a single-chip microcomputer debugging device provided in this application;

[0039] Figure 5 A structural diagram of an electronic device provided for this application. DETAILED DESCRIPTION

[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0041] In the prior art, debugging of an 8051 microcontroller usually requires the use of a JTAG emulator, but debugging of an 8051 microcontroller with the use of a JTAG emulator often requires understanding of a complex JTAG protocol, which increases labor costs and resource consumption.

[0042] In order to overcome the above technical problems, the present application discloses a single-chip microcomputer debugging method, which is applied to an 8051 single-chip microcomputer, comprising:

[0043] Step S11, receiving a processor stop instruction via a local integrated circuit bus, and suspending the operation of the central processing unit based on the processor stop instruction.

[0044] In this embodiment, it is necessary to receive the corresponding instruction through the local integrated circuit bus so that the central processor can perform the corresponding operation based on the instruction. The specific process is as follows: determine whether the local integrated circuit bus receives the processor stop instruction. If the processor stop instruction is received, send the processor stop instruction to the test command cache through the local integrated circuit bus; send the processor stop instruction to the central processor through the test command cache, so that the central processor can start the debugging mode based on the processor stop instruction and suspend the operation. That is, in this application, if Figure 2As shown, the information in the 8051 single-chip microcomputer can be transmitted through the I2C bus. When the single-chip microcomputer needs to be debugged, the operation of the central processing unit in the single-chip microcomputer needs to be suspended first. Therefore, when the single-chip microcomputer debugging is turned on, it is necessary to determine whether the processor stop instruction is received. If the processor stop instruction is received, the processor stop instruction needs to be forwarded to the test command cache through the I2C bus, and the processor stop instruction is sent to the central processing unit of the 8051 single-chip microcomputer through the test command cache, so that the central processing unit can turn on the debugging mode based on the processor stop instruction and stop the operation. It should be explained that the I2C bus is an I2C module that comes with the 8051 single-chip microcomputer core. As a slave, it receives the signal of the master outside. It can be used as a data receiving function to receive external data signals, and can also be used as a debugging function to receive external debugging commands. However, I2C can only receive byte-level data serially, and the master needs to send the test command to the test command cache serially through I2C for caching. Then the test command cache sends the command to the central processing unit of the 8051 single-chip microcomputer through the system bus. In this way, commands can be sent and received through the I2C bus, and the I2C bus has fewer ports and is more convenient to use. It is not affected by the clock frequency of the Master, and docking is also simpler.

[0045] Step S12, determining whether the central processing unit stops operating. If the central processing unit stops operating, backing up the current user program code and the current local register value to obtain a backup code and a backup register value.

[0046] In this embodiment, after the central processor stops operating, it is necessary to back up the current user program code and local register value to avoid modifying the relevant data during the test process, resulting in abnormal operation of the user program after exiting the test. The specific process is as follows: the current state of the central processor is obtained through the local status register to determine whether the central processor stops operating through the current state; if the central processor stops operating, the current user program code and the current local register value are backed up to store the obtained backup code in the user program memory and the backup register value in the data memory. That is, when the central processor receives the processor stop instruction, it will stop operating according to the processor stop instruction. It should be explained that in order to determine the current state of the current central processor, the operation status information of the central processor can be collected through the local status register, and the operation status information can be judged as RUN operation, STOP stop operation or BREAK breakpoint stop. If the current processing operation state is STOP stop operation, it is necessary to back up the current user program code and store the backup code in the user program memory, back up the current local register value, and store the current local register value in the data memory. This avoids the situation where the relevant data is modified during the test, causing the user program to run abnormally and cannot be recovered after exiting the test.

[0047] Step S13, receiving debugging instructions through the local integrated circuit bus, performing this round of debugging operations based on the debugging instructions, and performing the next round of debugging operations after the current round of debugging operations ends, until the preset debugging exit condition is met, and restoring the backup code and the backup register value.

[0048] In this embodiment, it is necessary to receive debug instructions through a local integrated circuit bus, that is, an I2C bus, and forward the debug instructions to a central processing unit so that the central processing unit can perform corresponding debugging. The specific process is as follows: receiving debug instructions through the local integrated circuit bus, and sending the debug instructions to a test command cache; using the test command cache to send the debug instructions to the central processing unit, so that the central processing unit can parse the debug instructions based on a preset protocol and perform corresponding debugging operations based on the parsing results. That is, it is necessary to receive the debugging instruction through the I2C bus and send the debugging instruction to the test command cache. The test command cache can forward the test command to the central processing unit. When the central processing unit receives the test command, it can perform corresponding operations according to the type of the test command. The specific process is as follows: use the test command cache to send the debugging instruction to the central processing unit, so that the central processing unit parses the debugging instruction based on the preset protocol to generate a corresponding parsing result; if the parsing result indicates that the debugging instruction is a first running instruction, the backup code and the backup register value are restored, the debugging is exited, the preset program counter and the current user program code are read, and the central processing unit is re-run; if the parsing result indicates that the debugging instruction is a second running instruction, the backup code and the backup register value are restored, and the current program counter value of the preset program counter is modified; if the parsing result indicates that the debugging instruction is a control instruction, the corresponding test program is read from the preset test program memory, and the test program is executed. That is, after the CPU receives the debugging instruction, it can parse the debugging instruction. If the parsing result indicates that the debugging instruction is the first running instruction, that is, the running instruction, it is necessary to replace the current user program code and the current register value with the backup code and the backup register value to restore the user program code and the register value, and then exit the debugging mode of the CPU, read the preset program counter, re-run the CPU, and run the restored user program code; if the parsing result indicates that the debugging instruction is the second running instruction, that is, the single-step running instruction, it is necessary to replace the current user program code and the current register value with the backup code and the backup register value to restore the user program code and the register value, and increase the current program counter value by one bit, and then perform the next round of debugging; if the parsing result indicates that the debugging instruction is a control instruction, it is necessary to read the corresponding test program from the preset test program memory, execute the test program, and perform corresponding read and write operations. When all debugging instructions are executed and the exit debugging instruction is received, the debugging mode can also be exited and the user program code can be executed.

[0049] It can be seen that in this embodiment, the processor stop instruction is first received through the local integrated circuit bus, and the operation of the central processor is suspended based on the processor stop instruction, and then it is determined whether the central processor stops operating. If the central processor stops operating, the current user program code and the current local register value are backed up to obtain the backup code and the backup register value. Finally, the debugging instruction is received through the local integrated circuit bus to perform the current round of debugging operations based on the debugging instruction, and the next round of debugging operations is performed after the current round of debugging operations are completed until the preset debugging exit condition is met, and the backup code and the backup register value are restored. It can be seen that the method of the present application needs to transmit commands through the local integrated circuit bus. In a round of debugging, when the processor stop instruction is received, the operation of the central processor is suspended, and the current user program code and the current local register value are backed up. When the debugging instruction is received, the corresponding single-chip microcomputer debugging is performed, and the next round of debugging is performed until the preset debugging exit condition is met, then the debugging is exited, and the backup code and the backup register value are restored. In this way, on the one hand, commands can be sent and received through the I2C bus, avoiding the use of JTAG emulator, reducing the cost of use, and not being affected by the clock frequency of the Master, making docking easier; on the other hand, each time debugging is entered, the registers and user programs must be backed up first to prevent related data from being modified during the test, resulting in abnormal operation of the user program after exiting the test.

[0050] See also Figure 3 As shown, the embodiment of the present invention discloses a single chip microcomputer debugging method, comprising:

[0051] like Figure 3As shown, it is a hardware circuit structure diagram of a single-chip microcomputer debugging method, in which it is necessary to use the I2C bus as a slave to receive the master's signal. When a command is received, it is necessary to use I2C to send the received command to the test command cache through the parallel IO port. The test command cache can send the received test command to the central processing unit of the 8051 single-chip microcomputer through the system bus. It should be noted that the parallel IO port can be used as a common input and output port, and can also be used as a dedicated port of I2C and UART (Universal Asynchronous Receiver / Transmitter). After the CPU obtains the test command, the running state of the CPU can be determined through the status register, and then the corresponding operation can be performed. If the received test instruction is a running instruction, the backed-up user program code can be read from the FLASH memory of the program memory, and the backed-up register value can be read from the data memory to restore the user program code and the register value, and then exit the debugging state; if the received test instruction is a single-step running instruction, it is necessary to read the backed-up user program code from the FLASH memory of the program memory, and read the backed-up register value from the data memory to restore the user program code and the register value, and then read the value of the PC counter through the PC (Program Counter) pointer, and increase the value of the PC counter by one unit; if the received test instruction is a control instruction, it is necessary to read the corresponding debugging code from the ROM (Read-Only Memory), and run the debugging code to perform debugging operations. When the debugging instruction is executed and no new debugging instructions are received, the debugging mode can be exited and the user program can be executed.

[0052] It is further necessary to explain that in the debugging code, relevant protocols can be specified: the first type of debugging instructions, the encoding of CPU state control instructions: 1. 0xdeadbeefaa: stop running the CPU; 2. 0xdeadbeefb0: run the CPU; 3. 0xdeadbeefb1: single-step run the CPU. The second type of debugging instructions, the encoding of CPU read and write control instructions: 1. 0xdeadbeef0: read 8051 internal RAM operation; 2. 0xdeadbeef1: write 8051 internal RAM operation; 3. 0xdeadbeef2: read 8051 external RAM operation; 4. 0xdeadbeef3: write 8051 external RAM operation; 5. 0xdeadbeef4: read SFR register; 6. 0xdeadbeef5: write SFR register; 7. 0xdeadbeef6~0xdeadbeefe: read register; 8. 0xdeadbeef10~0xdeadbeef17: write register. The use example of debugging instructions is as follows: the external master sends 0xdeadbeef1, 0x1234, 0x55: the master writes 0x55 data to the 8051 internal RAM address 0x1234. In this way, the protocol can be customized and a simple customized protocol can be used. There is no need to understand the complex JTAG protocol, making debugging simpler, saving a lot of human resources and saving costs.

[0053] See also Figure 4 As shown, the embodiment of the present invention discloses a single-chip microcomputer debugging device, which is applied to an 8051 single-chip microcomputer, including:

[0054] The operation stop module 11 is used to receive a processor stop instruction through a local integrated circuit bus, and suspend the operation of the central processing unit based on the processor stop instruction;

[0055] The data backup module 12 is used to determine whether the central processing unit stops operating. If the central processing unit stops operating, the current user program code and the current local register value are backed up to obtain a backup code and a backup register value;

[0056] The debugging module 13 is used to receive debugging instructions through the local integrated circuit bus to perform this round of debugging operations based on the debugging instructions, and to perform the next round of debugging operations after the current round of debugging operations is completed until the preset debugging exit conditions are met, and the backup code and the backup register value are restored.

[0057] It can be seen that in this embodiment, the processor stop instruction is first received through the local integrated circuit bus, and the operation of the central processor is suspended based on the processor stop instruction, and then it is determined whether the central processor stops operating. If the central processor stops operating, the current user program code and the current local register value are backed up to obtain the backup code and the backup register value. Finally, the debugging instruction is received through the local integrated circuit bus to perform the current round of debugging operation based on the debugging instruction, and the next round of debugging operation is performed after the current round of debugging operation is completed until the preset debugging exit condition is met, and the backup code and the backup register value are restored. It can be seen that the method of the present application needs to transmit commands through the local integrated circuit bus. In a round of debugging, when the processor stop instruction is received, the operation of the central processor is suspended, and the current user program code and the current local register value are backed up. When the debugging instruction is received, the corresponding single-chip microcomputer debugging is performed, and the next round of debugging is performed until the preset debugging exit condition is met, then the debugging is exited, and the backup code and the backup register value are restored. In this way, the single-chip microcomputer can be debugged through the local integrated circuit bus, avoiding the additional use of the JTAG emulator for debugging, and effectively reducing the use cost.

[0058] In some embodiments, the operation stop module 11 may specifically include:

[0059] an instruction transmission unit, configured to determine whether the local integrated circuit bus receives a processor stop instruction, and if the processor stop instruction is received, send the processor stop instruction to the test command cache via the local integrated circuit bus;

[0060] The operation suspension unit is used to send the processor stop instruction to the central processing unit through the test command cache, so that the central processing unit starts the debugging mode based on the processor stop instruction and suspends the operation.

[0061] In some embodiments, the operation stop module 11 may specifically include:

[0062] A state determination unit, used for obtaining a current state of the central processing unit through a local state register, so as to determine whether the central processing unit stops operating through the current state;

[0063] The data backup unit is used to back up the current user program code and the current local register value if the central processing unit stops operating, so as to store the obtained backup code in the user program memory and store the backup register value in the data memory.

[0064] In some embodiments, the debugging module 13 may specifically include:

[0065] A debug instruction forwarding submodule, configured to receive debug instructions via the local integrated circuit bus and send the debug instructions to a test command cache;

[0066] The debugging execution submodule is used to send the debugging instruction to the central processing unit by using the test command cache, so that the central processing unit parses the debugging instruction based on a preset protocol and performs corresponding debugging operations based on the parsing result.

[0067] In some embodiments, the debugging execution submodule may specifically include:

[0068] An instruction parsing unit, used for sending the debugging instruction to the central processing unit by using the test command cache, so that the central processing unit parses the debugging instruction based on a preset protocol to generate a corresponding parsing result;

[0069] A first execution unit, configured to restore the backup code and the backup register value, exit debugging, read a preset program counter and the current user program code, and re-run the central processing unit if the analysis result indicates that the debugging instruction is a first running instruction;

[0070] a second execution unit, configured to restore the backup code and the backup register value, and modify the current program counter value of the preset program counter if the analysis result indicates that the debugging instruction is a second running instruction;

[0071] The third execution unit is configured to read a corresponding test program from a preset test program memory and execute the test program if the analysis result indicates that the debugging instruction is a control instruction.

[0072] Furthermore, the present application also discloses an electronic device. Figure 5 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.

[0073] Figure 5 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the single-chip debugging method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0074] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0075] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0076] The operating system 221 is used to manage and control the hardware devices on the electronic device 20 and the computer program 222, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the single-chip debugging method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.

[0077] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the single-chip microcomputer debugging method disclosed above is implemented. The specific steps of the method can refer to the corresponding contents disclosed in the above embodiments, and will not be repeated here.

[0078] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0079] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0080] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0081] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0082] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A single chip microcomputer debugging method, characterized in that: Applicable to 8051 microcontrollers, including: receiving a processor stop instruction via a local integrated circuit bus, and suspending the operation of a central processing unit based on the processor stop instruction; Determine whether the central processing unit stops operating, and if the central processing unit stops operating, back up the current user program code and the current local register value to obtain a backup code and a backup register value; receiving a debugging instruction through the local integrated circuit bus, performing a current round of debugging operations based on the debugging instruction, and performing a next round of debugging operations after the current round of debugging operations ends, until a preset debugging exit condition is met, and restoring the backup code and the backup register value; The receiving of the debugging instruction through the local integrated circuit bus to perform the current round of debugging operation based on the debugging instruction includes: receiving a debug instruction via the local integrated circuit bus, and sending the debug instruction to a test command cache; Using the test command cache to send the debugging instruction to the central processing unit, so that the central processing unit parses the debugging instruction based on a preset protocol and performs corresponding debugging operations based on the parsing result; The step of using the test command cache to send the debugging instruction to the central processing unit so that the central processing unit parses the debugging instruction based on a preset protocol and performs corresponding debugging operations based on the parsing result includes: Using the test command cache to send the debugging instruction to the central processing unit, so that the central processing unit parses the debugging instruction based on a preset protocol to generate a corresponding parsing result; If the analysis result indicates that the debugging instruction is the first running instruction, the backup code and the backup register value are restored, debugging is exited, a preset program counter and the current user program code are read, and the central processing unit is re-run; If the analysis result indicates that the debugging instruction is a second running instruction, restoring the backup code and the backup register value, and modifying the current program counter value of the preset program counter; If the analysis result indicates that the debugging instruction is a control instruction, a corresponding test program is read from a preset test program memory and the test program is executed.

2. The single chip microcomputer debugging method according to claim 1, characterized in that: The receiving a processor stop instruction through a local integrated circuit bus and suspending the operation of a central processing unit based on the processor stop instruction includes: determining whether the local integrated circuit bus receives a processor stop instruction, and if the processor stop instruction is received, sending the processor stop instruction to the test command cache through the local integrated circuit bus; The processor stop instruction is sent to the central processing unit through the test command buffer, so that the central processing unit starts the debugging mode based on the processor stop instruction and suspends the operation.

3. The single chip microcomputer debugging method according to claim 1, characterized in that: The determining whether the central processing unit stops operating, and if the central processing unit stops operating, backing up the current user program code and the current local register value to obtain a backup code and a backup register value, includes: Acquiring the current state of the CPU through the local state register, so as to determine whether the CPU stops operating through the current state; If the central processing unit stops operating, the current user program code and the current local register value are backed up, so that the obtained backup code is stored in the user program memory, and the backup register value is stored in the data memory.

4. The single chip microcomputer debugging method according to claim 1, characterized in that: The preset debugging exit condition is receiving a debugging exit instruction in any round of debugging.

5. The single chip computer debugging method according to any one of claims 1 to 4, characterized in that: The local integrated circuit bus is an I2C bus.

6. A single chip microcomputer debugging device, characterized in that: Applicable to 8051 microcontrollers, including: An operation stop module, configured to receive a processor stop instruction through a local integrated circuit bus, and suspend the operation of a central processing unit based on the processor stop instruction; A data backup module, used to determine whether the central processing unit stops operating. If the central processing unit stops operating, the current user program code and the current local register value are backed up to obtain a backup code and a backup register value; A debugging module, configured to receive debugging instructions through the local integrated circuit bus, perform a current round of debugging operations based on the debugging instructions, and perform a next round of debugging operations after the current round of debugging operations ends, until a preset debugging exit condition is met, and restore the backup code and the backup register value; Wherein, the debugging module includes: A debug instruction forwarding submodule, configured to receive debug instructions via the local integrated circuit bus and send the debug instructions to a test command cache; A debugging execution submodule, used to send the debugging instruction to the central processing unit by using the test command cache, so that the central processing unit parses the debugging instruction based on a preset protocol and performs corresponding debugging operations based on the parsing result; Wherein, the debugging execution submodule includes: An instruction parsing unit, used for sending the debugging instruction to the central processing unit by using the test command cache, so that the central processing unit parses the debugging instruction based on a preset protocol to generate a corresponding parsing result; A first execution unit, configured to restore the backup code and the backup register value, exit debugging, read a preset program counter and the current user program code, and re-run the central processing unit if the analysis result indicates that the debugging instruction is a first running instruction; a second execution unit, configured to restore the backup code and the backup register value, and modify the current program counter value of the preset program counter if the analysis result indicates that the debugging instruction is a second running instruction; The third execution unit is configured to read a corresponding test program from a preset test program memory and execute the test program if the analysis result indicates that the debugging instruction is a control instruction.

7. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, used for executing the computer program to implement the single chip microcomputer debugging method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed by a processor, implements the single-chip microcomputer debugging method as claimed in any one of claims 1 to 5.

Citation Information

Patent Citations

  • SOC (System On Chip) chip debugging equipment, method and device

    CN102033807A