Frequently Asked Questions
How can I use my HEX files with MPLAB® tools to program my target?
MPLAB® is the IDE Microchip provides and provides programming support for all Microchip tools (PICSTART Plus, Promate, ICD2, etc). This provides a simple guide on how to import the HEX file into MPLAB® so it can be programmed into your target. For more MPLAB® documentation, please refer to Microchip's documentation.
First, be sure that your HEX file will run stand-alone (doesn't need a debugger). Click here for pointers on creating a stand-alone HEX file.
Follow these steps:
- Start MPLAB®. All steps in this FAQ that refer to a toolbar means the toolbar of MPLAB®.
- Make sure no other project/workspace is open by selecting File -> Close Workspace from the toolbar.
- Select your target device by selecting Configure -> Select Device. This will bring-up a dialog where you select your target PIC®MCU(PIC16F877A, PIC18F4520, etc). It also will tell you if your programming tool is supported for this device.
- Open the Configuration Bits dialog by selecting Configure -> Configuration Bits from the toolbar. This will open a new dialog window, at the very top of this window you will see a checkbox labeled 'Configuration bits set in code', make sure this checkbox is SET. Failure to do this will cause invalid configuration bits to be written to the device.
- Select your programming tool by selecting the Programmer item from the toolbar. This will give you a list of selectable programmers.
- Import your HEX file by selecting File -> Import from the toolbar. This will load the HEX file into memory. Importing the hex BEFORE you selected programmer or selected target device will cause the HEX file to be cleared from memory, so it is important to do it in the order shown here.
- Program your device. This is done via the Programmer item from the toolbar. This process is different for each programming tool. But for the ICD2, you first need to connect to the device with Programmer -> Connect Device, and the program the device with Programmer -> Program
- Repeat the previous step for each target microcontroller that you wish to program with this HEX file.