You are on page 1of 10

Introduction to mikroC PRO for PIC

MICROCONTROLLER

Hammad Khan (191216)


_________________________

BACHELOR OF ELECTRICAL ENGINEERING


Fall-19

Submitted To:
Engr. Mariam Sabir
Lab Engineer
____________

Department of Electrical Engineering


FACULTY OF ENGINEERING
AIR UNIVERSITY,ISLAMABAD
AIR UNIVERSITY
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

EXPERIMENT NO 8

Lab Title: Introduction to mikroC PRO for PIC

Student Name: Hammad Khan Reg. No: 191216

Objective: Introduction to PIC18F452 and mikroC Pro 6.4.0. Familiarizing students with
programming in mikroC Pro, creating a new project and verifying results

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: 1-12-2021 Signature:


Lab#08
Introduction to mikroC PRO for PIC
Objective:
 Introducing students to PIC18F452 and mikroC Pro 6.4.0
 Familiarizing students with programming in mikroC Pro, creating a new project and
verifying results

Equipment:
Hardware:
1. 89c51 microcontroller
2. LEDs
Software:
1. Keil u-vision
2. Smart-pro 5000u

Discussion:
Introduction:
PIC 18FXXX:
The acronym PIC stands for "peripheral interface controller". PIC 18FXXX series has the
following features:
• 8 bit microcontrollers; Middle series
• On Chip ROM
• Data EEPROM
• Data RAM Timers
• ADCs
• I/O Ports
• USART
PIC18F452 microcontroller has a number of input/output pins which are used for connections
with external devices. It has a total of 40 pins out of which 34 pins can be used as input output
pins. These pins are grouped into 5 sets which are called PORTS denoted by A, B, C, D and E.
• Port A consists of seven pins named as RA0-RA6.
• Port B consists of eight pins named as RB0-RB7.
• Port C consists of eight pins named as RC0-RC7.
PIC18F452 is a powerful microcontroller with one 8-bit and three 16-bit timers, 8-Channels 10-
bit Analog-digital converter, and I2C, SPI, USART peripheral. It is a low power microcontroller
unit that consumes about less than 0.2 μA standby current and 1.6mA normal current during 5V
and 4 MHz operations. Some important features for this micro-controller are given below:
Crystal Oscillator/Ceramic Resonators:
In XT, LP, HS or HS+PLL Oscillator modes, a crystal or ceramic resonator is connected to the
OSC1 and OSC2 pins to establish oscillation. The PIC18F452 oscillator design requires the use
of a parallel cut crystal. Figure below shows the pin connections:

The electrical characteristics of PIC18F452 are:

PIC18F452 Registers:
Each port has three registers for its operation. These registers are:
• TRIS register (data direction register)
• PORT register (reads the levels on the pins of the device)
• LAT register (output latch)
LAB TASKS
Task#01
Write a code in mikroC to blink even and odd LED patterns. Verify the results on Proteus
and hardware.

Program Code

void main()
{
TRISB = 0; //Makes PORTB0 Output Pin
while(1)
{
PORTB = 0x55; //LED's ON
Delay_ms(100);
PORTB = 0xAA; //LED's OFF
Delay_ms(100);
}
}
Proteus Circuit
Task#02
Write a code in mikroC to shift the data towards right or left and display the results on LEDs.
Verify the results on Proteus and Hardware.
Code

void main()
{
TRISB = 0; //Makes PORTB0 Output Pin
//Right shift
while(1)
{
PORTB = 0x8;
Delay_ms(100);
PORTB>>=0x01;
Delay_ms(100);
PORTB>>=0x01;
Delay_ms(100);
PORTB>>=0x01;
Delay_ms(100);
PORTB>>=0x01;
Delay_ms(100);
}}
Proteus Circuit
Learning Outcomes:
In this lab, we got a brief introduction about PIC micro controller P18F452. PIC18F452 is a
powerful microcontroller with one 8-bit and three 16-bit timers, 8-Channels 10-bit Analog-
digital converter, and I2C, SPI, USART peripheral. It is a low power microcontroller unit that
consumes about less than 0.2 μA standby current and 1.6mA normal current during 5V and 4
MHz operations
We also learnt about PIC compiler named mikroC PRO. It is very helpful and easy to use
compiler for PIC micro controllers. We performed certain task in C language on P18F452 using
mikroC to fully understand the functionality of PIC and to get familiar with the interface of
mikroC.

You might also like