PIC Microcontroller Primer – Tutorial #2

PIC2 - 1

As promised, this part starts with a simple programming tutorial on the PIC12F675 microcontroller which shows you how to program and use it as a simple LED flasher. It’s assumed that you have successfully constructed your own PIC mini development board, and you have a PIC usb programmer (PIC Kit 2) in your hand. Well, then get ready to prepare your little hardware for this minor experiment, as instructed below.

Hardware Wiring

As you can see the hardware is very simple and only requires a 5mm Red LED and a 1K resistor, in addition to the PIC mini development board. The LED is connected between GPIO 2 (pin 5) of the PIC 12F675 microcontroller and the ground (0V) rail through the 1K current limiting resistor.

PIC hardware wiring

Software Code

For the sake of simplicity, a ‘ready-to-use’ hex code is used here. Just download the hex file (Hello_LED.Hex) from the indicated link, and burn it into the PIC12F675 microcontroller with the help of your PIC Kit 2 programmer. Note that, this is only a simple approach to test the PIC12F675 microcontroller of your mini development board. From the next part, you can learn how to program PIC microcontrollers using your own codes!

PIC Kit 2 Microcontroller Programmer Guide

Inorder to get the best from your PIC Kit 2 Microcontroller Programmer, it is recommended to download the PIC Kit 2 user guide from This user’s guide describes how to use PIC Kit 2 Microcontroller Programmer. Other useful notes are also included in this detailed official documentation.
The PIC KIt 2 Microcontroller Programmer can program PIC microcontrollers that are installed in an application circuit using In-Circuit Serial Programming (ICSP). In-Circuit Serial Programming (ICSP) requires five signals:

  • VPP/MCLR – Programming Voltage (when applied, the device goes into programming mode)
  • PGC or ICSPCLK – Programming Clock (a unidirectional synchronous serial clock line from the programmer to the target)
  • PGD or ICSPDAT – Programming Data (a bidirectional synchronous serial data line)
  • VDD – Power Supply (positive voltage)
  • VSS – Power Supply (ground reference)

When you are familiar with your PIC Kit 2 microcontroller programmer, interconnect the mini development board (MDB) with PIC Kit 2 as shown below. Since, you can safely power the mini development board (at this time) by the PICkit™ 2 Microcontroller Programmer itself, remember to switch off the mini development board’s power supply during ICSP programming!

pickit 2 connector

MDB and PIC Kit 2 pin connection

After this ICSP wiring, connect the PIC Kit 2 programmer to your PC and open the PICKit2 Software. After Opening the PICKit2 Programmer Tool, click Erase, and after Erasing Import the downloaded Hex file from the stored location (File → Import).

pic programmer tool

After Importing the Hex File, write the program to PIC by clicking the Write button. After programming, you may verify the program in the PIC Microcontroller with the Hex file using the Verify button. This can used to check whether the program in the microcontroller is corrupted or not. Now remove the ICSP wiring, and power the mini development board from its own power supply. If everything is okay, you can see that the LED is flashing continuously with about 4Hz frequency at 50% duty cycle.

Yes, now you are sure that your PIC12F675 (in your MDB) is functioning well, and your PIC Kit 2 microcontroller programmer can successfully burn hex files from your computer to the microcontroller chip. Certainly, not a bad evening!

→ Part 3
← Part 1