The photo shows a PIC16F84 microprocessor board tethered, by ribbon cable, to a circuit having 8 LEDs and an 8-position DIP switch. Learning a microprocessor’s capabilities often demands such a setup where LEDs turn on/off, blink at desired rates and respond to switches. This tutorial serves to quickly accelerate your PIC16F84 development ambitions.
Motivation and Audience
An embedded micro like the PIC16F84 is a 18-pin chip that can serve as the “brains” behind your project; the PIC can be outfitted with sensors and decide whether devices like motor and relays should be activated.
Like other micros, the PIC16F84 has a large and loyal following. There are many articles written on it both in print and on-line as well as several books. So why this tutorial? Much of the literature either provides too much or too little information. This tutorial is very focused because its purpose is to rapidly acquaint you with the fundamentals needed to develop PIC16F84-based applications. This is achieved with focused hands-on exercises exploring:
- PIC input/output (I/O) ports: LEDs are turned on and off and switches are read
- PIC timer: An LED is blinked at a desired rate
- PIC serial communication: ASCII characters are sent between a PC and PIC
Port I/O, timers and serial communications are the building blocks to construct more complex systems. Supplementing these exercises are links to additional information which can leap frog your future development endeavors. This tutorial makes the following assumptions:
- You have a PIC16F84 device programmer
- You have Microchip’s MPLAB or your device programmer came with software to “burn” HEX files to the PIC16F84
Additionally, it helps to have:
- David Benson’s book Easy PIC’n
- CCS’s C compiler if you wish to try the C programs
The tutorial breakdown is as follows:
- PIC16F84 Development Cycle Overview
- PIC16F84 Port Input/Output
- PIC16F84 Timer
- Example 5: timer1_0.asm blinks an LED at a desired rate
- Serial communication
- Where To Go From Here
PIC16F84 Development Cycle Overview
The PIC16f84 is an 18-pin 14-bit embedded micro featuring electronically erasable programmable read-only memory (EEPROM). The essential steps are:
Step 1: On a PC, type the program, successfully compile it and then generate the HEX file. Step 2: Using a PIC16F84 device programmer, upload the HEX file into the PIC16F84. This step is often called "burning". Step 3: Insert your PIC16F84 into your circuit, power up and verify the program works as expected. This step is often called "dropping" the chip. If it isn't, you must go to Step 1 and debug your program and repeat burning and dropping.
Embedded micros having EPROM versus those with EEPROM require a fourth step – the program must be erased using ultraviolet light before starting again at Step 1. However the PIC16F84 uses EEPROM and is what makes it popular – the device programmer erases the program without ultraviolet light.
This tutorial assumes you have a PIC16F84 device programmer for Step 2 above. The author personally uses Microchip’s (the company that manufactures the PIC16F84) device programmer called PICStart ($199 US or educational discount price of $149). A web search reveals many 3rd party PIC16F84 device programmers ranging in prices from $50 to $200 US). They essentially are similar. PICStart can be purchased at Digikey Part Number: DV003001-ND. For the $149 educational discount phone your order 1-800-DIGIKEY.
PIC16F84 Port Input/Output
The PIC16F84 features two ports named A and B having five and eight digital lines respectively. Any line can be configured to be an input or output. Port I/O exercises is best accomplished by constructing a PIC16F84-based circuit which features a ZIF socket and 0.1 inch headers. The parts list, schematic and construction details follow.
US-based vendors include Jameco, Digikey, JDR and Radio Shack. Note: Boondog has no association with these vendors. Attempts were acquire all parts from a single vendor. Part numbers for common resistors are not given.
|PART DESCRIPTION||VENDOR||PART||PRICE (2002)||QTY|
|40-PIN ZIF SOCKET||JAMECO||104029||10.95||1|
|8-POSITION DIP SWITCH||JAMECO||38842||0.79||1|
|4 MHZ CRYSTAL CLOCK OSCILLATOR||JAMECO||27967||1.89||1|
|0.1 UF CAP||JAMECO||151116||1.00 FOR BAG OF 10||1|
|0.1 INCH HEADERS||JAMECO||160881||0.39||1|
|SIPP 30-PIN WIREWRAP SOCKET||JAMECO||104053||1.95||1|
|T1-3/4 GREEN LED||JAMECO||104256||0.29||1|
|100 OHM RESISTOR||1|
|10 KILO OHM RESISTOR||1|
|220 OHM RESISTOR||9|
|3.3 KILO OHM RESISTOR||8|
|6 INCH PROTOTYPING CIRCUIT BOARD||RADIO SHACK||276-170||2.99||1|
|2-3/4 X 3-3/4 PROTOTYPING CIRCUIT BOARD||RADIO SHACK||276-158||2.39||1|
An effort was made to find a single source supplier of all parts. Jameco has every part cited in the table – Neighborhoold Radio Shacks typically have the proto boards in stock and are comparatively cheaper than similiar boards from Jameco.
Part connection methods and part locations are not critical. The left photo below shows a part layout that works well. The right photo shows a combination of wire wrapping and soldering can be used to construct the PIC16F84 LED/DIP circuit.
For more detail: PIC16F84 Fundamentals
EasyEDA: Ideas for Circuit Design, Innovation for Electronics Access
Free Circuit Design: Schematic – Simulation – PCB Layout – Gerber Viewer
JLCPCB Prototype: Only $2 for 10pcs 10×10cm, 24 hours Quick Turn, DHL Delivery in 3 days
Current Project / Post can also be found using:
- easy picn