Category: PIC MicroController


PIC 12F675 is 8 bit , 8 pin mini and powerful Microcontroller.

It has 1k Bytes of ROM Flash memory , 64 Bytes of RAM ,  128  Bytes of EEPROM , 4 channels of 10 bit ADC , 2 TIMERS one 8 bit and another 16 bit.A comparator and inbuilt oscillator also are provided.

This chip can be programmed using PICKIT3.

IDE used is MPLAB X and compiler is XC 8.

Connection details as below in image.

An LED is connected to pin 3 (GP4) .Short lead of LED is connected to Gnd through a Resistor 470E.


MPLAB X IDE is the IDE used here for development.Compiler installed is XC8

Image 2

Open MPLABX IDE , File  –> New Project

Select  Standalone Project

Image 3

Under Device select PIC12F675

Against TOOL , tick mark Show All and select PICKIT3 from the dropdown list.

Image 4

Next is the selection of Compiler.

Select XC8 .

If not listed , check the installation of XC8 compiler.

Image 5

Provide a Project name and browse to the location of folder created for project location.

Image 6

Now the project files are created.

Right click on SOURCE FILES and click on New –> main.c

If you want rename the file , leave the extension as .c

Click Next to add the .c file to Source files.

Image 7

Click on .c file to see the skeleton C file.

#include <xc.h>

header file for Compiler is added automatically.

We need to set the configuration bits in the code using

#pragma config

Image 17

Settings like Internal oscillator , Watch Dog OFF , Brownout detect OFF can be

used with a comma separator in a single command line.

Image 16

You can also verify correct settings by clicking on Production –> Set Configuration Bits

Image 9

A new Window opens at the bottom.

Here you can do the needed settings and finally click on Generate code.

You can copy and paste the pragma settings inside the C code.

Or to make it simple make a single command line with comma separator.

As we cannot spare 2 GPIO pins for external crystal oscillator , most of the projects are configured for internal oscillator of 4 MHz.

This is set by

# pragma config FOSC=INTRCIO

Image 10

Next we need to define the crystal frequency

#define _XTAL_FREQ 4000000

Without this command delay function will not work.

Data Direction is set by TRISIO Register.

Making a bit 0 will make the corresponding  GPIO pin OUTPUT

and making a bit 1 will configure GPIO as INPUT.


The above notation can also be used.Here 0 is left shifted 4 times thus making GP4 as OUTPUT.

Under never ending loop we make GP4 initially 0 and after a delay of 1 second we make it 1.

Note the usage of double underscore __ before delay.

Image 11

Before building the project , an important setting to be done to make the Power to Target from PICKIT3.

Click Set Project Configuration and then Customize.

Image 20

Select PICKIT3 and then from the dropdown select POWER.

Image 13

Put a tick mark against Power Target from PICKIT3 and click Apply.

Image 14

Now click on BUILD MAIN PROJECT or F11 Button to Compile.

Image 15

When no errors are found , you can see BUILD SUCCESSFUL.

Image 18

Now click on the DOWN Arrow icon on tool bar to upload the hex file on to chip.

Image 19

Once file is uploaded , you can see the LED connected to GP4 blinking.





pic2    pic3


PICKIT3  seems to be a DEGRADED version of PICKIT2 . PIC may be a Microcontroller Giant , but a newer version of Toolkit should be more user friendly than the previous versions.In case of PIC the design Team has never bothered this.

Following are the Changes made in PICKIT3 , which many have criticized  :

1. The little useful standalone program  PICKIT2 to fuse HEX files is scrapped now.There is no standalone program to fuse HEX files.Now you need to install MPLAB IPE along with MPLAB X IDE & use that for fusing target IC with HEX file.

2. PROGRAMMER TO GO function of PICKIT2 is scrapped in PICKIT3.

This function allows a PIC MCU memory image to be downloaded into the PICKIT 2 unit for later programming into a specific PIC MCU. No software or PC is required to program devices once the PICkit 2 unit is set up for Programming-To-Go

3. TARGET is not powered automatically in PICKIT3. In PICKIT2 Automatic Power feature is enabled by default.In case of PICKIT3 you need to CONFIGURE manually , else you get TARGET NOT FOUND error.

4.PICKIT3 does not detect DEVICE automatically.You need to select the device from drop down list.

5.PICKIT3 uses PIC24 series MCU , while PICKIT2 was designed on PIC18 series.But PICKIT2 seems to be faster than PICKIT3.

6.If you change the target IC , Firmware upgrade happens every time in PICKIT3 , an annoying feature.   

As MICROCHIP has stopped production & support to PICKIT2 we’ve to live with PICKIT3.Let us now see the solutions for common problems faced in using this “ADVANCED Device”.

You can fuse the HEX file from within MPLAB X IDE or through MPLAB IPE..

MPLAB X IDE Method :

From within MPLAB IDE click the Icon with down Arrow image “Make & Program Device Main Project”.

The project is now BUILD.

Once you get BUILD SUCCESSFUL in the OUTPUT Window , the IDE will try to connect with PICKIT3 Programmer




But you get TARGET NOT FOUND error.



Click on RUN –>set project configuration –>CUSTOMIZE



On the new window select PICKIT3


Under OPTIONS CATGEGORIES drop down select POWER



Tick mark “Power Target circuit from Pickit3”

& select voltage level as 5.0



Click OK & then click on the  “Make & Program Device Main Project” again

Now the target is detected & HEX file fused on to target.


Method 2 : Through MPLAB IPE

From MPLAB IDE click RUN –> BUILD MAIN PROJECT  to create the HEX file.


The HEX file is created inside the PROJECT File –> dist –> default –> production

Note the location of HEX file.

Image 6

Now open MPLAB IPE the Integrated Programming Environment


Image 17

Select the IC , here PIC16F877A , Apply & then click on CONNECT

Image 7


You get Target Not found ERROR.

Image 8


Image 9


To enter Advanced mode you need to type in the password –     microchip

Image 1

Now a new set of buttons appear on left side.

Click on POWER button

Image 11

Select Vdd as 5.0 & then tick mark “POWER TARGET CIRCUIT FROM TOOL”

Image 12

Now click on OPERTATE button

Image 13

The target is found & connected now.

Click the browse button & navigate to select the HEX file stored.

Image 14

Click PROGRAM button to fuse the target chip with selected HEX file.

Image 15


Image 16


cooltext753793315   cooltext753790696


16 X 2 LCD is most popular in Embedded projects .16 is the number of Columns & 2 is the no. of Rows.Generally it needs 8 bits to display the data as the Data bus is of 8 bits.

In this post the LCD is used in 4 bit mode ,splitting the data Byte in Nibbles.So we can save 4 data port pins of the PIC microcontroller.

Complete datasheet of  this LCD is available here .

The Data or command is sent in nibble form (1 nibble= 4 bit) in the 4-bit mode. The higher nibble is sent first followed by the lower nibble. The function of RS, RW and EN pins remains similar to 8-bit mode.

The pin out of LCD is as follows:

1. Ground
2. VCC (+3.3 to +5V)
3. Display Contrast adjustment (VO)
4. Register Select (RS). RS=0: Command, RS=1: Data
5. Read/Write (R/W). R/W=0: Write, R/W=1: Read
6. Clock (Enable). Falling edge triggered
7,8,9,10   Bit 0 to bit3  (Not used in 4-bit operation)
11. D4 Bit 4
12. D5 Bit 5
13. D6 Bit 6
14. D7 Bit 7
15.Backlight Anode (+)
16.Backlight Cathode (-)



For interfacing LCD with microcontroller we need system-bus (data-bus, address-bus and control-bus). In our case for 4 bit mode the  data pins (D4-D7) are the ‘data and address’ bus while the 3 control pins(RS, R/W and E) are the control bus

These displays generally have a 16-wire interface, of which 11 IO lines from the PIC micro are needed. 8 of these lines are for DATA.

As we use LCD in 4 BIT Mode , only 4 lines are actually needed.

The Read/Write R/W pin is pulled to Ground making the LCD write only.

Dropping the 4 Data lines & the R/W line , we need only 6 I/O lines (4 data lines D4-D7 along with RS and Enable)  for basic operation


To start with create a Folder say inside F:\myprojects to store all our work.

Open the MPLABX IDE & click on File –> New Project

Choose Project –> Microchip Embedded –> Standalone Project  click on Next & select the Device as PIC16F877A

Select Tool as PICKIT2  & Compiler as XC8

Provide project name as LCD & project location as F:\myprojects ( we’ve created earlier).

Image 4


Click on FINISH


Image 1 

Inside FILE PANE you can see the default File folders created by the IDE.

For the XC compiler to understand the LCD hardware , a Header file is used.Download this file & store it inside the LCD.X folder. HEADER FILE DOWNLOAD HERE

Copy & paste the lcd.h header file into the LCD.X folder.

Right click on Header Files –> Add Existing Item  & browse to the location where you’ve stored the lcd.h  header file & select it.

Now lcd.h will appear under Header Files folder

Image 2


Now Right click on Source Files –> New  –>  C Main File

Provide a file name , or leave it to default name “newmain” .

Select the extension as .c from the drop down.

You can see newmain.c file created inside the LCD.X project folder.




Click on Finish to see the newmain.c file under Source Files folder .The LCD.h file is seen under Header Files folder.

Delete the generated code for now .

Image 6

Click on Window –> PIC Memory Views  –> Configuration bits & set the config bits as FOSC = HS ,WDTE =OFF ,LVP = OFF ,etc.. as seen below

Image 7


Click on “Generate Source code to output “ button seen at the bottom.



You can copy & paste  the Configuration code on to the Editor Pane.

Or you can enter the following config. code in a single line as :


#include <xc.h>

#pragma config FOSC=HS , WDTE=OFF , LVP =OFF , PERTE=OFF


As we use an external crystal of 20 MHz on demo board , we declare FOSC as HS & other settings WatchDog, Low Voltage Programming ,etc . as OFF

Below the #include <xc.h> statement define the crystal value as

#define _XTAL_FREQ 20000000

20 followed by 6 zeroes represents 20 MHz value.




Image 10

#include “lcd.h” statement indicates that the lcd.h file resides inside the project folder.Previously you should’ve downloaded this file & stored it inside the LCD.X folder.Otherwise you’ll get red error squiggles against this statement.

PORT D pins are used to connect with the LCD.

We need only 4 pins for DATA , as we use the LCD in 4 bit mode. Pins RD4 to RD7 are used for data bits D4 to D7.

RS (Register Select)  is connected to pin RD2.

When RS = 0 , D4 to D7 value is interpreted as COMMAND by the LCD.

When RS = 1 , D4 to D7 value is interpreted as DATA by the LCD.

To initialize & set the cursor location we set this RS as 0 (Command mode) & for displaying Data we set this RS to 1.

LCD enable pin is connected to RD3.

R/W READ/WRITE pin of LCD is connected to GND as we use the LCD to display DATA.

All these connections are declared using the #define preprocessor statements.



#define _XTAL_FREQ 20000000

#define RS RD2
#define EN RD3
#define D4 RD4
#define D5 RD5
#define D6 RD6
#define D7 RD7
#include <xc.h>

#include "lcd.h";

void main()
  unsigned int a;
  TRISD = 0x00;
    Lcd_Write_String("LCD Library for");
    Lcd_Write_String("MPLAB XC8");
    Lcd_Write_String("Saravana Electronics");





After feeding in the code as above ,

Click on Run –> Build Project

If all the syntax are correct you get BUILD SUCCESSFUL.

Finally click on Run –> Run Main Project or press F6 to execute the program & see result on the LCD.

Support  Video :





There are 2 types of  seven segment displays – CC (Common Cathode) & CA (Common Anode).In this post we shall see how to interface CA display with PIC 16F877A.

   The display , as the name indicates , is made up of seven segments of LED.Each one of the seven LEDs in the display is given a positional segment with one of its connection pins being brought out of the  plastic package. These  LED pins are labeled from “ a “ to “ g“ representing each individual LED. The other LED pins are connected together and wired to form a common pin.

In case of CA display +5v is tied to Common pin.

The  common pin is generally used to identify which type of 7-segment display it is. As each LED has two connecting pins, one called the “Anode” and the other called the “Cathode”, there are therefore two types of LED 7-segment display called: Common Cathode (CC) and Common Anode(CA).

Common anode displays are more popular as many logic circuits can sink more current than they can source.


Depending upon the decimal digit to be displayed, the particular set of LEDs is forward biased. For instance, to display the numerical digit 0, we will need to light up six of the LED segments corresponding to a, b, c, d, e and f. Then the various digits from 0 through 9 can be displayed using a 7-segment display as shown.

For a Common Anode Display , the COMMON pin should be connected to HIGH & the corresponding DIGIT segments should be made LOW.Each LED segment can tolerate up to only 1.5v DC .

As the HIGH level from PIC is around 5V , a current limiting resistor of 470 ohms must be used at the common pin.

For e.g., to display digit 1 , the segments b & c should be made LOW while the COM pin is made HIGH.

To display digit 2 , the segments a,b,d,e & g are made LOW while making the COM pin HIGH.

Then for a 7-segment display, we can produce a truth table giving the individual segments that need to be illuminated in order to produce the required decimal digit from 0 through 9 as shown below.


CONNECTIONS :  All segment pins are Enabled by LOW (0)

RD2  –>  DIGIT 1  Common Anode pin made HIGH to display a Digit.

RB7—>  D0               RB0 –> D7    

RB3 –> D4                RB6 –> D1 

RB2 –> D5                RB5 –> D2

RB1 –> D6               RB4 –> D3


The Demo board I’m using has 4 PNP Transistors which is connected to Digit1,Digit2,Digit3 & Digit4.When a LOW is applied to Base of transistor,it conducts and apply HIGH to the Common pin of Display.



Open a New project in MPLABX & follow the initial STEPS as described in previous post.

The code to drive a single Display is given below.CONFIG statements to be replaced by the code generated for configuration bits as described in earlier post.


#define _XTAL_FREQ 16000000
#include <xc.h>

// CONFIG statements here….

unsigned char hexValue[10]={0x03,0x9F,0x25,0x0D,0x99,0x49,0x41,0x1F,0x01,0x09};
int i=0;

int main()
TRISB=0x00;  // Port B pins all OUTPUTs
TRISD2=0; // RD2 as OUTPUT
RD2=1;    // Disable display 1

    RD2=0;   // Enable Display 1
    for( i=0; i<10; i++)
        PORTB= hexValue[i];


PNP transistors are used to drive the Enable common pin of CA displays. A LOW at the base of transistor will make it conduct & provide HIGH at the common Anode pin of Display.

According to the data pin (D0 to D7) levels , digits 0 to 9 are displayed. A LOW at data pin will make the segment GLOW & a HIGH will make it OFF.


The HEX values for the Digit to be displayed are achieved as shown in the Table above.These values are stored in an Array variable unsigned char hexValue , which is declared to store 10 values.

Port B is defined as Output by TRISB = 0x00;

Port pin D2 is declared as Output , which is used to enable the common pin of display.

Initially RD2 = 1 which makes the PNP transistor OFF & the display is disabled.

Under While loop , the  RD2 is made 0 to enable the Display & the HEX value data is loaded one by one at an interval of 1 sec.

You get display running from 0 to 9 at 1 sec interval repeatedly.

In the previous post we’ve seen the LED blinking program.In this post we shall see how to connect a push switch to a Digital Input of PIC 16F877A .

A micro switch is connected between port pin RB0 & Ground. Port pin RB0 is pulled High through a 10k resistor connected to +5v supply.On pressing the switch the LED glows & on releasing the switch the LED GOES Off.


Image 8


In the development board I’ve used , the pull up resistors are not provided.But this can be enabled internally by making the bit RBPU=0 of Option Register.

This can be achieved by declaring


or   RBPU=0;   The NOT_RBPU bit (MSB) is cleared in the Option Register to apply PULL UP internally to all PORTB pins. 


The pull up resistor is mandatory to avoid floating values at digital inputs.


Following 10 Steps are common for all projects except the project name is different.

In future projects I will not mention the following 10 steps .These are the initial settings required for each project.Future posts will be focused on main C code straight away.


STEP 1 :

Click on  File –> New Project

Under Choose Project select category  “Microchip Embedded “ & Projects as“ StandaloneProject


Image 1.1


STEP 2 :

Select the Target device as PIC16F877A.

Click Next



STEP 3 :

Select the TOOL as PICKIT2

Image1. 3

STEP 4 :

Select the Compiler as XC8 & click Next.


Image1. 5


STEP 5 :

Provide a name to the project & select the Project folder to store the results.

Click on FINISH

Image 2

STEP 6 :

Project folder appears in the File pane.

Right click on Source Files &  select  New  –>  C Main File

Image 3


STEP 7 :

Provide a name to the C file .The extension must be selected as c from the drop down below.

Click on FINISH


Image 4

STEP 8 :

Click on   Window  –> PIC MEMORY VIEWS –> Configuration Bits

Image 9


On the Task pane window you get the Configuration Bits .

Each bit can be modified as ON or OFF by the drop down menu following the bit

Set FOSC to HS for High Frequency External oscillator & other bits all OFF.

Click on “ Generate Source code to Output” button at the bottom.


Image 10

STEP 9 :

Configuration bit setting code is generated.

Delete the default code seen in the Editor pane on top.

Now Paste the Configuration code here.


Image 11

STEP 10 :

Finally add the Crystal Frequency definition to the top of #include <xc.h> statement

#define _XTAL_FREQ 16000000

Image 14




Now you can feed the following C main code below the configuration code.

Image 5


OPTION_REG MSB bit is cleared to enable internal PULL UP Resistors for PORTB.

Port B pin 0 is declared as INput where switch is connected

Port D Pin 2 is declared as Output where LED is connected  .

Initially LED is OFF by making RD2 pin low (RD2=0).

Under the never ending loop the condition of RB0 is verified & if the switch is pressed RD2 is made High , thus making the LED glow.

After a delay of 2 secs the LED is made OFF.


After feeding the Code press CTRL+SHIFT+S  to save all the project files.

Now click on RUN –> Build the Main Project 


Image 6

After getting BUILD SUCCESSFUL click on “Run Main Project “

The generated HEX file will be loaded on to the Target chip .

Image 7

If you press the switch at RB0 the LED at RD2 glows.



The same code can be used to check the Buzzer circuit & the Relay circuit ( if you’ve purchased the development board shown above)

Remove the wire at LED point & connect it to Relay input (connector CN12 ) which is seen near the yellow sugar cube relay on top right of the board.Now by pressing the switch the relay gets ON ,just like the LED.

To test the buzzer , connect the  wire from  RD2 port pin to CN21 .The buzzer is with a white round sticker on its top , seen  just above the LCD.Pressing the key will activate the buzzer now.

For availability of this development board contact :

cooltext753793315   cooltext753790696


In this post we shall work with the HELLO WORLD program ,blinking an LED.

Port Pin RD7 is declared as output where an LED is connected through a current limiting resistor of 470 ohms.External crystal of 16MHZ is used in the circuit & this is defined in the configuration settings.


Open the MPLABX IDE.

Click on File – > New Project



A New Project window opens.Select the category “Microchip Embedded “ & under projects select “Standalone Project” . Click on Next.




Next step is to select your target device.Under Device bar you can type in PIC16F877A or you can select from the  list of drop down menu.




Now select the Tool as PICKIT2 . Other options are PICKIT3,REAL ICE & Simulator.In this demo we’re using a PICKIT2 hardware.




Next is the selection of Compiler.You can see a list of compilers installed including MPASM (assembly language) . MPLABX allows usage of old HITECH C compiler also.

The XC8 will show up in the list if you had installed it correctly.

Select the XC8 compiler.




Now provide a Project name “LedBlink” & click on Browse to select a location to store the Project.

Click on Finish.




The MPLAB project IDE opens with 4 panes.FILE pane, Navigation pane, Editor pane & Task pane.

Inside FILE pane you can see your project LedBlink.




To write the C code we need to create a C main file.

Right click on Source Files & click on New—> C Main File




Provide a File name & ensure that the Extension is .c

Do not add the .c extension next to your filename.It is selected from the drop down menu of Extension, seen below the Filename.



Click on Finish to see the code window on Editor pane.

You can just delete the default code presented ( the #include declarations & int main statements)




Before writing the main code we’ve to program the configuration bits.Click on

Window –> PIC Memory Views –> Configuration Bits



On the Task Pane area at the bottom the Configuration options are displayed.




As we’re using an external High frequency crystal on the Demo board , select from the drop down menu against FOSC as HS .

Other options you can leave for defaults.But the LVP should be selected OFF.

Now click on the button which says “ Generate Source Code to Output”




You can now see the Configuration code generated as per your settings.




Copy the Configuration code generated & paste it on to the Code window of Editor pane .




Before the #include <xc.h> statement you’ve to define the crystal frequency.

#define _XTAL_FREQ 16000000

In this demo an external crystal value of 16MHz is used.This must be declared by the #define statement.If you miss this statement , any Delay statements in your code will show up a red squiggly mark.




Now type in the following code just below the configuration code.


int main()
    TRISD7=0;                  //RD7 declared as Output pin
    RD7=1;                     //make RD7 pin High to glow LED
    __delay_ms(1000);  // 1 second delay
    RD7=0;                    // make RD7 pin Low to Off LED

return 0;



Port pin RD7 is declared as Output by TRISD7 = 0

Never ending loop starts by while (1)

RD7 is made High by RD7=1 ,in turn makes the LED glow.

A delay of 1 second is given by __delay_ms(1000)  Note the usage of double underscore before delay statement.

RD7 pin is then made low by RD7=0 , switching OFF the LED.

Again a delay of 1 sec is given.

The never ending loop repeats , as a result you see the LED blinking at 1 sec interval.



Click on Run —> Build Main Project  to build the project.

If you’ve followed the Syntax properly , you can see Build Successful



Now click on Run –> Run Main Project 



MPLABX will connect to the hardware PICKIT2 & program the target IC .The .Hex file is loaded on to the Target IC & you can see the LED connected at port pin RD7 blinking.

The .hex file generated is located at folder


Image 11

Below is the picture of Development board connected with PICKIT2 .An LED is wired to port pin RD7 .



Watch this Tutorial Video :


In this blog series I’ll post tutorials on using PIC16F877A .You’ll learn the basics starting from installation of the new MPLABX IDE along with the C compiler XC8 .

Further you’ll learn all demo programs like blinking LED, driving a 7 segment display, driving a relay,driving a servo motor,controlling a stepper motor, interfacing keypad matrix, interfacing 16 x 2 LCD, UART control for serial communication,etc.,

To start with we shall walk through the installation of IDE with XC8 compiler.

Download the MPLABX IDE  (375 Mb)  from :

& XC8 compiler (180 Mb) for 12F,16F,18F series of PIC controllers from :

MPLAB XC Compiler licenses are available as Free editions and have the option of a 60-day PRO evaluation trial.After trial time you can continue using the compiler but without optimization .i.e your final hex  code will be larger.

Following is the screenshot of the installer files downloaded for MPLABX installation.

  Image 1

Double click on MPLABX installer application (version 2.26 at the time of this post) .

Setup window opens up.Leave the installation directory to default settings C:\ProgramFiles\Microchip\MPLABX


Image 2            Image 3


Select both the IDE and IPE .Click on Next button to start installing the IDE.


Image 4      Image 5


Once the installation is over you’ll be guided to download XC8 compiler if the XC compiler button is checked.

Image 6     Image 7

Now double click the XC8 compiler installer application


Image 8            Image 9


Leave the installation directory to default.

               Image 10    

On the next screen select all the options as Compiler settings.

      Image 11




Image 12           Image 13


Once the installation is completed you can see the MPLABXIDE & MPLABXC8 folders under All Programs.


Image 14      Image 15


Click on the MPLABX IDE v2.26 to start the IDE.


Image 16


In the next post we shall see how to blink an LED , a HELLO WORLD program to start with any Microcontroller.

To transfer the HEX file on to PIC Flash memory you need a programmer like PICKIT2 or PICKIT3.As a student you may not wish to shell out the bucks to buy one.The solution is PIC BOOTLOADER & this post is a tutorial on how to implement Boot loader on a PIC16F877A chip.

Remember that the Boot loader itself must be fused on to the Flash memory using an external programmer like PICKIT2.Once the chip is boot loaded the external programmer is not needed for further programming.

Whenever  a boot loaded chip is re started ,the program counter jumps to the boot loader section & waits for the instruction which is fed through the serial communication port.A Bootloader is the first program which executes (before the main program) whenever a system is initialized. In case there is no communication in the serial port, the program counter will jump to the preloaded program at 0000H & executes the program.

Mostly the bootloader resides in the bottom most area of the ROM but there are some cases where the boot loader can be configured in the top (like in PIC18F).The starting and ending address of the bootloader in the ROM depends on the product.

TINY BOOTLOADER is one such loader for PIC 16F & 18F ICs.

As all other bootloaders, this  consists of a Windows application running on the PC and boot loader firmware running on the target PIC chip.

Download the boot loader zip file from :


Features of the firmware
  • Size of only 100 words; (all versions, for 16F,18F,dsPIC occupy less than 100 words);
  • Can write flash, eeprom and configuration bytes(18F);
  • On reset, waits 1 second (adjustable) for a message from the PC, if not received, launch user application;
  • The .asm file can be easily modified and adapted for any frequency (or baudrate);
    Unzip the downloaded TINY PIC BootLoader.Under the folder named “picsource” is given the Boot loader Hex files for PIC16F & PIC18F ICs.Select 16f & then select the hex file “tinybld_16F876A_20MHz.HEX “ .
    This is the boot loader firmware compatible to PIC16F877A .The selection of crystal frequency 20MHz is important & ensure that the target board uses the same value crystal 20MHz. 
    The “tinybldWin” found in the top folder is the Windows application through which you can load the HEX file on to the arget chip PIC16F877A.

New Windows application can be  downloaded from :


To fuse the Boot loader firmware on to the target chip you need PICKIT2 hardware.




Place the PIC16F877A chip on to the ZIF socket of PICKIT2 programmer (pin 1 always near the handle).Start the application PICKIT2.

The hardware is detected automatically and  device name is displayed PIC16F877A.

Image 2

Click on File –> Import HEX

Image 3

Browse to the location where you’ve unzipped the downloaded folder & select the firmware Hex file

“tinybld_16F876A_20MHz.HEX “ .

The document of TINY BOOTLOADER says this is the matching firmware for PIC16F877A

Image 4

Click on WRITE to fuse the firmware n to the target chip.


Image 5

Now your PIC IC is BOOT LOADED & ready to accept your Program Hex files through the Serial port.

Image 6

To load your program HEX files you need an USB to UART converter.Here I’ve used one built on Silicon Labs CP2102.

The converter is connected to PC using USB cable.A RS232 STRAIGHT cable is used to connect the Target board with UART converter. 



Check out the connections between PIC & MAX232 ICs on your target board.

RC6 (PIN 25) should go to pin 11 of MAX232

RC7 (PIN 26) goes to PIN 12 of MAX 232.

PIN 13 of MAX 232 goes to pin 3 of the DB9 connector.

PIN 14 of MAX232 goes to pin 2 of DB9 connector.

Double check these connections, otherwise your Target chip won’t be detected by the Windows application.


Image 11


Now start the Windows application & click on CHECK PIC button.Your target chip is detected & displayed.The default Baud rate is 115200 .

You can also check the Search button to scan for the port where the Target board is connected.


Image 7

Click on BROWSE & navigate to the HEX file you’ve created using MPLAB.

Click on WRITE FLASH to fuse the HEX file on to the Target.

Image 8

Now the Boot loaded chip is fused with your program.On Power On restart the chip will start the Boot loader.After  1 sec wait , it will  launch your program.


cooltext753793315    cooltext753790696


PICKIT2 Lite is a clone hardware to fuse the HEX file on to the target PIC Microcontroller.The advantage of this USB Programmer is that you can program the HEX file from within the MPLAB IDE &  no standalone PICKIT2 software is required.

It is built on PIC18F2550 IC which is loaded with PIC Firmware & Boot loader.PIC18F2550  has an inbuilt USB interface avoiding the need for an external USB-UART circuit.

PICKIT2 Lite is an ICSP – In Circuit Serial Programmer 


              Picture 24


The 5 pins on PICKIT2 namely   VPP (MCLR) , VDD (+5V) , GND , DAT (PGD) , CLK (PGC)

are used for In Circuit Programming.While programming , a 12v is generated by PICKIT2 & applied to MCLR pin of PIC controller , while data flows in through PGD pin controlled by the PGC Clock cycle.

The AUX pin is used only with PIC microcontrollers that support LVP –Low Voltage programming.


The PICKIT2 programmer can be connected to a PIC DEMO Board using jumper wires according to following connection details. :

Image 1


As per above details connections to ICSP made & shown below:


Picture 25


Now you can open the project in MPLAB IDE & from within the MPLAB IDE you can initiate PICKIT2 & Program the HEX code on to the Flash ROM of PIC chip.

Connect USB cable to PC.Open the project in MPLAB IDE.

Under Programmer –> Select Programmer –> Select PICKIT2

Image 3


If PICKIT2 is not detected automatically , click on Programmer – > Connect

Image 4

Your hardware will be detected .The IC placed on the ZIF socket is also detected.


Image 5

Now you can click on Programmer –> Program to fuse the HEX file on to the PIC microcontroller.


Image 6


Watch this support Video :



cooltext753793315   cooltext1137713216




In this post we shall discuss the following common problems faced by newbies & their solutions.

1. My   .c  file is not showing under Source files.

2. After selecting HITECH UNIVERSAL TOOLSUITE from under Toolsuite Contents , there is an X mark seen near the Location.

3. I do not see the .HEX file generated.

4. My Build is successful. Fusing of HEX file is ok , but my project is not working.

5. PICKIT2 complains that there is no Configuration bits ,while importing HEX file.


1. When you try to add your C code file .c by right clicking Source files , it lands up under Other Files.The reason is , you’ve not selected the Tool suite for HITECH C compiler & it is in Microchip ASM tool suite for Assembly language.Unless you select the Hitech C you can’t add a .c file to Source files.


Image 1

Open your Project & select from

Project –> Select Language ToolSuite

Under Active Toolsuite select the HITECH UNIVERSAL TOOLSUITE

Image 3


Now your .c file will appear under Source Files.


2. You see an X mark near the Location while selecting Hitech Universal Toolsuite.

The reason is that while installing the HITECH  C Compiler you’ve selected a different location other than C:  or you might not have checked the “Set environment path “ while installing Hitech C compiler.

Click on browse next to Location bar &  go to the location where you’ve installed  the C compiler & select it.

By default it is under location

Image 3

Under /bin folder the executable C compiler file is picc.exe


Image 1


3.  Your BUILD is successful , but you do not see the HEX file.


Image 4


The HEX file generated along with other files inside the Project folder. But you do not see the extension .hex

Go to Tools –>  Folder Options  of the Windows Explorer .


Image 5


Under VIEW tab Un tick  “Hide extensions for known file types “ & click OK.


Image 6


Now you can see the .hex file.


Image 7


4 & 5 .  Setting the  Configuration bits & including it in the C code is important.


Under Configure select Configuration Bits.

A new window opens. Uncheck the box “Configuration Bits set in code “ to enable editing the bits.


Image 8


By default the Oscillator is set to RC Oscillator.But in your project you use an external crystal of 8 or 20MHz.From the drop down menu select HS Oscillator which stands for usage of High Frequency oscillator.

Disable Watch Dog timer,Power up timer & Brown out Reset.



Generally LVP (Low Voltage Programming) is not used .So select  “RB3 is Digital I/O,HV on MCLR must be used for programming “  .

The final hex value is generated & shown under Value .(3F3A)



This Hex value should be added in your CONFIG statement of C code.Note the usage of two underscores __ before CONFIG.




Now build your project to generate HEX code with Configuration bits.


Watch this support video :


Solution to common problems while programming PIC