0% found this document useful (0 votes)
62 views13 pages

ECE542L - Laboratory Experiment 1 PDF

This document describes Laboratory Experiment 1 which involves basic input/output (I/O) port manipulation for the PIC16F877a microcontroller. The objectives are to determine the ports of the PIC16F877a, manipulate the port status, and code a program for it. It explains that the PIC has output pins divided into ports that can be configured as inputs or outputs using TRIS and PORT registers. The experiment involves blinking LEDs connected to port C in different patterns depending on the status of pins on port B. Students are instructed to complete the code to blink the LEDs as specified and also design a "walking LED" circuit.

Uploaded by

Briely Briz
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)
62 views13 pages

ECE542L - Laboratory Experiment 1 PDF

This document describes Laboratory Experiment 1 which involves basic input/output (I/O) port manipulation for the PIC16F877a microcontroller. The objectives are to determine the ports of the PIC16F877a, manipulate the port status, and code a program for it. It explains that the PIC has output pins divided into ports that can be configured as inputs or outputs using TRIS and PORT registers. The experiment involves blinking LEDs connected to port C in different patterns depending on the status of pins on port B. Students are instructed to complete the code to blink the LEDs as specified and also design a "walking LED" circuit.

Uploaded by

Briely Briz
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/ 13

Laboratory Experiment 1

Basic I/O Ports Manipulation for PIC

ECE 542/L Microprocessor Systems


Objectives:
• To be able to determine the different
ports of the PIC16F877a.

• To be able to manipulate the port status


of the PIC16F877a.

• To be able to code a program for the


PIC16F877a.
Before going to the programming you should understand
the following things:

• Output pins of a PIC Microcontroller is divided in to


different PORTS containing a group of GPIO (General
Purpose Input Output Pins) pins.

• In 16F PIC Microcontrollers, there are two registers


associated with a port, TRIS and PORT. eg: TRISB,
PORTB, TRISC, PORTC
• TRIS stands for Tri-State, which determines the
direction of each GPIO pin. Logic 1 at a particular
bit of TRIS register makes the corresponding pin
Input and Logic 0 at a particular bit of TRIS register
makes the corresponding pin Output. An Input pin
of PIC Microcontroller have very high input
impedance, thus it may said to be in Hi-Impedance
state.
• PORT register is used to read data from or write
data to GPIO pins. Logic 1 at a particular bit of
PORT register makes the corresponding pin at
Logic High (VDD) and Logic 0 at a particular bit of
PORT register makes the corresponding pin at
Logic Low (VSS) if that pin is an Output pin (TRIS
bit is 0).

• PORT register can be used to read digital data from


an Input pin. Logic 1 indicates the pin is at Logic
High and Logic 0 indicates that the pin is at Logic
Low.
PIC16F877A Pin Outs
Circuit Design for Blinking LEDs
Laboratory Exercise 1: Blinking LEDs

Exercise details:
• When PORT RB0 is Low, LEDs connected to RC0-
RC3 must blink
• When PORT RB0 is High, LEDs connected to
RC4-RC7 must blink
• When PORT RB1 is High, LEDs connected to
RC0-RC7 must blink
Laboratory Exercise 1: Blinking LEDs
Open your mikroC and create a project for this
experiment.
int x=1;
void main() {
TRISB = 0b111; //set port B to input
TRISC = 0b0000; //set port C to output
PORTC = 0; //initialize port C
PORTB = 0; //initialize port C
while(x=1){
if (PORTB.RB0 == 1) //check status of PORTB pin RB0
{
PORTC = 0; //set port C to low
delay_ms(50);
PORTC = 0xF0; //set port C to high
delay_ms(50);
}
…continued

else if (PORTB.RB1 == 1)
{
PORTC = 0; //set port C to low
delay_ms(50);
PORTC = 0xFF; //set port C to high
delay_ms(50);
}
else
{
PORTC = 0; //set port C to low
delay_ms(50);
PORTC = 0xF; //set port C to high
delay_ms(50);
}

}
}
Design Exercise 1: Walking LED

Exercise details:
• Utilize the previous circuit design for this activity.
• When PORT RB0 is High and RB1 is Low, lighted
LED must shift to the left
• When PORT RB0 and RB1 are Low, lighted LED
must shift to the right
• When PORT RB0 and RB1 are High, LEDs must
blink
• When PORT RB0 is Low and RB1 is High, LEDs
must stay lighted
Copy your codes and circuitry in an A4 sized PDF file
together with your name and subject details. Content
of the file must be the result of Laboratory Exercise
and Design Exercise.

Attach the file in the your Schoology account under


the “Laboratory Experiment 1” activity found at the
Materials section.
Laboratory Experiment 1
Basic I/O Ports Manipulation for PIC

ECE 542/L Microprocessor Systems

You might also like