MPLAB X IDE Debug Code

Publisher:EnchantedHeartLatest update time:2020-03-28 Source: eefocusKeywords:MPLAB Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. In the Project window, select the project or make it the main project (right-click the project and select “Set as main”).
2. Click the “Debug Project” icon (or select Debug>Debug Project or Debug>Step Into) to start a debug run.
To pause the application code:
• Click the “Pause” icon (or select Debug>Pause) to pause program execution.
To run the code again:
• Click the “Continue” icon (or select Debug>Continue) to start program execution again.
To end execution of the code:
• Click the “Finish Debugger Session” icon (or select Debug>Finish Debugger Session) to
end program execution.
The difference between Run and Debug Run will become apparent when using the debugging features (starting with Section 4.18, “Controlling Program Execution with Breakpoints”).
To launch the debugger:
If your code was compiled for debugging and you just want to launch the debugging tools, you can do so by selecting the down arrow next to the “Debug Project” icon and selecting “Launch Debugger”.


Setting or Clearing Simple Breakpoints
To set a breakpoint on a line of code, do one of the following:
• Click the left margin of the line of code in the Source Editor
• Press Ctrl+F8
To clear a breakpoint, do one of the following:
• Repeat the steps for setting the breakpoint
• Select Debug>Toggle Breakpoint.


Stepping Through Code
Use one of the single-step functions on the Debug menu and Debug toolbar to step through code from the beginning of the code or after pausing at a breakpoint. Check for changes in variable values ​​(see the next section) or determine if the program flow is correct.
There are several ways to step through code:
Step Over - Executes a line of program source code. If the line is a function call, the entire function is executed and then stops.
Step Into - Executes a line of program source code. If the line is a function call, the program executes to the first statement of the function and then stops.
Step Out - Executes a line of program source code. If the line is a function call, the function is executed and control returns to the caller.
Run to Cursor - Runs the current project to the cursor position in the file and stops program execution.
Animate - Performs single-step operations at run time and updates register values ​​at run time. Continuous single-stepping runs slower than the Run function, but allows you to view changing register values ​​in the Special Function Register window or in the Watches window.


Watch symbol values ​​change
Watch the values ​​of selected symbols change in the Watches window. Determining whether these values ​​are what you expect during program execution can help you debug your code.


To view the Watches window, do one of the following:
• Select Window>Debugging>Watches to open the window.
• If the Output window is already open, click the Watches tab in the window.
To create a new watch directly:
You can add symbols directly to the Watches window by doing one of the following:
• Double-click in the Name column and enter a global symbol, SFR, or absolute address (0x300).
• Right-click a global symbol or SFR in the Editor window and select New Watch.
• Select a global symbol or SFR in the Editor window and drag and drop it into the Watches window.
To create a new watch using the New Watch dialog:
You can add symbols or SFRs to the Watches window by using the New Watch dialog:
• Right-click in the Watches window and select New Watch or select Tools>New Watch. Click the Select button to view Global Symbols or SFRs. Click a
name and click OK.
• Select the symbol or SFR name in the Editor window and select New Watch from the right-click menu.
The name populates in the window. Click OK.


To create a new runtime watch:
Before adding a runtime watch to the Watches window, you need to set the clock:
1. Right-click the project name and select “Properties”.
2. Click the debug tool name (for example, REAL ICE) and select the option category “Clock”.
3. Set the runtime instruction speed.


To add a global symbol or SFR as a runtime watch, follow the instructions under "Creating a new watch using the New Watch dialog box," except this time select "New Runtime Watch" instead of "New Watch."


Symbols used in runtime observations must be resized to match the device memory, that is, 8-bit symbols are required when using an 8-bit device.


To watch a symbol change:
1. Perform a debug run, then pause the program.
2. Click the Watches tab to make the window active.
3. For a watch symbol, continue the debug run and pause to watch the value change. For a run-time watch symbol, continue the debug run and watch the value change as the program executes.


You can only see the value of symbols (global symbols, SFRs, arrays, register bit fields, etc.) when you are in a debugging session.
To change the cardinality of the symbol you are watching:
• Right-click on the symbol's row and select "Display Value As"

To view the Variables window, do one of the following:
• Select Window>Debugging>Variables to open the window.
• If the Output window is open, click the Variables tab in the window.


To view variable changes:
1. Perform a debug run and pause the program.
2. Click the Variables tab to view window and local variable values.


To change the cardinality of a variable:
• Right-click the variable's row and select Display Value As.

Keywords:MPLAB Reference address:MPLAB X IDE Debug Code

Previous article:MPLAB X IDE keeps stopping at the splash screen and cannot be entered. Solution
Next article:Solve the problem of garbled characters in MPLAB X IDE file comments

Recommended ReadingLatest update time:2024-11-23 11:57

It is reported that Ryzen 5 3500X will be launched in the Korean market at the end of October
In order to compete with the Core F processors of its competitors, especially the popular Core i5-9400F processor, AMD recently launched the Ryzen 5 3500X processor, priced at 1,099 yuan, which has a very high cost performance. Specifically, the Ryzen 5 3500X is still based on the 7nm process and Zen 2 architecture, w
[Mobile phone portable]
It is reported that Ryzen 5 3500X will be launched in the Korean market at the end of October
Important progress has been made in the research of X-ray free electron laser oscillators
The free electron laser team of the Shanghai Light Source Center has made important progress in the research of X-ray free electron laser oscillators, and has theoretically proposed a method to generate vortex X-rays. The research shows that the output of the X-ray free electron laser oscillator can be changed from tr
[Embedded]
Vivo X60t Pro mobile phone is available on the network: 6.56-inch curved screen
vivo previously launched two mobile phones, X60t and X60t Pro+, equipped with Dimensity 1100 and Qualcomm Snapdragon 888 SoC respectively. All mobile phones in this series are equipped with Zeiss imaging system, and the latter is equipped with a micro-curved screen. At present, another mobile phone in this series, viv
[Mobile phone portable]
Vivo X60t Pro mobile phone is available on the network: 6.56-inch curved screen
Supporting 20x hybrid zoom, realme X2 Pro uses a centered quad camera
According to official news from realme, realme X2 Pro is confirmed to use a 64-megapixel quad-camera with a rear-centered design. It is understood that realme X2 Pro is the company's first smartphone with flagship configuration, equipped with a 90Hz refresh rate screen, Qualcomm Snapdragon 855 plus chipset, 64-megap
[Mobile phone portable]
The era of V2X technology has arrived
In 2021, when autonomous driving technology is not yet ready for road use, some V2X technologies will become the focus of the implementation of intelligent connected technology.   Four automakers have already mass-produced V2X technology, mainly focusing on V2I and V2V functions At present, there are four companies in
[Embedded]
The era of V2X technology has arrived
51 single chip microcomputer 8X8 dot matrix screen circularly moves left
Use timer 0 interrupt to control 8x8 dot matrix screen to shift left in a loop #include reg51.h. #include intrins.h typedef unsigned char u8; typedef unsigned int u16;   sbit SRCLK=P3^6; sbit RCLK=P3^5; sbit SER=P3^4;   u16 i,k; u16 time;    u8 code ledduan ={{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24},             
[Microcontroller]
Research and Application of Interrupt Programming Mechanism in ARM S3C2410X System
0Introduction ​ In embedded systems, the function of external devices is mainly realized by the interrupt mechanism, that is, the implementation of device function programs is organized in the form of interrupt service subroutines. The interrupt function can solve the waiting delay problem caused b
[Microcontroller]
Research and Application of Interrupt Programming Mechanism in ARM S3C2410X System
Who helped make the Xbox Series X so compact?
The Microsoft Game Stack channel recently disassembled the new Xbox Series X. In the video, special mention was made of the Xbox's SoC processor power supply system. Let's first take a look at the product image of Xbox Series X: The Xbox Series X SoC is called "Scarlett" and uses TSMC's N7 process node. The des
[Power Management]
Who helped make the Xbox Series X so compact?
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号