How to program the PIC microcontroller in my projects

Quite a few of my electronics projects use an 8-bit Microchip PIC microcontroller. To avoid repeating the programming instructions and to get less questions about the subject, I collected the necessary information to this page to help hobby builders not so familiar with PICs.


All PIC microcontrollers used in my projects are in-system programmable. This means that the firmware can be programmed or updated without removing the microcontroller from the circuit. For this purpose, there is a connector on the PCB to connect a programmer to ICSP pins of the microcontroller.


Some of my projects use a bootloader. A bootloader is a small program in the microcontoller which allows to program or update the main application to the microcontroller without a programmer. Usually the updated firmware is transferred to the microcontroller via some interface that the main application is already using. For example the JAKADAPTER uses USB bootloader, which allows to update the firmware via USB. In this case a software is needed which uploads the new firmware to the microcontroller. If you are building a project which uses bootloader, you will anyway need a programmer to program the bootloader to the PIC for the first time.


Currently the official tools from Microchip suitable for hobbyists are PICkit3 and ICD3. The PICkit3 is cheaper, around 40€. The ICD3 is about four times the price of PICkit3. It is faster and has better debugging features, but just to program the microcontroller when building a project, PICkit3 is more than enough. To use these tools, you have to install the IPE (Integrated Programming Environment) from the massive Microchip X-IDE development package. The X-IDE software is free, but not very user friendly.

For PICkit3, there was also a small and easy-to-use standalone software, but it was discontinued on 2013. You can still get it from here. As the last software release was in 2013, it doesn't support newer devices. Or does it? Well, actually it does, if the device file is updated. Thankfully, Microchip has released the source code for the standalone programmer software. Based on this information, dougy83 has created a device file editor which allows to add support to new devices, if you know what you are doing. There are a lot of device files floating around which have support to new parts. However I found none which properly supported all parts which I have used. So I took this file from GBert's github repository, and used the device file editor to fix PIC18F24K50 (it had wrong device ID and wrong program memory write script) and moved the PIC16(L)F1788/9 devices from '1.8V Min' family to '1.8V Min II' family (so they have correct device ID mask). It seems that the '1.8V Min II' family revision script doesn't work correctly for the PIC16(L)F1788/9, the revision number is shifted one bit left and two highest bits are set to 1. But this doesn't affect programming of the chips. The fixed device file is available below:
Just unzip the file and replace the original in the directory where you installed the PICkit standalone software. The device file has support for 744 devices, see here for list. I have tested and verified that this device file works for at least PIC16F690, PIC16F727, PIC16F866, PIC16F1459, PIC16F1788, PIC16F1789, PIC16LF1937, PIC16F1938, PIC18F14K50, PIC18F24K50, PIC18F45K50 and PIC18F26K22.

An even cheaper option for programmer is the old PICkit2. It is now discontinued, but there are cheap clones available in eBay. The last official software version was released in 2009 (available here). It uses the same device file as PICkit3 and with my fixed device file above, it can program all the controllers used in my projects.

Programming cable

On some of my projects there is a 5-pin or 6-pin header on the PCB, where a PICkit2/3 can be connected directly. In case of 5-pin header, just match pin 1 (indicated by a triangle on board and PICkit). Pin 6 is usually not needed, so leaving that out saves some PCB area.

On some of my projects there is just a footprint on the PCB with 6 small pads and three small holes. In this case you don't need any connector on the board, but you need a Tag-Connect cable instead. A suitable cable for ICD3 is TC2030-MCP-NL. For PICkit2/3 the suitable cable is TC2030-PKT-NL. The -NL in the code specifies a 'no-legs' version of the cable. If it is not available, you can also get the 'legged' version of the cable and just break the legs by bending them with finger. The Tag-Connect cables are very handy but also very expensive, so in future projects I'm going to include both the Tag-Connect footprint and the 5-pin header footprint if there is room on PCB.

There is still one more option: Using a ZIF socket programming adapter. This is especially useful if you are building the JAKADAPTER through-hole version board and don't have the Tag-Connect cable. You can program the bootloader to PIC18F24K50 with PICkit2/3 and a ZIF adapter before soldering the PIC to the board. The ZIF adapters are available for less than 2 € in eBay.

Powering during programming

The PIC of course needs power when it is being programmed. It can be powered from external supply or from the programmer itself. When using the PICkit standalone software, it automatically detects if there is external supply connected and if not, power is supplied from PICkit. With the IPE software the power from programmer must be separately enabled from the advanced options menu.

page created 11.2.2017
last updated 13.2.2017