STM32 learning experience eleven: ST-LINK debug software and hardware simulation debugging method principle +

Record it, easy to read - after
the main content:
1) the JTAG / SWD debug principle;
2) software simulation debugging;
3) ST-LINK debug hardware emulation.
Official data: "the STM32 Chinese Reference Manual V10" Chapter 29 - Debugging Support DBG
1. the JTAG / SWD debug principle Brief
1.1 STM32F10xxx use Cortex ™ -M3 core, which contains hardware debug module, support for complex debugging operations. Hardware debug module allows fetch kernel (instruction break) or stop data (breakpoint) visit. When the kernel is stopped, the internal state and external state system kernel can all be queried. After completing the inquiry, the core and peripherals can be restored, the program will continue. When the microcontroller STM32F10x connected to the debugger and start debugging, the debugger uses a kernel module hardware debugging debug operation. Debug Interface supports two types: 1) a serial interface (SWD, 2 data lines) ; 2) the JTAG debug interface (data line 5).
2. SWJ debug port (Serial Wire and the JTAG)
2.1 kernel integrates the STM32F10xxx serial / JTAG debug interface (SWJ-DP). This is a standard ARM CoreSight debug interface, the interface comprising a JTAG-DP (5 pins) and SW-DP Interface (pin 2);
2.2 the JTAG debug interface (JTAG-DP) provides a standard pin 5 to AHP-AP module JTAG interface. Serial debug interface (SW-DP) providing a needle 2 (data + clock) AHP-AP interface module;
2.3 SWJ-DP interface, two pins 5 and pin JTAG interface interface in SW-DP Some are multiplexed.
Here Insert Picture Description
3. SWJ debug port pins
5 3.1 STM32F10xxx general I / O port pins can be used as SWJ-DP interface. These pins are present in all of the package.
Here Insert Picture Description
4. Flexible SWJ_DP pin assignment
Here Insert Picture Description
5. JTAG / SWD interface hardware in FIG.
Here Insert Picture Description
6. The debug software simulation
6.1 before starting the simulation software, click magic wand, the Target interface model and crystal frequency confirmation chip;
Here Insert Picture Description
6.2 Debug interface, select Use Simulator, check the Run to main (), while in the last line of input DARMSTM.DLL two Dialog DLL and Parameter respectively, -pSTM32F103ZE and TRAMSTM.DLL, -pSTM32F103ZE;
Here Insert Picture Description
6.3 to compile under the project, and then click Start / Stop Debug Session start the simulation (exit simulation also click the start / Stop Debug Session).
7. software simulation debugging interface toolbar Interpretation
Here Insert Picture Description
7.1 Reset : its function is equivalent to pressing the reset button on the hardware. To achieve the equivalent of a hard reset. After pressing the button, the code will be re-executed from the beginning;
7.2 arrives at a breakpoint (the Run) : used to quickly arrives at a breakpoint, sometimes you do not need to watch how each step is performed, but want to quickly the implementation of the program to a place to see the results, this button can achieve this function, provided that you place in view of setting a breakpoint;
7.3 stops : this button when the program has been executed becomes effective, the button can make the program stopped, proceeds to step through the state;
7.4 executed into: To perform a function used to implement the functions to which, in the case where no function, is equivalent to the execution of the last button;
7.5 executed in the past : where encounter with a function by which a button can step through this function, this function without entering the single-step;
7.6 perform out : this button is entered when the function of single-step debugging, sometimes you may not have to perform the remainder of the functions, and direct step is performed by the button the remaining part of the complete function, and out of a function, return to the position of the called function;
7.7 perform to cursor : this button can quickly make the program run to cursor, in fact, quite like button function arrives at a breakpoint, but two those who are different, there may be multiple breakpoints, but only one at the cursor;
7.8 compilation window : with this button, you can view the compiled code, which is useful for analytical procedures;
7.9 Watch variables / stack window : the button press will pop up a window display variable, you can view various variable values you want to look inside;
7.10 memory View window : Deposit viewing window, you can enter the memory address in which you want to view, and then observe this piece of memory changes;
7.11 serial printer window : press the button, a window will pop up similar serial debugging assistant interface to display from the serial port print content;
7.12 logic analysis window : press this button will bring up a window logical analysis, some of the new IO port through the SETUP button, you can observe the level change these IO ports, to be displayed in various forms;
7.13 System View window : Pressing the button will pop up a watch each function execution time and the percentage of the window, used to analyze the performance function is quite useful.
8. ST-LINK debug hardware emulation
8.1 Hardware connection: ST-LINK emulator end is connected to the development version, and the other end connected to a computer via a USB cable (for downloading programs to develop Edition); the other is connected with a USB cord is connected to the serial version of the development, and the other end connected to the computer (for debug serial data view);
8.2 debug interface, select Use ST-LINK debugger, like other simulation software provided;
Here Insert Picture Description
8.3 MDK software program, click Download to download the program to the development version, click the start / Stop debug Session start simulation debugging;
8.4 to open the serial debugging assistant, click arrives at a breakpoint (if not set a breakpoint, the program has been run), then you can We observed corresponding data in the serial debugging assistant.
9. Logic Simulation Simulation analysis module
9.1 logic analysis module is only valid for the simulation software, hardware emulation invalid;
9.2 defines the GPIO pins if the program logic may be provided in the analysis window, the observed level of pin level to marquees for example, in logical analysis window is provided, a new signal analysis logic, input PORTB.5, as shown in FIG., high and low can be observed after the transport operation PB5 follows.
Here Insert Picture Description
Peripherals menu bar 10. The module
10.1 at the function module to view the appropriate registers, as an example to marquees, click Peripherals → General Purpose I / O → GPIOB, select PB.5, the debugger single-step in the simulation , the observed value change GPIOB_ODR.
Here Insert Picture Description
Knowledge points:
1) understand the software simulation and hardware emulation debugging difference debugging;
2) review the parameters ST-LINK emulator, reference STM32 learning experience ten: Configure ST-LINK emulator software Keil MDK

Published 24 original articles · won praise 2 · Views 4121

Guess you like

Origin blog.csdn.net/Leisure_ksj/article/details/105309542