0% found this document useful (0 votes)
22 views5 pages

TP N1 Malak

It is about a script to program 16F877

Uploaded by

malak Milo
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)
22 views5 pages

TP N1 Malak

It is about a script to program 16F877

Uploaded by

malak Milo
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/ 5

TP N°1: Introduction to Proteus and MikroC PRO

GI_1

By the student : Khernane Malak .

A general idea of the 16F877:


The 16F877 microcontroller is commonly used in a wide range of applications such as home
automation, industrial automation, robotics, and automotive electronics, among others. It can be
programmed using various programming languages such as C, C++, and Assembly, and can be
programmed using various development tools such as MPLAB IDE and PICKit.

In our first TP we used the "mikroC PRO" as a compiler , it started with establishing a new
project at the interface of the mikroC PRO than we had typed and compiled all the codes one by
one(each one has been treated apart),all was written by C .

The first code:

void main(){
trisb = 0b11110000;
while(1)
{ portb = 0b00001111;}
}

Here is a breakdown of what some parts of the code above does:

︎"trisb = Ob11110000;" sets the direction of the pins of port b of the microcontroller as
inputs or outputs. In this case, the four most significant bits of port B are set as inputs (1) and the
four least significant bits are set as outputs (0).

︎"portb = 0b00001111;" sets the value of the four least significant bits of port b as high (1)
and the four most significant bits as low (0). This will turn on the intput pins of port b while
keeping the output pins at a low state.
The third code:

void main() {
trisb= 0b11110000;
while(1){
portb = 0b11110000;
delay_ms(200);
portb.f0=1;
delay_ms(200);
portb.f0=0;
porth.f1=1;
delay ms(200);
portb.f1=0;
portb.f2=1;
delay_ms(200);
portb.f2=0;
porth.f3=1;
delay_ms(200);}
}

Some more clarification :


"trisb= 0b11110000;" to insure that all the attributes values to the output pins of the port b are
(0).
"portb.f2" and "portb.f3" are used to turn on and off the third and fourth output pins of port b.
"delay_ms(200);"is used to introduce a delay of 200ms between each of the output.
Some programs that we were asked to write:
The first code makes the even diodes flash for one second and the odd diodes for one second .

The second code start whith adding 4 other LEDs "trisb= 0b00000000;"where the lit LED
moving from top to bottom.
The Last one is a program with a chaser from top to bottom and simultaneously from bottom to
the top .

The simulation
After the coding section we passed to the simulation part using the software ISIS PROTEUS
,where we have created a new project and establish a test circuit .
The test circuit contains one microcontroller to test it ,diode to show off the output ,a resistance
which allows to a certain electric current intensity passing through the diode, a crystal which is
an electrical components are commonly used in electronic devices to provide a stable reference
frequency for timing and synchronization.

You might also like