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.
Dowload MPLAB® X from Microchip and install.
In MPLAB® X click on the Plugin menu to launch the Plugin Manager.
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.
Download MPLAB® XC32 C/C++ compiler from Microchip and install. The free version of the compiler will work.
Download Arduino IDE from Arduino.cc and install.
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.
From within the MPLAB® X IDE navigate to File->Import->Import chipKIT Project. This will launch the import wizard as shown below.
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.
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.
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.
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.
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.
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.
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.
With the MPLAB X build configuration mode set to Debug you have two options of uploading and building code.
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.
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.
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.
This button will compile your code and upload it for deployment.
This button compiles code for debugging which allows you to set breakpoints, step through lines, and view memory at runtime.
Use these buttons for controlling code stepping.