0% found this document useful (0 votes)
16 views

MP Lab Report # 1

This document describes a lab experiment on using MikroC PRO for PIC microcontrollers. The objectives are to install MikroC PRO, create a new project, make a schematic in Proteus, and burn the hex file onto a PIC18F452 microcontroller. The lab instructions provide steps to install MikroC PRO, start a new project, write code to blink an LED, create a schematic with a PIC18F452, LED bar graph, and resistors, and debug the code. A task is defined where port D is set as an input to read switches, port B is set as an output, and the code writes the port D values to port B to light the LED bar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

MP Lab Report # 1

This document describes a lab experiment on using MikroC PRO for PIC microcontrollers. The objectives are to install MikroC PRO, create a new project, make a schematic in Proteus, and burn the hex file onto a PIC18F452 microcontroller. The lab instructions provide steps to install MikroC PRO, start a new project, write code to blink an LED, create a schematic with a PIC18F452, LED bar graph, and resistors, and debug the code. A task is defined where port D is set as an input to read switches, port B is set as an output, and the code writes the port D values to port B to light the LED bar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

AIR UNIVERSITY

DEPARTMENT OF ELECTRICAL AND COMPUTER


ENGINEERING
EXPERIMENT: 01

Lab Title: . Introduction to MikroC PRO for PIC


Student Name: ABDUL MOEED, HASSAN ZEB, UMAIR-UL-HASSAN

Reg. No:190378, 190570, 190538

Objective: To recognize the working of Mikro-C and SmartPro 500u burner.

LAB ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes (5) (4) (3) (2) (1)
Ability to Conduct
Experiment
Ability to assimilate the
results
Effective use of lab
equipment and follows
the lab safety rules

Total Marks: Obtained Marks:

LAB REPORT ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes
(5) (4) (3) (2) (1)

Data presentation

Experimental results

Conclusion

Total Marks: Obtained Marks:

Date: Signature:
Lab 1
. Introduction to MikroC PRO for PIC

Objectives:
 Install the MikroC Pro 6.4.0
 Start up the mikroC PRO for PIC
 Create A New Project
 Make Schematic on Proteus and burn your hex file in PIC18F452

Hardware:
 PIC18F452 microcontroller
 Led Bar graph
 Resistors
Introduction:
Install the compiler:
Install this software“mikroC_PRO_PIC_2014_6.4.0”

Open “keygen” folder then open “mikroC PRO for PIC”.

Launch the application” keygen” and then a black window will appear after waiting for 1 or 2
seconds you are done with it.

Start up the compiler:


Launch from desktop “mikroC PRO for PIC"

1. Main Toolbar
2. Code Explorer
3. Project Settings
4. Messages
5. Code Editor
6. Image Preview
7. Project Manger
8. Library Manager

Procedure:
Creating a New Project:
Step1: The process of creating a new project is very simple. Select the New Project option from
the Project menu as shown below. The New Project Wizard window appears. It can also be
opened by clicking the New Project icon from the Project toolbar.
Step2: Rename the project then select the directory in which you want to save your project.
Select the device for which you want to write code here I am using “PIC18f452” and then choose
the xtal oscillators value.

Click Next.

Step3: This step allows you to include additional files that you need in your project: some
headers or source files that you already wrote, and that you might need in further development.
Since we are building a simple application, we won’t be adding any files at this moment.
So just Click Next
Step4: Following step allows you to quickly set whether you want to include all libraries in your
project, or not. Even if all libraries are included, they will not consume any memory unless they
are explicitly used from within your code. The main advantage of including all libraries is that
you will have over 500 functions available for use in your code right away, and visible from
Code Assistant [CTRL+Space]. We will leave this in default configuration:

Make sure to leave “Include All” selected. Click Next.

Step5: Click Finish


You can verify project setting. Write your code in second window

Step6: In this Step you will write a code for “LED Blinking”.
Write code as shown below and Build it

Step7: Remove Errors if you found

Step8: Debugging, you can add or remove registers or variables in watch window to observe
them step by step to verify your logic (as this step is not necessary)
Make Schematic in Proteus:
Make schematic shown below

Double click on pic18f452 and specify path for program hex file.

Click on play button, if you followed all the steps in correct way then blinking will be started.
You can add registers in watch window in proteus for the purpose of debugging Debug>>Watch
Window

SFR’s are being used here: Latx, Portx, and Trisx


Trisx is used to mark a port input or output to make a port input Trisx=0; and to make a port
output Trisx=0xff;
Latx is used to write data on the port. Sometimes when you write data on a Portx and a load is
attached with that port than this load can change the logic state which you have written on that
Portx and you can get unexpected results so, to write data on port an internal latch is being used.
Example: If Led is connected with an I/O Port then you should write data on Latx to turn on or
off led. This Latx will pass its value to PORTx and led will be off or on according to your data.
Led is Light emitting diode so after certain voltage light emitting diode will be in forward biased
and act like short circuit and logic 1 will be shorted with ground and changes to logic 0 and it
produces unexpected result because you passed “logic 1” on that pin but know “logic 0” is
present on that port. But data on Latx is same as I passed.
Simply Latx will be used when Trisx=0 ;)
Portx is used to read data from the port.
Simply Portx will be used when Trisx=0xff ;)

Lab Task1:
Define Port D an input Port and Port B an Output Port. Connect led bar graph to observe output
and connect switches on Port D then write data from PortD to PortB (For writing purpose SFR
“Latx” will be being used and for reading purpose Portx will be used).

CODE:
void main() {

TrisD=0xff; //Define PortD an input port

TrisB=0; //Define PortB an Output Port

while(1) //Infinite loop


{

LatB=PortD; //Input from the PortD is being written on LATB

}}

Schematic:

Change the Switches states and observe it on led bar graph.


Conclusion:
In this lab we learned the basic code to light up the led bar, just to get familiarized with the
MikroC and Smart-Pro burner. We lighted up the LED bar through the switches which were
connected by a DC supply by one end and was grounded by another.

You might also like