Mplab x ide debugging code

Source: Internet
Author: User
Tags mplab

1. In the project window, select a project or set it as the main project (right-click the project and select "set
Main ").
2. Click the "Debug project" icon (or select debug> debug project or debug> step ).
Into) start debugging.
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 the program again.
To end code execution:
• Click the "Finish debugger session" icon (or select debug> finish debugger session)
End program execution.
When using the debugging function (starting from section 4.18 "using breakpoint Control Program Execution"), run and debug
The differences between run will become obvious.
To start the debugger:
If the code is compiled for debugging and you only want to start the debugging tool, you can select

Click the down arrow next to the debug project icon and select "launch Debugger" to start the debugger)

Set or clear simple breakpoints
To set a breakpoint on a code line, Perform one of the following operations:
• Click the left edge of the code line in the source code editor.
• Press Ctrl + F8
To clear a breakpoint, Perform one of the following operations:
• Repeat the steps to set breakpoints
• Select debug> toggle breakpoint.

Code execution in one step
You can use one of the single-step functions on the Debug menu and debug toolbar to pause the function from the beginning of the code or from the breakpoint.
And then gradually execute the code. Check the variable value changes (see the next section) or determine whether the program flow is correct.
There are several ways to execute code in one step:
Step over -- execute a line of source code of the program. If this row is a function call, the entire function is executed.
And then stop.
Step into -- execute a line of source code of the program. If this row is a function call, the program runs
The first statement of the function, and then stop.
Step out -- execute a line of source code of the program. If this row is a function call, execute the function,
And return the control to the caller.
Run to cursor (run to cursor position) -- run the current project until the cursor position in the file,
And stop program execution.
Animate (continuous one-step operation)-perform one-step operation at run time, and update the register at run time
Value. The running speed of a single consecutive step is lower than the run function, but it allows you
The Register (special function register) window or the watches window to view the changed register value.

Observe symbol value changes
In the watches window, observe the value of the selected symbol. Determine during program execution that these values are
No is the expected value to help you debug the code.

To view the watches window, Perform one of the following operations:
• Choose WINDOW> debugging> watches to open the window.
• If the output window has been opened, click the watches tab in the window.
To directly create a new observation:
You can add symbols directly to the watches window through one of the following operations:
• Double-click 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 it to the watches window.
Use the new watch dialog box to create a new observation:
You can add a symbol or SFr to the watches window by using the new watch dialog box:
• Right-click the watches window and select "new watch" or choose tools> new watch. Single
Click the select button to view global symbols or SFr. Click a name in the list
And then click OK.
• In the editor window, select a symbol or SFr name, and then select "new watch" from the right-click menu ".
The name will be filled in the window. Click OK.
Observe when you want to create a new runtime:
Before adding runtime observation to the watches window, you need to set the clock:
1. Right-click the project name and select "properties ".
2. Click the debugging tool name (for example, real ice) and select the option category "Clock ).
3. Set the command speed during running.
To add a global symbol or SFr as the runtime observation, follow the instructions in the "use new watch dialog box to create a new
The operation described in "Observe", but select "New runtime watch" (New runtime clock) instead
It is "new watch ".
The symbols used during runtime observation must be adjusted to match the device memory. That is, an 8-bit device is used.
The 8-digit symbol is required.

To view symbol changes:
1. Execute debugging and run, and then pause the program.
2. Click the watches tab to make the window active.
3. For the observed symbol, continue debugging and pause to view the value changes. Observe the symbols during running, following
Continue debugging and observe the value changes during program execution.
The value of the symbol (Global symbol, SFR, array, register bit domain, etc.) can be seen only when it is in the debugging session.
To change the base number of the observed symbol:
• Right-click the row where the symbol is located and select "display value as" (Display Mode of value)

To view the variables window, Perform one of the following operations:
• Select WINDOW> debugging> variables to open the window.
• If the output window has been opened, click the variables tab in the window.
To view variable changes:
1. Execute debugging and run, and then pause the program.
2. Click the variables tab to view the window and local variable values.
To change the base number of a variable:
• Right-click the row where the variable is located and select "display value ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.