PIC 16F84A 16f84 Microcontroller In Pakistan
| Introduction to PIC 16F84 Microcontroller
This tutorial will walk a beginner to Microcontroller through the basic principle of the PIC family Microcontroller. Mainly focus on the 16F84 just simply because it’s simpler than other type to understand.
For those who don’t know what a Microcontroller is; It is a brain of a digital device that operates in a close loop control process. It has I/O port to take in interrupt or data and send out signal to control relay or just simply a motor or that type of mechanisms.
The close up of a Microcontroller
Pins and it’s functions
The PIC 16F84 has two ports; each can be individually program as input or output. PortA is a 5bits/lines (mostly use as input), and portB is 8 bits/lines (normally use as output). You can think of the PIC controller as a fish tank with all the water lines running in and out from it. Some of the line you will hook up to the water coming in, the other for water coming out. Remember, don’t mistake the port as a single line; the two ports are each consists of multiple lines that can be use for parallel data transfer.
Introduction to Architecture of PIC 16’
The PIC ’84 has two separate blocks of memory; Program memory and file registers memory.
PIC’84 is 14 bits and can contain 1K of code. This is important to know because you don’t want to write a lengthy program or put to much comment on to a program and it will not fit into the PIC.
you can think of this as drawer in a cabinets. Some of the drawers are reserved for special purposes. These register are located at reserve address that the designed for the PIC to recognize and have higher priority then other address when it comes to interrupt (Read on).
Below are the most basic ones
Source: “Easy Pic’n”, David Benson, p.10
In this section, I only emphasize on the important features that are necessarily to better understand this tutorial. For a more detail explanation, I suggest the book “Easy Pic’n” by David Benson
Working register: ***This concept is important*****
Picture this; you can only open one drawer of the cabinet at a time. Therefore, to copy and transfer some thing from one drawer to another, you need to have a temporary space to dump data to. To move a shirt from drawer #1 to drawer #3. We do this; open drawer #1, move shirt from drawer #1 to working register, close drawer #1, open drawer #3, move shirt from working register to drawer #3, close drawer #3.
This is the only way to move data around the PIC’s registers.
PIC controller, like many other controller; it’s execute code line by line. Let say the PIC execute line #1. How does it know to go to line #2 or jump to a section after a “goto” instruction? Well the Program counter get updated every line after the PIC goes through a line of code. It’s keep track of which part of the program to jump to next.
Status register keep record of result of operation. Two important items are Zero flag and Carry flag. Imagine this; you subtract decimal base number 5 to number 5. The result is zero. The Status register have a bit that get set to 1 if the result is Zero from any operation has just performed by the controller. Similar with the Carry bit. It detect if there is a carry after an operation