How to Use “MikroC PRO for PIC” to Program PIC Microcontrollers

How to Use “MikroC PRO for PIC” to Program PIC Microcontrollers

PIC microcontrollers are a very useful and versatile tool for use in many electronic projects. They are very inexpensive and easy to find. They are also very powerful and many are capable of speeds up to 64 MIPS using the internal oscillator block, about 16 times faster than most comparable AVR microcontrollers. PICs are also easy to program, however getting the project set up can some times be tricky. These instructions will walk through the process of setting up the software, creating a new project, and programming some very simple functions to test the configuration and ensure everything is working. They are designed to be very open ended; after the project is created and the basics are finished the reader is encouraged to explore all the features and extras not covered in these instructions. Also you will find that these instructions will start out walking through step by step, but as the instructions near the end the reader is encouraged to explore other ways of accomplishing the tasks and make the project their own.
What you will need To build a project with a PIC microcontroller only requires a few items.

  • PIC microcontroller
    • These instructions are for programming a PIC18F series MCU, although others are similar.
    • Obtained from Microchips website.
    • Microchip allows students with valid .edu email addresses sample PIC’s for free!
    • The PIC I am using to create these instructions is a PIC18F22K80
  • PICkit 3 In-Circuit Debugger
    • Available from Microchip.
    • Costs $45 for general public, and #34 with student discount if you have an .edu email address.
    • There are also other programmers which will work just as well; however, this is the best one for starting out.
  • Breadboard and breadboard wires
  • LEDs, buttons, potentiometers, or anything else you would like to connect to the PIC

Step 1: Build Hardware

Build Hardware

Before doing any programming the first step is to build the hardware. Although the PIC18F portfolio is very large, many of the chips have several commonalities. For more detailed information see the “Guidelines for Getting Started with PIC18Fxxxx Microcontrollers” section in your devices datasheet. For detailed pin-outs of the PIC microcontroller see the “Pin Diagram” section in your devices datasheet.
Note: VDD = Positive Voltage and VSS = Ground.

  1. Connect the MCLR pin through a 1kΩ resistor to VDD.
  2. Connect a 0.1μF capacitor between every pair of adjoining VDD-VSS pairs or AVDD-AVSS pairs.
  3. Connect a 10μF capacitor between VCAP and Vss.
  4. Connect MCLR pin to pin 1 of the PICkit 3.
  5. Connect VDD to pin 2 of the PICkit 3.
  6. Connect VSS to pin 3 of the PICkit 3.
  7. Connect PGD pin to pin 4 of the PICkit 3.
  8. Connect PGC pin to pin 5 of the PICkit 3.
  9. Leave pin 6 of the PICkit 3 unconnected.
  10. Connect any analog inputs to pins with ANx functionality where x is a number.
  11. Connect any digital inputs or outputs to pins with Rxy functionality where x is a letter identifying the port, and y is a number identifying the bit.

For my example I have an LED connected between RA0 and ground, the wiper of a potentiometer connected to AN1, and a DPST switch connected to RA2. You may find it easier to program the PIC if you have sketched down a schematic of your circuit.

Step 2: Get Software

Get Software

These instructions will use XC8 compiler and MPLAB X IDE by Microchip. This step will explain how to get these tools and ensure they have been installed correctly.

  1. To get the latest version of the software visit Microchips website at
  2. Select the software for your OS and follow the standard installation instructions.

Note: If you are using Windows 8 you may need to run the installers in compatibility mode for Windows 7.

  1. Once the software is installed, start MPLAB X
  2. In the menu bar select Tools->Options
  3. In the Options dialog select the Embedded tab and ensure XC8 is listed in the Toolchain list.
  4. If it is listed select OK and move on the next step.
  5. If it is not listed ensure that instillation has completed, and click Scan for Build Tools button.
  6. If still not listed, look on Microchips forum for help with your specific problem.

Source: How to Use “MikroC PRO for PIC” to Program PIC Microcontrollers

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.