Академический Документы
Профессиональный Документы
Культура Документы
1
THE OUTPUT INSTRUCTION
OBJECTIVES
Upon the completion of this lab, you should be able to:
Connect the PORTB of PIC to LED board.
Use the OUTPUT instruction and be familiar to the environment of Flowcode
Software.
Configure the correct settings for the target PIC.
Design a simple program for PIC.
Simulate the program.
Compile and download the program to PIC.
Test the program loaded in the PIC.
EQUIPMENTS
Hardware:
Multichip Programmer
USB cable
AC adapter
LED board
PC
PIC16F84A
Software:
Flowcode
PPP
BACKGROUND
The PIC16F84A belongs to a class of 8 bit microcontrollers of RISC architecture.
It has ROM, RAM, EEPROM, Flash memory and two ports namely PORTA which has 5
pins (RA0RA4) and PORTB has 8 pins (RB0RB8). These ports are configurable as
input or output which means there are 13 input/output ports. They are used to interface
to different electronic devices such as LEDs, switches, motors, sensors, LCDs and
keypads.
The basic PIC microcontroller circuit requires an oscillator and an optional reset
button. An oscillator is necessary for the PIC to work properly because it is the one that
provides the clock pulse and determines how fast the microcontroller will execute the
program loaded to its memory. Resistor-Capacitor (RC), Crystal and Resonator
oscillators are types of oscillators that can be used for PIC micros. The crystal oscillator
is the commonly used which ranges from 4MHz to 20MHz.
LEDs with current limiting resistors are connected to microcontroller in two ways.
One is to switch them on with logic zero, and the other using logic one. The value of
resistor is determined by the amount of current that can flow to the LED. The maximum
current flow through the LED is set by the manufacturer.
PROCEDURE
1. Set up the Hardware.
Page 1 of 5
Flowcode will then display the microcontroller in the Microcontroller view and create an
empty flowchart. If the microcontroller is not shown, click ViewChip
Page 2 of 5
Click on the
arrow by the ' Connect to Port' dialogue box, and select the PORTB
option in the menu that you see. Notice that the settings for 'PIC Port' and 'PIC Bit'
change for all eight LED's.
Click on the 'Done' button to close the dialogue box.
You can change the color of the LED's by clicking on the
button on the LED display,
and choosing the 'Properties' option. The following dialogue box opens:
Click on the
arrow at the end of the 'LED Color' box, and select the color you want.
Then click the 'OK' button to close the dialogue box.
Move the cursor over the 0 in the Variable or value box and click once. This will highlight
the '0'. Now type a number 1 on the computer keyboard to change the value to a 1.
Page 3 of 5
Page 4 of 5
8. Repeat Step 5 to 7
You can also use Hexadecimal number preceded by 0x. To input 45H, enter 0x45.
For Binary numbers, precede it with 0b followed by 8 bit binary number. For example 45H is
equivalent to 0b01000101 in Binary.
Modify the value of set in the Output icon
into the following:
a. 57
b. 36
c. 15
d. 150
e. 200
f. 0xCD
g. 0xAD
h. 0x1F
i. 0x35
j. 0xA1
Whats the actual output? Which LEDs are ON?
Which LEDs are OFF? Why?
Supplemental Activities
The program should be downloaded to the PIC for verification and checking.
1.
2.
3.
4.
5.
6.
Use a single output icon that lights all of the LED's of Port B.
Alter the icon parameters so it puts only the odd LEDs of PortB 'on'
Now put only the even LEDs of PortB 'on'.
Now put the High nibble (bits 4 to 7) of Port B 'on'
Put only the LED on PB7 'on' by sending an 8-bit value to this port.
Write a program with at least 20 Outputs icons that writes a pattern of different
values to port B, one after the other, and review what the result is in simulation.
7. Draw up the full circuit diagram of the PIC with 8 LEDs on port B, including the
clocking circuit, the reset circuit, VDD and VSS connected to the PIC and the correct
current limiting resistors connected between LED and PIC.
Page 5 of 5