You are on page 1of 4

Laboratory Activity 1:

PIC16F84A Microcontroller
Faderan, Daniel Brian Fernandez, Jose Carlos BS Computer Engineering Ateneo de Manila University Loyola Heights, Quezon City

I. OBJECTIVES The goal of this experiment is to be able to explore the functions PIC16F84A Microcontroller and finally be able to program it. The PIC16F84A should be programmed to be able to display a 4-bit output dependent on a user-controlled 2-bit input. II. INTRODUCTION The PIC16F84A is a microcontroller in the PIC family. It has a total of 18 pins, 13 of which are I/O pins which we can use, as seen in Figure 1. Using this microcontroller, we will use a total of 6 of the available I/O pins to create a circuit which uses 2 inputs in which the value is controlled from the switches of the Digital Kit provided in the laboratory which would then control 4 outputs which will be noticed through the kits LEDs. Controlling the outputs will be handled by a program which will be installed into the microcontroller.

The conditions of the program are as follows: Input: Sw2 = 0 and Sw1 = 0, Output: LEDs = 0101 Input: Sw2 = 0 and Sw1 = 1, Output: LED values are rotating left with initial value of 0001. Input: Sw2 = 1 and Sw1 = 0, Output: LED values are counting. Input: Sw2 = 1 and Sw1 = 1, Output: LEDs are alternately blinking (i.e. 1001 <--> 0110)
III. METHODOLOGY

A circuit is built following the circuit diagram below:

Fig 1. PIC16F84A Microcontroller Circuit Diagram

Two RA pins(pin 17 & 18) were used as inputs whilst four RB pins(pins 6, 7, 8, 9) were used outputs during the programming process. 2 input pins were attached to switches whilst 4 output pins were attached to LEDs. Below is the code for the required program which was installed into the microcontroller(with comments as explanations): //code start
INCLUDE "P16F84.INC" list p=16F84 radix hex

__config _XT_OSC & _PWRTE_ON & _WDT_OFF PortB PortA status trisb trisa count1 count2 equ equ equ equ equ equ equ org bsf movlw movwf movlw movwf bcf start BTFSS BTFSS sw BTFSS input00 movlw b'0101' movwf PortB call delay goto start input01 movlw movwf call movlw movwf call movlw movwf call movlw movwf call goto input10 movlw movwf call inc1 incf call BTFSS goto BTFSS goto BTFSS goto BTFSS goto goto input11 movlw movwf call movlw movwf call goto delay b'1001' PortB delay b'0110' PortB delay start PortB delay PortB, 0 inc1 PortB, 1 inc1 PortB, 2 inc1 PortB, 3 inc1 start ;alternately blinking LEDs b'0000' PortB delay b'0001' PortB delay b'0010' PortB delay b'0100' PortB delay b'1000' PortB delay start ;binary counting LEDs ;rotating left LED light PortA, 1 goto goto input00 input10 ;else if pin 17 = 0, then ;if pin 18 = 0, goto still LEDs ;if pin 18 = 1, goto binary counting LEDs ;still LEDS PortA, 0 goto PortA, 1 goto goto input01 input11 sw ;if pin 17 = 1, then ;if pin 18 = 0, goto rotating left LEDs ;if pin 18 = 1, goto alternately blinking LEDs ;check if binary value in pin 17 is either 1 or 0 h'06' h'05' h'03' h'86' h'85' h'0e' h'0f' 0x000 status,5 00h trisb 03h trisa status,5 ;RB pins ;RA pins

loop1a labela loop2a end;

movlw movwf decfsz goto return movlw movwf decfsz goto goto

h'ff' count1 count1,1 labela h'ff' count2 count2,1 loop2a loop1a

;setup delay count value 1 ;count1 is slow counter ; ;still > 0 ;count1 < 0 so get out of the delay loop ;setup delay count value 2 ;count2 is fast counter inside count1 loop ; ;still > 0 so stay in loop2 ;count1 < 0 go to loop1

//end code
IV. RESULTS & DISCUSSION Below is the set-up for the microcontroller done according to the circuit diagram:

Fig 2. PIC16F84A Microcontroller Set-Up

Fig 2.1. Switches Designating Pin 17 & 18 With 0 Binary Value

Fig 2.2. Pin 17 = 0, Pin 18 = 0, Still LEDs Triggered

Figure 2.1 and 2.2 are samples taken from the experiments video documentary to indicate that the PIC is functioning well and the program installed is working according to its predetermined conditions.
V. CONCLUSION AND RECOMMENDATION

The PIC16F84A is a good microcontroller to start out with because of its good number of I/O pins and wide range of possible applications, although, it is limited to small-scale circuit technology like this lab experiment, for example. It is good for similarly small applications and is great for laboratory practice even if programming it requires low-level programming language like Assembly. Overall, this version from the PIC family is indeed useful.

You might also like