1.3.4 Run/Debug

Table 1-8. Running and Debugging Projects
MPLAB X IDE MPLAB Tools for VS Code

To debug a project, use one of the following methods:

  • The Debug menu, or

  • The Debug icon on the toolbar

Afterwards, the debug functions (e.g., Continue, Step Over/Into/Out, Restart, and Stop) will be added to the toolbar.

Figure 1-23. Debugging in MPLAB X IDE

Users can add breakpoints by clicking on a line of code and access other debug functions by right-clicking in the Editor window.

Figure 1-24. Adding Breakpoints in MPLAB X

To start a debug session:

  • Press F5, or

  • Click the Run and Debug icon on the VS Code activity bar

Users will be prompted to choose which debugger and target tool to use to run the code. Afterwards, the debug functions (e.g., Continue, Step Over/Into/Out, Restart, and Stop) will appear within the VS Code window.

Users can add breakpoints by clicking on a line of code and access other debug functions by right-clicking in the Editor window.

Figure 1-25. Debugging in MPLAB Tools for VS Code

Users can also program and debug from the MPLAB Tools view and command palette. Program the target tool with:

  • The Program icon on the selected toolkit, or

  • Typing >MPLAB Program in the command palette

Initiate the debug session by:

  • Typing >Debug: Start Debugging, or

  • The Start debugging icon on project configuration

To run the program on a connected device, use either:

  • The Production menu,

  • The Run icon from the toolbar, or

  • Right-click a project and select the Run option

Figure 1-26. Program/Run in MPLAB X IDE
Figure 1-27. Program/Run in MPLAB Tools for VS Code

Another option is to click the drop-down arrow beside the Debug icon in the editor window and select any of the Debug or Run options.

Figure 1-28. Debug and Run From MPLAB Tools for VS Code Editor

Refer to this video for a quick tutorial in VS Code: Configuring and Running a Debug Session in Microsoft® VS Code®.