MPLABX: Programming .HEX files

8

Long time ago I had a PICkit 2 programmer, which came with a nice little application that allowed for .hex files to be programmed without the need of MPLAB, and also worked as a logic analyzer. Then, I switched to PICkit 3 as the new range of Microchip microcontrollers was no longer supported by the PICkit 2. All went fine, but I missed the ability to program hex files, which is especially handy when burning bootloaders, or when I have to program existing compiled code.

This blog post is more than two years old.

Now, with the MPLABX we have again the possibility to program hex files directly, without the need of recompiling the code.

For this tutorial I will use an Explorer16 board, equipped with a PIC32MX360F512L PIM[1], on which I will program the ChipKit bootloader[2]. I first downloaded the pic32-Arduino-Bootloader-master.zip file, then extracted its contents on my hard drive (drive F in this tutorial). The bootloader for Explorer 16 is in this case in the folder F:pic32-Arduino-Bootloader-masterdistmicrochip-pic32-explorer-16-360f512lproduction and is named arduino-booloader.X.production.hex.

  Once we have located the file to be programmed, we open MPLABX. Then, we go to File –> New Project. In the new dialog window we make the following choices: Categories is set to “Microchip Embedded”, and Projects is set to “Prebuilt (Hex, Loadable Image) Project. Then, click on Next.

MPLABX new project window

In the next dialog we first choose the name of the prebuilt file. I browse to the “F:pic32-Arduino-Bootloader-masterdistmicrochip-pic32-explorer-16-360f512lproduction” folder and I select the “arduino-booloader.X.production.hex” file.

Then, I select the microcontroller corresponding to the installed PIM. So, from the Families drop down list I select “32-bit MCUs (PIC32)”, and for the Device I choose “PIC32MX360F512L”. Next, I select the PICkit 3 programmer from the Hardware tool list by clicking on the serial number of the programmer. Then, click next.

The next window shows the project summary. I like too keep things in order and to place the project field in the same folder where the hex file is. I looks that MPLABX thinks the same, so I don’t change anything. Notice the warning related to the long path. I just ignored it and pressed Finish, but you may wish to change it to a shorter path if things go wrong.

Final settings for the bootloader project

After clicking on Finish, MPLABX moves us on the default view. In the top corner we have the projects windows, and by clicking on the “Prebuilt files” we should see the name of our bootloader hex file.The Output window should display “Loading code from F:pic32-Arduino-Bootloader-masterdistmicrochip-pic32-explorer-16-360f512lproductionarduino-booloader.X.production.hex… Loading completed”

MPLABX main window

MPLABX main window

I will use the PICkit 3 to provide the power to the Explorer16 board. Remember that PICkit 3 can provide power to the target circuit, with a voltage between 1.8 and 5V, but with a current limit of 30mA. I right-click on the project name (text in bold), and from the lowest line of the drop-down list I select “Properties.” In the new window, in the Categories I click on “PICkit 3”, and from the Option categories drop-down list I go to “Power”. I check the Power target circuit from PICkit 3 tick mark, leaving the voltage at 3.25V. I click on Apply then OK to close the Properties window.

Powering the target device from PICkit3 in MPLABX

The last step is to program the microcontroller by going in the top bar to Run –> Run main project.

Top bar Run --> Run Main Project

If everything is OK the output window will show something like this:

*****************************************************
Connecting to MPLAB PICkit 3…
Firmware Suite Version…..01.30.09
Firmware type…………..PIC32MX

Target detected
Device ID Revision = B4 B6

The following memory area(s) will be programmed:
boot config memory
configuration memory

Programming…
Programming/Verify complete

The D5 LED on the explorer board will blink to indicate the bootloader is waiting.

  … That is all …


 

[Update 27 March 2015] Well hidden in the MPLABX download page there’s a section named PICkit Archives. There you can find a download link for a PICkit3 standalone application. It works just as badly as the rest of the Microchip software, but still easier to use than the MPLAXB procedure described above.

PICkit3 standalone application

PICkit3 standalone application


 

[1] I found that the same bootloader hex file works great also with the PIC32MX460F512L PIM

[2] ChipKit bootloaders for Explorer 16 can be downloaded from https://github.com/chipKIT32/pic32-Arduino-Bootloader

[3] Download page for the standalone application is http://www.microchip.com/pagehandler/en-us/family/mplabx/

Share.

8 Comments

  1. Avatar

    Hi
    I need a help
    I have a customized board with pic32mx360f512, (not a explorer16)
    Can I put the arduino bootloader for that?
    I must use Mplabx with pickit3 for burn it or can I use Arduino IDE?
    And, What board I will choose in the arduino IDE? (the max32?)

    Thank you

  2. Avatar

    Hi again,

    i did exactly the same and get sucess with Mplax and Pickit

    But in the Arduino IDE: No target found.

    I dont know what board to choose

    Could you help?

Leave A Reply