Project Scripts in MPLAB® X IDE

Last modified by Microchip on 2024/06/24 06:34

MPLAB® X IDE provides scripting capabilities to control the IDE behavior programmatically. 32-bit SAM microprocessor (MPU) projects in particular need to use scripts to support bootstrapping. However, scripts can be used with MCU projects as well.

About the Scripts

The scripts are written in Jython. The scripts have access to an API that allows you to:

  • Control the debugging session state (run, halt, etc.)
  • Access memory in the device while debugging.
  • Set breakpoints with callbacks to functions that determine if a halt should happen or not. This allows implementation of conditional breakpoints.
  • Place actions in the Projects window which, when clicked, will run methods in a script.
  • Provide hooks for debug events: a function will be called when a given event happens.

Adding Scripts to a Project

If you create a project for a 32-bit SAM MPU, the project wizard will add a “Script Files” folder to your project and a default file in that folder.

If you have an existing project to which you would like to add scripting features, follow the steps:

  1. Close the project in MPLAB X IDE.
  2. Create a file named or use the self-documenting example that explains the APIs. Find the example file in:
    <MPLAB X IDE Install folder>\docs
  3. Copy the file into your project directory. Edit the file here as necessary.
  4. Re-open the project and you will see a “Script Files” folder in the project tree. The file will be under this folder.

Using the Scripts

​Whenever you edit the file, you will have to shut down and reboot MPLAB X IDE before updates take affect.

For a 32-bit SAM MPU project, edit the file for your project, shut down and reboot MPLAB X IDE, and debug your application.

For the example project, there is also a “Tests” folder. Simply run the scripts under “Tests” as needed.

Unedited Example in Project

shows where scripts are listed in the project window

For more information on scripting, see the "IDE Scripting (" page (206) of the "MPLAB X IDE User's Guide."