When you install MPLAB IDE, by default ,a third party C compiler called Hitech C compiler for PIC10/12/16 family is installed.After successful installation ,the Hitech C compiler appears in the dropdown list of ‘Language Tool Suite ‘ selection of project wizard.


Image 1

Note that Hitech C is only preinstalled for PIC 10/12/16 family and this will not appear if you have selected a PIC18  Series device.

For programming a Pic18 series IC in C language either you have to install HITECH C compiler for 18 series or PIC C18 offered by Microchip itself.

Download the free student version ‘Lite mode’ which is a 75Mb download from


Image 2

Double click the downloaded file to start installation of PIC18.Generally it gets installed in

C:\MCC18  (Win7) or C:\Program Files\Microchip\MCC18 (XP).

Image 4Image 5

Note down the installation directory, as it is required to link the Tool suite contents.

Please note that MPLAB installation and PIC_C18 Installation are both separate and get installed in separate directories.The C compiler PIC18 is linked to your project during  step2  of the project wizard.

For  better understanding of this let us start with a new MPLAB project.

1.To start with create an empty folder in your C: drive ,say C:\myprojects.


Click   Project  –> Project Wizard –> Next

Now select a PIC18 device from the dropdown menu ,say  PIC18F4220.

3.  By clicking Next you land on the step 2 window for selection of Language Suite.

From the dropdown box next to Active Tool suite ,select ‘Microchip C18 Tool suite..This appears in the dropdown box only if you have selected a PIC18 family IC in the previous step.

Image 6

As you see in the screenshot above there are 4 contents in the Toolsuite contents :

Assembler(mpasmwin.exe), Object Linker(mplink.exe) , C compiler (mcc 18.exe) & Librarian(mplib.exe).

If any of the content is highlighted in the Tool suite contents , its location is displayed in Location box.In case you see a  X mark while highlighting any of the contents ,you then have to locate the component manually.If this is not done then your program build wont succeed.

To manually locate the components,highligt a content and then click Browse.. next to the Location box. All components are found inside the MCC18 directory,which is the default installation directory of PicC18 compiler.

mpasmwin.exe is found inside C:\MCC18\mpasm  folder

mplink.exe is inside  C:\MCC18\bin folder

mcc18.exe & mplib.exe are also inside   C:\MCC18\bin folder.

After confirming the location of all the 4 components Click  Next.

4. The Project location shows an empty box. Click Browse.. and point it to the empty       folder

C:\myprojects we created earlier.


After the folder opens enter a name for your project say, project1 and click save.An extension .mcp will be automatically  added.

Image 1.1

Next step is addition of any existing files to the project folder.For now simply click Next .

Project summary page appears.Now click Finish.

The MPLAB screen shows the project screen with project name in the top status bar and a project panel appears showing names of various folders that may be used with the project.

Image 2.2Image 4.4

Every project must have at least one Source file. Currently our Source file folder is empty.

5.Highlight the Source files folder in the Project panel and then from the File menu select ‘Add New File  to project’

Image 8

A new dialog box appears.Browse to the Myprojects empty folder you created earlier in C:\.You can see 3 files related to the project has already been created automatically by MPLAB IDE. In the filename box give a name like blank.c . The extension .c is a must.Click Save.

Image 10

Now  the source file is created and added as seen in the project panel. An editor panel also opens  , where you enter the C18 source code to the project.

Image 1.5

Type in the following skeleton code:

/**C18 Programming **/

# include <p18f4220.h>

void main (void)



Click the Floppy Icon in the top to save and then click the Build ALL icon at the extreme right ( 3rd from last).

Even though it is an empty program , the build Succeeds.


Click Project –> Close to save & close the project with all required MPLAB files.

If you get an error then verify the Build Options settings as follows :

Click  Project  -> Build Options  ->Project

This appears only when there is an active project open.

Select Directories tab.

Image 1.8

From the dropdown menu select one by one and enter as follows  :

1. Output directory

After highlighting this from the dropdown menu click New.

      Type in any name for the output ,like , “Output-HexFiles  “        and click Apply.

2.Intermediary Directory

Select this from the dropdown menu and click New.

Type in  “Object Linking Files “ and click Apply.

3. Include Search Path

Select this and click New. Then click the  … Browse button and go to C:\MCC18 and select the  h folder , which has all the Header files.

Now the path is C:\MCC18\h

click Apply.


4. Library Search path

Select this and click New. Click the  …Browse button and go to C:\MCC18\lib

Click Apply.

5. Linker-Script Search path

Click New and then Browse to C:\MCC18\bin\LKR.

Now select the MPLAB C18 tab .Under categories dropdown select ‘Memory Model’

Select the Code Model as Large  and the Data model as small as shown below:

Image 1.9

Click OK to complete the configuration.

If all these configurations are set as above ,then Build All will succeed.