Introduction to MPLAB Compiler

Hello friends, I hope you all are doing great. In today's tutorial, I am going to give you a detailed Introduction to MPLAB Compiler. MPLAB is used for PIC programming both in assembly and C languages. In my previous posts, I have completely explain how to install MPLAB software and also the C compiler for MPLAB.Today I am going to explain getting started with MPLAB. This chapter doesn't belong to programming but the initials required for programming. Setting a project in MPLAB is not much difficult but obviously beginners don't know much about it and they think that its a crap and very difficult. Although its not and i think its the best programming compiler for PIC Microcontroller. Easy and fully controllable. In the coming tutorial we are gonna design a small project in which we will do LED Blinking using PIC Microcontroller. So let's start it.

Steps To Follow

I believe that you have installed the MPLAB Software which I have emailed to all the subscribed users on our site. If anyone didn't receive it yet then get subscribed on our site and I will email it to you. You should also have a look at these Top 3 PIC C Compilers. Now follow these steps carefully and if you feel any problem let me know in comments.

Step 1
  • Open the software by clicking on the icon placed on your desktop or in the start menu. It will open as shown in the figure below:
Step 2
  • Now first we need to make a new project to start our programming so click on Project and then New.
Step 3
  • By clicking on New, it will open a new dialog box, where you need to put the Project name and the destination of your project and click OK.
  • I recommend to choose a separate folder for each of your project so that the files never mixed up.
Step 4
  • After clicking OK you will see that nothing changed and you are unable to see your newly created project.
  • So to view your project click on the View and then Project as shown in image below:
  • Now after clicking on project a small window on the right side will open.
  • Its called Tree in programming language and it shows all the files you are using in your project but right now its empty because you didn't add any file in your project, you have just created it.
Step 5
  • Lets add files in your project. So for this click on the File and then New and you will see a file will open with the name Untitled. this is the file in which we will add our programming code.
  • But first we need to add it in our project otherwise it will remain just a notepad file.
  • Sorry, I don't have image for this step actually it got lost, i think its not much difficult :))
Step 6
  • So now to add you file in your project, click on the File and the Save as.
  • A new dialog box will open, now enter name of your project and add it in the same location where you created your project.(it's not necessary but files of project should remain in the same location) and then click Save.
  • Here comes the important part must add .c extension after the name of your file. This .c extension will tell the compiler that its our C programming file.
 
Step 7
  • Now we have created our c file but we didn't add it in our project. ( Saving in same location doesn't mean that you have added it your project)
  • So to add the file in your project, right click on the Source File in the left side panel and then click on Add Files as shown in the image below.
  • It will open a dialog box now select your recently created file with the extension .c and click save and you will see that it will appear under the Source File folder.
Step 8
  • Now we need to add the header, library and linker files in our project.
  • So repeat the same process and right click on the Header Files and then Add Files.
  • Now the question is where to find the header file.Move to the location where you have installed your C compiler, the default location is C drive and the name is MCC18.
  • Open MCC18 Folder and there you will see many folders.
  • To add the header file click on the folder with the name "h" (h for header).
  • In this folder you will see a lot of files, which file to select depends on the PIC you are using.
  • As I am using PIC18F452 so I wrote p18F452 in the File name box and in the suggestions i got my file with the name p18f452.h and i selected it and click save as shown in the image below.
Step 9
  • Repeat the same process for linker and library files.
  • For linker file open the folder with the name "lkr" in the MCC18 folder and for library file open the folder "lib" and select the file with name of your Microcontroller.
  • I have added all my files as shown in the image below and now my project is complete.
  • That's all our project structure has completed, now if you want to do coding just add it in your newly created .c file and if you want to save the project then click on File and then Save Workspace and it will save your project.
  • In our next class we will add the code in the .c file and execute it on our pic.
I hope you have enjoyed this detailed Introduction to MPLAB Compiler for PIC Microcontroller. Till next tutorial ALLAH HAFIZ ...... stay blessed ..... and keep remembering me in your prayers .... :))

Installation of MPLAB C Compiler

Hello friends, hope you all are fine and enjoying good health. In today's tutorial we are gonna have a look at Installation of MPLAB C Compiler in Windows. In the previous part of this chapter, I have explained How to install the MPLAB software in Windows, that part was not much tricky and we did very easily and our software was then ready to use, but as we didn't install the C compiler so we can't do C programming for PIC Microcontroller on MPLAB. We can only do assembly programming on it. Now in this post I will teach you how to install MPLAB C18 compiler so that we can do programming of PIC in C. There are many different compilers available in the market, one of them is MikroC and another famous one is CCS but they are paid compilers means you have to buy them, in order to work on them. You should also have a look at Introduction to MPLAB Compiler.

Although they provide some demo version as well which has some limit of hex size. Why MPLAB is better than MikroC or any other compiler is because it is very flexible. You can change any bit of your Microcontroller in MPLAB but this thing isn't possible in other compilers. But on the other side it also more difficult than other compilers. MikroC has builtin libraries using which you can save quite a lot of time. Suppose you wanna run LCD, then in MikroC you just need to write 2 lines but in MPLAB there will be quite a lot code lines need to be written. Here's a comparison of Top 3 PIC C Compilers. So, anyways its just a little comparison, now lets come back to our tutorial and start with Installation of MPLAB C Compiler.

Installation of MPLAB C Compiler

  • The software has already been emailed to all the subscribed members. If you are not subscribed yet then get subscribed and it will be emailed to you as well.
  • Open the rar file and you will see there are two folders in it, this time open the second folder named MPLAB C18 F and run the exe file in it.
  • The next screen appears will be like the below image. On this step click Next.
  • Now the below image will appear, click on I Accept and then click Next.
  • Browse for the location where you want to install the compiler but i will recommend to install it in the C so don't change the location.
  • Now don't change any option and just click Next again as shown in below image:
  • Now here comes the real part, check all the boxes as shown in below image, they make the work easier and while making a project you don't need to add them manually.
  • Again you will come with four option and do the same thing check all the boxes as shown in the image below.
  • Now simply click on Next.
  • And finally your software will begin to install.
  • When the installation process is completed , uncheck all the options and just click on the finish button and your C compiler is now ready for use.

Advice

  • Always install the MPLAB software first and then the C compiler. Actually C compiler links itself with the MPLAB software so it will become very handy for you.
  • It seems like a lengthy proces but in actual its not, just a few clicks and you are done.
I hope you have enjoyed today's tutorial and now can easily install MPLAB C Compiler for PIC Microcontroller. Will meet you guys in next tutorial. Till then take care & have fun !!! :)

How to Install MPLAB Software in Windows

No. MPLAB Tutorials
Give Your Suggestions !!!
1. Getting Started With Microcontrollers
2. Getting Started with PIC Microcontrollers
3. Functions Available in PIC18F452
4. How to Install the MPLAB Software
5. How to Install the MPLAB C18 Compiler
6. Getting started With MPLAB
7. LED Blinking Project on PIC Microcontroller

Hello friends, hope you all are fine and enjoying good health. Previously, we have seen Functions available in PIC18F452. In today's tutorial we are gonna have a look at How to install MPLAB software. Until now, we have seen only what is PIC Microcontroller and what is it capable of? Now we are gonna move a little further and will see how we can burn program into it and get it our slave. So in order to make the PIC our slave, we have to burn some coding into it and even before that we need some platform where we can actually write this coding and this platform is provided by Microchip itself and is called MPLAB.

MPLAB is a software in which we write a programming code for PIC Microcontroller. It is basically a compiler which compiles the code and then create its hex file, which we later uploads in our microcontroller. I have explained this thing before in Getting Started with PIC Microcontroller. Now before going any further, we will first have a look on how to install MPLAB software in Windows. So in this tutorial, I will explain the step by step the whole process of installing MPLAB. MPLAB supports assembly language, which we are not gonna learn in this class so, after installing the MPLAB software we also have to install the MPLAB C compiler, which we will install in the coming tutorial, so first install this MPLAB software and then move to the next tutorial to install C compiler.

Steps to Install MPLAB

  • You can download MPLAB software quite easily from official site of MPLAB as its free of cost.
  • Open the rar file and you will see there are two folders in it, open the folder named MPLAB_IDE_v8_56 and run the file setup.exe
  • The next screen appears will be like that :
  • Click on Modify and then on Next and the next screen will be like below image :
  • Don't do any changing and again click on Next.
  • On the next window,click the NEXT button again.
  • The software will now begin to install and after complete installation the final window will popup simply click on FINISH.
  • That's all your software has been installed.
  • Now simple open the software and start programming but you can only do programming in assembly language.

The first part of this tutorial has been completed. In the next part, I will explain how to install the MPLAB C compiler so that you can also do programming in C language in MPLAB.

Till then take care ...... ALLAH HAFIZ :))
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir