The Fundamentals of Programming a PIC Microcontroller

Created: May 20, 2018
Updated: January 25, 2021

Two children programming a microcontroller

One thing I’ve learned from parenting: it can be incredibly difficult to teach a child something. While they might be very interested, and they might have all the time and resources in the world, if the child isn’t ready to learn or is missing some crucial building block, they might just not get the skill or lesson.

Thankfully, programming a PIC microcontroller unit (MCU) is considerably easier. With the right programming tools, circuit, and functional firmware, a programmer can get a PIC microcontroller to behave exactly as desired. Of course, to avoid unnecessary hassle and frustration down the line, it is still important to adhere to a few crucial steps.

The PIC Microcontroller

Despite the emergence of single-board embedded controllers like Arduino, Raspberry Pi, or BeagleBone, the PIC microcontroller still remains relevant among electronics engineers. Manufactured by Microchip, PIC microcontrollers are characterized by their ease of use, versatile features, and cost-effectiveness. PIC microcontroller programming ranges from simple 8-bit MUC to powerful 32-bit models.

The versatility of PIC microcontrollers made it popular not only amongst engineers but hobbyists as well. The broad range of peripherals, memory, and processing power provides a right fit for almost any application. The programmer will probably find a PIC microcontroller in their washing machine or alarm system.

Tools A Programmer Needs To Program A Microcontroller

Programming a PIC microcontroller today is significantly easier than it was a decade ago. Back then, some of the lower range of PIC microcontrollers required a dedicated PIC programmer hardware to inject the firmware in. But if you’re starting with a PIC microcontroller today, downloading a firmware into the microcontroller is usually a simple process.

These are the tools a programmer would need to program a PIC micro today:


The MPLAB X IDE is a comprehensive development environment from Microchip. You’ll need the MPLAB X to write your firmware, compile and build it before you can program the PIC microcontroller. Unlike expensive IDE that you need to pay for in the past, the MPLAB X IDE is free for download.

Web developer in front of code on computer

The first step is getting your firmware right.


The PICKIT 4 is the latest in-circuit debugger from Microchip PIC that allows the programmer to efficiently download the program to the microcontroller. It is an improved version of its predecessor PICKIT 3 with the added feature of an SD Card slot, which facilitates programming on-the-go for various firmware. When programming the PIC microcontroller in the lab, you’ll need to connect the PICKIT 4 between the USB port of your computer and the programming pin of the microcontroller.

3. Programming Circuit

The programming pins for PIC microcontrollers are indicated in the datasheet. PIC microcontrollers support either In-Circuit Serial Programming (ICSP) or In-Circuit Debugging (ICD), with the latter allowing engineers to debug the firmware in real time. It is important to include the circuitry for the programming (ICSP or ICD) interface in the design for the PICKIT 4 or PICKIT 3 to connect to.

Programming the Microcontroller

With all the programming tools ready (regardless of ICSP or ICD) and the prototype assembled, programming the microcontroller is almost intuitive. Traditional programming tools require the programmer to power up the hardware before any firmware downloads. But the PICKIT programmers can be configured to power up the microcontroller as long as it doesn’t exceed its maximum current limit.

There are two ways to get the firmware into the PIC microcontroller. In the MPLAB X IDE, the programmer will find the options to ‘Run Project’ or ‘Debug Project’ and clicking ‘Run Project’ compiles and builds your firmware in production mode while the latter creates a debug version of the firmware footprint. You’ll want to take time to ensure that the final product is programmed with the production version of the firmware.

microcontroller with pins placed

Done correctly, your microcontroller will start running after the program is loaded.

Tips for Designing the Programming Circuit on a PCB

The programming pins arrangement on PICKIT 3 and PICKIT 4 are similar although PICKIT 4 has two additional reserved pin connections. The firmware is transferred through the PGD and PGC signal with a /MCLR pin to drive the microcontroller into programming mode.

The programmer will want to route both the PGD and PGC in parallel and maintain the same length to ensure minimal signal corruption. Besides that, proper labeling on the orientation of the programming pins on the PCB is needed, as it’s easy to mistakenly plug in the PICKIT in reverse, risking damage to both the PCB and PICKIT alike.

Using a great PCB design software like Altium Designer® helps you greatly in designing interference-free programming circuits for PIC microcontrollers.

Need more advice on programming a PIC microcontroller? Talk to an expert at Altium Designer.

Recent Articles

Back to Home