MPIDE: no bootloader, no problem


Back to the Arduino-compatible IDE for PIC32 microcontrollers MPIDE. In this post I will show how to program the code written in MPIDE on any PIC32, without the need of a bootloader.

This blog post is more than two years old.

Typically Arduino IDE, and all similar clones, create a temporary folder in C:Users<Username>AppDataLocalTemp. For any new project a new temporary folder is created. The trick in this post is to instruct MPIDE to put the compiled .hex files in a folder specified by the user, then use the “Auto Import Hex + Write device” function in PICkit 3 standalone application to program the chosen PIC32 microcontroller. .

Here’s how to do it:

Supposing you want to put the compiled hex files into E:mpide-0023-windows-20140821compiled, browse to the MPIDE installation folder, then create a folder named “compiled”. Then go back and browse to the lib folder (something like this: E:mpide-0023-windows-20140821lib).

Locate the file named preferences.txt. It’s a good idea to create a backup of this, as it will save you the hassle to reinstall MPIDE if you screw things up. Then, edit the preferences.txt. Add the line “build.path=E:mpide-0023-windows-20140821compiled” at the end of the file. Next time you start MPIDE, it will put the compiled hex files in that folder. In the preferences file you should have something like this:

# temporary build path, normally this goes into the default
# “temp” folder for that platform (as defined by java)
# but this can be used to set a specific file in case of problems

It’s a good idea to set also export.delete_target_folder = false so the hex file is kept even after closing MPIDE.

When working with MPIDE select a board that has the same PIC32 as you are wish to program. For this example I selected a Microchip PIC32 Starter kit. The blink LED example resulted in the following output:

MPIDE output

MPIDE output in a specific folder

To program the PIC32 starter kit I used a PICkit3 with PIC32 firmware, using the standalone application. A DM320002 extension board was used for easy access to the ICD programming pins of the PIC32.

Now all I have to do is to start the PICkit 3 standalone app, select the correct microcontroller from the list, then go to the E:mpide-0023-windows-20140821compiled folder. Here I use the “Auto Import Hex + Write device” function and I select the Blink.cpp.hex file. From this moment the PICkit3 software continuously monitors that hex file, and whenever I modify the source code and recompile it, it will be automatically programmed in the PIC microcontroller.

Help! I bricked my PICkit 3

The range of PIC32 microcontrollers supported by the PICkit 3 standalone app is not so great. One might use MPLABX IPE (Integrated programming Environment) which supports the whole range of PIC microcontrollers. But if you do this, when you will start the PICkit 3 standalone app again you will have a nasty surprise: “Unhandled exception has occurred in your application.  If you click Continue, the application will ignore this error and attempt to continue. If you click Quit. the application will close immediately.  Data parameter cannot be longer than 136 bytes. Parameter name: Data.

PICkit 3 error

PICkit3 error in the standalone app, after using it with MPLABX IPE

To me it looks that MPLABX IPE updates the PICkit 3 firmware to version 01.36.10, while the standalone app uses firmware version 01.26.33. My workaround is to use MPLABX to manually downgrade the PICkit3 to the firmware version required by the standalone application. Here’s how to do it:

In MPLABX IPE, first select a microcontroller that is supported by PICkit 3 standalone application. Then, in the Settings menu, disable “Auto download firmware”. Go to “Manual Download Firmware” and browse to the folder where the standalone app is installed. Select PK3FW_012633.jam file, then OK.

PICkit3 firmware update

Using MPLABX to downgrade the PICkit3 firmware.

In the end you should see somemesage like:

Now Downloading new Firmware for target device: PIC18F4520
Downloading bootloader
Bootloader download complete
Programming download…
Downloading RS…
RS download complete
Programming download…
Downloading AP…
AP download complete
Programming download…

Currently loaded firmware on PICkit 3
Firmware Suite Version…..01.26.33 *
Firmware type…………..PIC18F

Target device was not found (could not detect target voltage VDD). You must connect to a target device to use PICkit 3.

If the PICkit 3 is completely bricked and is not recognized by MPLABX IPE or by PICkit 3 standalone application, the only way to restore it is to open it to access the internal ICSP pins, and use another programmer to reload the firmware. Two excellent tutorials on how to do this are here and here.



    • Teodor


      It only applies to selected PIC32 microcontrollers. On the other hand, now ChipKit core is available directly in Arduino IDE, so this blog post has become quite obsolete.

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.