chipKIT® Development Platform

Inspired by Arduino™

Last edit: 2021-03-23 00:32 by Majenko

MPLABX Importer

  1. Requirements

  2. Installation

    1. Install MPLAB® X (v3.60 or later)

    2. Install chipKIT® Importer Plugin

      1. Locate the Plugin Menu

      2. Find and Install chipKIT Importer

    3. Install MPLAB® XC32 C/C++ compiler (v1.43 or later)

    4. Install Arduino IDE (v1.81 or later)

    5. Install chipKIT-core (v1.40 or later)

  3. Importing Blink.io

    1. Create a Copy of Blink.io

    2. Launch the chipKIT Importer

    3. Configure the chipKIT Importer Wizard

    4. Select a Programmer Tool

    5. Finish Importing

  4. Programming and Debugging Hardware

    1. PIC32MX2 Boards

      1. Default Mode

        1. Compiling for Default Mode

        2. Uploading using pic32prog.exe in Default Mode

      2. Debug Mode

      3. Make and Program Device

      4. Debug Project

    2. All Other Boards

      1. Make and Program Device

      2. Debug Project

Requirements

Installation

The chipKIT Importer pluging for MPLAB® X is installed as a 3rd party plugin through the MPLAB® X IDE. Therefore, you'll need to install MPLAB® X version 3.60 or later to get started. Before you can import an Arduino sketch into MPLAB® X you'll also need to install the MPLAB® XC32 Compiler and the Arduino IDE with chipKIT-core installed. As you'll see later, the chipKIT Importer will ask for the installation directories of the Arduino IDE and chipKIT-Core because it uses files from these programs, so be sure to know where those are installed.


Install MPLAB® X (v3.60 or later)

Dowload MPLAB® X from Microchip and install.

Install chipKIT® Importer Plugin

Locate the Plugin Menu

In MPLAB® X click on the Plugin menu to launch the Plugin Manager.

 Locate the Plugin Menu

Find and Install chipKIT Importer

Click on the Available Plugins tab in the Plugins manager. Then in the search box type chipKIT to filter for the chipKIT Importer. Click the checkbox next to the chipKIT Importer plugin and then click Install. Follow the on screen installation dialog to complete the installation.

 Search for the chipKIT Importer plugin from within the MPLAB X plugin manager


Install MPLAB® XC32 C/C++ compiler (v1.43 or later)

Download MPLAB® XC32 C/C++ compiler from Microchip and install. The free version of the compiler will work.


Install Arduino IDE (v1.81 or later)

Download Arduino IDE from Arduino.cc and install.


Install chipKIT-core (v1.40 or later)

Follow the How-To Install chipKIT Core tutorial


Importing Blink.io

Create a Copy of Blink.io

The example Blink.io is typically in a read only directory and therefore you should save a copy in a read/write directory to make it your own. To do this start the Arduino IDE and navigate to File->Examples-> 01. Basics -> Blink. Then from the File menu click Save As. Take note of the directory you save to as you will need to navigate to it from the chipKIT Importer wizard.

Launch the chipKIT Importer

From within the MPLAB® X IDE navigate to File->Import->Import chipKIT Project. This will launch the import wizard as shown below.

 chipKIT Importer Wizard

Configure the chipKIT Importer Wizard

The following information is required for the chipKIT Importer to function properly

  • Source Project Location : The location of the Arduino sketch being imported. I.E. Blink.io.

  • Target Project Location : The location where the imported files will be saved. This will become the location of the MPLAB X project files.

  • Arduino Location : The location where the Arduino IDE is installed.

  • chipKIT Core Location : The location where chipKIT-core was installed. On Windows this is typically in C:\Users\myuser\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\1.4.1 where myuser is your username and 1.4.1 would be the latest version of the chipKIT-core

  • Target Board : The chipKIT Board variant for which you intend to load the compiled the code.

  • Project Directory : This field is automatically generated and is the same as the Target Project Location.

  • Encoding : Leave this as ISO-8859-1 unless you have a good reason to change it.

  • Copy All chipKIT Dependecies : Leaving this box checked will create a stand-alone project that is logically separate from the chipKIT/Arduino environment. Unchecking the box means that all source files and libraries will remain in the chipKIT/Arduino environment.

Select a Programmer Tool

For debugging within MPLAB® X you'll need a compatible programmer / debugger tool. The chipKIT PGM tool is an inexpensive tool that will get the job done. However, you can also use the PICKit 3 or ICD3 debuggers. You'll need to have your tool plugged in to select it from the list. Once you have selected your desired tool click next to finish importing.

 Select the appropriate programming tool. PGM Shown Here.

Finish Importing

Read this as it's an important warning about blowing away your bootloader in order to gain the debugging feature. Default mode allows you to keep your bootloader in tact if you don't require debugging. Debug mode requires you to use a programmer such as the chipKIT PGM, PICKit 3, or ICD3. Using debug mode will require you to reprogram your bootloader if you decide later that you wish to return to programming the device through the default mode or the Arduino IDE. These modes will be explained in more detain in subsequent sections of this page.

 chipKIT Importer Complete Dialog with Important Messages.

Programming and Debugging Hardware

For programming boards it's important to known that options will vary depending on what boards you are using. For boards which use the PICMX2 Family of processors and that use the built in USB of those processors two modes will be available, Default Mode and Debug Mode. Refer to the list of Boards for a details on which boards use the MX2 Family processor. These include chipKIT Lenny, Fubarino Mini, UltraNano, chipKIT DP32, chipKIT PI, and chipKIT CMOD

For all other boards only the Default Mode is available.

PIC32MX2 Boards

Default Mode behaves a little different depending on the board type you are using. If you are using the PICMX2 based boards which uses the processors USB peripheral, then the main feature of this mode is the ability to use the MPLAB X IDE in the same manor as you would use the Arduino IDE. In other words it's possible to make code changes, click Build, and then click the CK icon in the tool bar to download to the selected COM port. The COM port selected would be the same port you would select if you were using the Arduino IDE. No programmer tool is necessary because code is loaded using the default bootloader.

Default Mode

Compiling for Default Mode

Prior to clicking the cK icon in the toolbar to upload a hex file to a chipKIT board, the program needs to be compiled using the Build Project (F11) tool in MPLAB X as shown below.

 Click Build before programming

Uploading using pic32prog.exe in Default Mode

To upload a hex file to a chipKIT board you may first need to put your board into bootloader mode. This is typically done by pressing one or more buttons on the chipKIT board. Once in bootloader mode you can select the appropriate port from the drop down menu next to the cK icon in the toolbar as shown in the image below. When you click the cK icon the pic32prog.exe tool, which is included with chipKit-core, is used to upload the hex file. Failing hit the Build button after a code change will result in you loading the same hex file as before.

 COM Select and cK Icon in MPLAB X


Debug Mode

With the MPLAB X build configuration mode set to Debug you have two options of uploading and building code.

Make and Program Device

If you click Make and Program Device, then a HEX file will be built which not only includes the normal sketch, but also includes the default bootloader HEX file. So when the programmer programs the board, the normal USB bootloader will be written to Flash as well as the sketch.

Make and Program Device

Debug Project

If you click Debug Project, then the sketch is built and combined with a super simple jump instruction (from the linker script) instead of a bootloader. We had to do this so that the Debug Executive (a piece of code added by MPLAB X to your image if you want to do hardware debugging) would have a proper place to live (in the same space as our USB bootloader, unfortunately). So by leaving our USB bootloader out of the image, and just putting a jump instruction in, we can allow the hardware debugging of our sketch.

 Debug Project and Step Through Buttons


All Other Boards

When using boards which do not have the PICMX2 processor, only the Default Mode is available in MPLAB X. It requires that you use a hardware debugger such as the chipKIT PGM, PICKit 3, or ICD3 to both program and debug. To be clear, these boards still have the ability to run in a release (non-debug) mode and debug mode. It simply works a little differently than those boards with the PICMX2 processors.

To build and program a device for deployment you'll use the Make and Program Device button shown below. To program in debug mode you'll use the Debug Project button also shown below.

Make and Program Device

This button will compile your code and upload it for deployment.

 Make and Program Device Button

Debug Project

This button compiles code for debugging which allows you to set breakpoints, step through lines, and view memory at runtime.

 Debug Project

Use these buttons for controlling code stepping.

 Buttons for Stepping Thru Code