You are on page 1of 12

Experiment 2

THE PROGRAMMER
Name: ____________________________________ Section: _____________
Professor: ________________________________ Date: ________________
DURATION: 2 Hours

OBJECTIVES:

 To be able to learn how to load the source code into the PIC16F84A using
different types of Programmer.

 To test the loaded source code into the actual circuit.

BACKGROUND:

The Programmer is a hardware that serves as interface circuit between the


PICmicrocontroller and computer. Programmer is necessary to transfer the source code
(.hex file) into the microcontroller.

This experiment shows three different ways on how to load the .hex file to the
PICmicrocontroller by using three different types of Programmer’s Kit: Parallel
Programmer, Serial Programmer, and PIC Start Plus.

The Parallel Programmer is a low cost programmer that can be found in number
of electronic stores in Manila. Usually it has associated driver when you purchase it.
There are two freeware software that can be used to drive the Parallel
Programmer, these are, Oshon Soft and PICALL. These two drivers can be downloaded
for free from the following websites; www.oshonsoft.com and www.picallw.com
respectively. But to prevent software conflict, it is recommended to install only one
software, either oshonsoft or picall.

2nd Edition (Evaluation Copy) Prepared by: Engr. Emmanuel T. Longares, PECE 10
The Serial Programmer used in this experiment was constructed based on the
schematic diagram that has downloaded from http://feng3.cool.ne.jp/en/pg5v2.html. The
Serial Programmer is also called Multi PIC Programmer 5V2 and it was developed by
Feng. It is capable of programming 8-pin to 40 pin devices using single ZIF socket [2].
The driver of Serial Programmer is called icprog. The icprog is a third party software
like PICALL and Oshon Soft. It can be downloaded from www.ic-prog.com.

The PICSTART Plus Programmer is product of Microchip Inc. and does not
require third party drivers. The source code can load directly into the PICmicrocontroller
using MPLAB IDE.

MATERIALS/COMPONENTS:
PIC16F84A - 1 piece
4 Mhz Crystal Oscillator - 1 piece
10KOhm resistor (1/4W) - 2 pieces
360Ohm resistor (1/4W) - 3 pieces
Light Emitting Diode (LED) - 3 pieces
Tact Switch - 1 piece

EQUIPMENT:
Computer with installed MPLAB IDE V.8.33
Programmer
Power Supply

TOOLS:
Breadboard
IC Puller
Connecting Wires
Cutter and Long Nose

2nd Edition (Evaluation Copy) Prepared by: Engr. Emmanuel T. Longares, PECE 11
PROCEDURE:

Part 1: Parallel Port Programmer

a. If your Programmer is the one with parallel connector like in Figure 2.1,
connect it to your computer’s parallel port before turning on the computer.
Otherwise proceed to Part 2.

Figure 2.1: Parallel Port Programmer

b. Turn on the power supply and adjust it to 20Vdc. Connect the positive
terminal of power supply to color pink wire of programmer and negative
terminal to the color gray. Make sure that the power supply is connected in
the correct terminals of programmer to prevent possible damage to the
device.

c. Open the MPLAB IDE software. Using the project wizard, choose PIC16F84A
as the device.

2nd Edition (Evaluation Copy) Prepared by: Engr. Emmanuel T. Longares, PECE 12
d. Create a folder and named it as “Expt_2.1”. Name your project as “LED1”.
Save and place it to Expt_2.1 folder.

e. Compile the copied PIC16F84A template using Ctrl F10 of your keyboard.
Make sure that the template is working properly before proceeding to the next
step.

f. Type the given source code written below.


;**********************************************************************
; Filename: Driving a LED.asm
; File Version: 1
;**********************************************************************
list p=16F84A ; list directive to define processor
#include <p16F84A.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
INT_VAR UDATA 0x0C
w_temp RES 1 ; variable used for context saving

status_temp RES 1 ; variable used for context saving

;**********************************************************************
RESET_VECTOR CODE 0x000 ; processor reset vector
goto start ; go to beginning of program
MAIN CODE
start
; remaining code goes here
nop ; "nop" is Required for Emulators

bsf STATUS, RP0 ; Goto Bank 1 to set Port Direction


bcf TRISB,0 ; Set RB0 to Output
bcf STATUS, RP0 ; Go back to Bank 0

clrf PORTB

bsf PORTB, 0 ; Make the LED of PORTB.0 "ON"

goto $

2nd Edition (Evaluation Copy) Prepared by: Engr. Emmanuel T. Longares, PECE 13
END ; directive 'end of program'
g. Compile the source code. Once compiled successfully, double click the
PICALL icon in your desktop. In the three arrow down buttons of PICALL,
choose PIC16PRO, microchip, and PIC16F84A.

h. In the main menu of PICALL, click Settings>Hardware Set-up. A pop-up


window PIC16PRO Setting and Testing shall appear. Then click the P16PRO
74LS05, 6-KIT 96 and click Ok.

i. Again in the main menu of PICALL, click the File and click Open Program.
Go to your Expt_2.1 folder and open your LED1.hex file. Place your
PIC16F84A IC to the Programmer. Make sure that it is placed properly in
correct position. Then, click config and choose the XT. Click the Program
button in the PICALL and a message “program load successfully in
xseconds” shall appear.

j. Turn off the power supply of Programmer. Using IC puller, remove the
PIC16F84A.

k. Using your tools and materials, construct the circuit shown in Figure 2.2.

VCC
5V

U1
10k Ω R2 17 RA0 VDD 14 R1
18 RA1 RB0INT 6
1 RA2 RB1 7
2 RA3 RB2 8 360Ω
3 RA4T0CKI RB3 9
RB4 10
4 MCLR RB5 11
16 OSC1CLKIN RB6 12
RB7 13
5 VSS OSC2CLKOUT 15

P IC16F84A

4MHz Crystal Osc.

Figure 2.2: Turning ON a LED using PIC16F84A

2nd Edition (Evaluation Copy) Prepared by: Engr. Emmanuel T. Longares, PECE 14
l. Supply your circuit with 5Vdc. The LED at PORTB0 (pin 6) must light. If not,
check your connections. Make sure that there is no loose connection.

Part 2: Serial Port Programmer

a. If your Programmer is the one with serial connector like in Figure 2.3, connect
it to your computer’s serial port before turning on the computer. Otherwise,
proceed to Part 3.

FIGURE 2.3: Serial Port Programmer

b. Turn the two switches of Serial Port Programmer to the direction indicated in
Figure 2.3.

c. Place the PIC16F84A to the Serial Programmer as shown in Figure 2.4.

Note: In placing the PIC16F84A in the programmer, leave one slot as pointed by
the ball pen shown in figure 2.4.

2nd Edition (Evaluation Copy) Prepared by: Engr. Emmanuel T. Longares, PECE 15
FIGURE 2.4: PIC16F84A Orientation in Serial Port Programmer

Note: The orientation of pins must be similar in figure 2.5. Pin 1 is the one
pointed by the ball pen.

Figure 2.5: Pin Orientations of PIC16F84A

2nd Edition (Evaluation Copy) Prepared by: Engr. Emmanuel T. Longares, PECE 16
d. Compile the source code. Once compiled successfully, click the icprog icon
in your desktop. In the icprog menu, click the open and locate your LED1.hex
file. In the arrow down list of action tool bar, choose the PIC16F84A. Choose
XT in the arrow down list of Oscillator.

e. Click the Program All of action tool bar.

f. Using your tools and materials, construct the circuit shown in Figure 2.2.

g. Supply your circuit with 5Vdc. The LED at PORTB0 should light. If not, check
your connections. Make sure that there is no loose connection.

Part 3: PICSTART Plus Programmer

a. If your Programmer is the one with serial connector like in Figure 2.5, connect
it to your computer’s serial port before turning on the computer.

Figure 2.5: PICSTART PLUS Programmer

2nd Edition (Evaluation Copy) Prepared by: Engr. Emmanuel T. Longares, PECE 17
b. Type the source code given in Part 1.f.

c. Compile the source code. Once compiled successfully, in the MPLAB menu
click the debugger>select tool>none.

d. Again in the MPLAD IDE menu, click the Programmer>Select


Programmer>PICSTART Plus. Click the Programmer of MPLAB menu and
click Enable Programmer.

e. Unlock or unzip the PICstart Plus. Place the PIC16F84A to the IC holder and
lock it. Make sure that the IC is placed in the correct orientation before
proceeding to the next step.

f. Load the source code. This can be carried out by clicking the Programmer of
MPLAB menu and click Program.

g. Using your tools and materials, construct the circuit shown in Figure 2.2.

h. Supply your circuit with 5Vdc. The LED at PORTB0 should light. If not, check
your connections. Make sure that there is no loose connection.

Part 4: Exercises

a. Modify the source code given in Part 1 such that a LED at PORTB 5 light.
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________

2nd Edition (Evaluation Copy) Prepared by: Engr. Emmanuel T. Longares, PECE 18
________________________________________________________________
________________________________________________________________

b. Modify the source code given in Part 1 such that PORTB0 to PORTB3 light.

________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________

SUMMARY:
________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________

2nd Edition (Evaluation Copy) Prepared by: Engr. Emmanuel T. Longares, PECE 19
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________

CONCLUSION:
________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
____________________________________________________________________

RECOMMENDATION:
________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________

2nd Edition (Evaluation Copy) Prepared by: Engr. Emmanuel T. Longares, PECE 20
REFERENCES:

 Mano, M. Digital Design 4th ed. Singapore: Pearson Education, Asia, 2007

 Bartee, T. Computer Architecture and Logic Design. New Jersey: John Wiley &
Sons, 2004

 M. Predko, Programming and Customizing PICmicro MICROCONTROLLERS


2nd Edition, McGrawHill Companies Inc., USA, 2002

 F. Valdez-Perez and R. Pallas-Areny, Microcontrollers Fundamentals and


Application with PIC, CRC Press, Taylor and Francis Group, USA, 2009

 J. Sanches and M. P. Canton, Microcontroller Programming – The Microchip


PIC, CRC Press, Taylor and Francis Group, USA, 2007

 D.W. Smith, PIC in Practice, Dave Smith, Elsevier Ltd.,UK, 2006

 R.L. Tokheim, Digital Electronics Principles and Applications 6 th Edition,


McGraw-Hill Companies Inc. USA, 2003

 PIC16F84a Datasheet.pdf

 http://www.microchip.com

 http://www.picallw.com

2nd Edition (Evaluation Copy) Prepared by: Engr. Emmanuel T. Longares, PECE 21

You might also like