Embedded Systems

PIC16F84 Microcontroller Features

PIC16F84 belongs to a class of 8-bit microcontrollers of RISC architecture (i.e. microcontrollers with Reduced Instruction Set Computer). This is a low cost Microchip microcontroller with EEPROM flash memory for program and data storage. It has no built-in Analog to Digital converter (A/D) and Digital to Analog converter (D/A) or serial communication capability.

Other PIC microcontrollers that are pin compatible with the PIC16F84 include PIC16F84A, PIC16F88 and PIC16F819. These three microcontrollers (plus others) can be programmed to represent the PIC16F84. The key differences that distinguish the three mentioned microcontrollers from the PIC16F84 include:

  • The PIC16F84A, PIC16F88 and PIC16F819 can be run at faster clock speeds of up to 20 MHz.
  • The PIC16F88 and PIC16F819 have internal oscillators that can provide the clock signal without the external components permitting more I/O lines.
  • PIC16F88 and PIC16F819 microcontrollers have more memory and additional software-configurable functionality like on-board comparators and pulse-width modulation generators.
  • Lastly the PIC16F88 and PIC16F819 have software-configurable A/D converters, which allow one to interface the PIC to analog sensors that output a continuously varying voltage rather than a digital signal.

A block diagram of the PIC16F84 microcontroller is shown below:

PIC16F84 Block Diagram
Figure 1.0 PIC16F84 Block Diagram. Image Source: Microchip Technology, Inc.

The PIC16F84 is an 8-bit CMOS microcontroller with 1792 bytes of flash EEPROM program memory, 68 bytes of RAM data memory, and 64 bytes of non-volatile EEPROM data memory. The 1792 bytes of program memory are subdivided into 14-bit words, because machine code instructions are 14 bits wide. Hence, the EEPROM can hold up to 1024 (1 k) instructions i.e.  (1792 x 8)/14 = 1024. The PIC16F84 can be driven at a clock speed up to 10 MHz however; it is typically driven at 4 MHz. The microcontroller is referred to as 8-bit because the data bus is 8 bits wide, and all data processing, storage and retrieval is accomplished using bytes.

Related: Basic Structure of Microcontroller

When we compile a program and download it to a PIC, it is stored as set of binary machine code instructions in the flash program memory. These instructions are sequentially fetched from memory, placed in the instruction register and executed. Each instruction corresponds to a low-level function implemented with logic circuits on the chip. For instance, an instruction might load a number stored in RAM or EEPROM into the working register, which is termed to as the W register or accumulator; the next instruction might command the Arithmetic Logic Unit (ALU) to add a different number to the value in this register, and the next instruction might return the summed up value to the memory. Since an instruction is executed every four clock cycles, the PIC16F84 can do calculations, read input values, store and retrieve information from memory, and perform other functions very fast. With a clock speed of 4 MHz, an instruction is executed every microsecond and 1 million instructions can be executed every second.

A special purpose timer, called watch-dog timer is included in PIC microcontrollers. This is a count-down timer that, when activated, needs to be continually reset by the running program. If the program fails to reset the watch-dog timer before it counts down to 0, the PIC will automatically reset itself. In critical application, the feature can be used to reset the microcontroller if the software gets caught in an unintentionally endless loop.

The Ram, which provides a space for storing data, also maintains a set of special purpose byte-wide locations called file registers. The bits in these registers are used to control the function and indicate the status of the microcontroller.

PIC16F84 is packed on an 18-pin DIP IC that has the pin schematic or pinout as illustrated below:

Figure 1.1 PIC16F84 pinout and the needed external components

The figure above shows the minimum set of external components recommended for PIC to function properly.

Related: Microprocessor vs Microcontroller, What are the Differences?

The table below shows the pin identifiers in natural groupings along with their descriptions:

Pin IdentifierDescription
RA[0-4]5 bits of bidirectional I/O (PORTA)
RB[0-7]8 bits of bidirectional I/O (PORTB)
Vss, VddPower supply ground reference
OSCI, OSC2Oscillator crystal inputs
MCLRMaster clear (active low)

The five pins (RA0 through RA4) are digital I/O pins collectively referred to as PORTA, and the eight pins RB0 through RB7 are digital I/O pins collectively termed to as PORTB. In aggregate, there are 13 I/O lines, called bidirectional lines because each can be individually configured in software as an input or output. PORTA and PORTB are special purpose file registers on the PIC that provide the interface to the I/O pins. Even though all PIC registers contain 8 bits, only the 5 least significant bits (LSBs) of PORTA are used.

Don’t miss out on key updates, join our newsletter  List

A key feature of the PIC, that is available with most microcontrollers, is its ability to process interrupts. An interrupt occurs when a specially designated input changes state. When this happens, normal program execution is suspended while a special interrupt handling portion of the program is executed. On the PIC16F84, pins RB0 and RB4 through RB7 can be configured as interrupt inputs.

The power and ground are connected to the PIC through pins Vdd and Vss. The dd and ss subscripts refer to the drain and source notation used for MOS transistors since a PIC is a CMOS device. The voltage levels i.e. Vdd = 5 V and Vss = 0 V can be provided using a DC power supply or batteries e.g. 9 V battery connected through a voltage regulator.

The master clear pin (MCLR) is active low and provides a reset feature. Grounding this pin causes the PIC to reset and restart the program stored in EEPROM. This pin must be held high during the normal program execution. This is achieved with the pull-up resistor as illustrated in the Figure 1.1 above. If this pin is left unconnected (floating), the chip might reset itself intermittently. To provide a manual reset feature to a PIC design, NO (normally open) push button can be added. Closing the switch grounds the pin and causes the PIC to reset. This is illustrated in the figure below:

Figure 1.2 PIC manual reset switch circuit

The PIC clock frequency can be controlled using different techniques, including an external RC circuit, an external clock source or a clock crystal. In Figure 1.1 we have used the clock crystal to provide an accurate and stable clock frequency. The clock frequency is set by connecting a 4-MHz crystal across the OSC1 and OSC2 pins with the 22 pF capacitors grounded.

Applications of PIC16F84 microcontroller

PIC16F84 has a number of uses, for example:

  • It is used in industrial instruments, remote sensors, electrical door locks and safety devices.
  • It is used for controlling home appliances.
  • EEPROM memory makes it a best choice for devices where permanent storage of various parameters is required (codes for transmitters, motor speed, receiver frequencies, etc.).
  • It is ideal for smart cards applications as well as for battery powered devices because of its low power consumption.

Also read: What is a Mechatronics System?

Share
John Mulindi

John Mulindi is an Industrial Instrumentation and Control Professional with a wide range of experience in electrical and electronics, process measurement, control systems and automation. In free time he spends time reading, taking adventure walks and watching football.

View Comments

Recent Posts

What to Expect from PCB Assembly Services in China

The importance of printed circuit board (PCB) technology has escalated throughout the years with the…

23 hours ago

Magneto-Optic Current Sensors for High Voltage, High Power Transmission Lines

One of the key challenges in measuring the electrical current in high voltage, high power…

3 days ago

How the Wiegand Effect is used in Sensing Instruments

The Concept behind Wiegand Effect Based Sensors   The Wiegand effect technology employs the unique…

5 days ago

Piezoelectric Accelerometer: Principle of Operation & Applications

An accelerometer is a sensor that is designed to measure acceleration or rate of change…

6 days ago

The USB-6009 Data Acquisition Card Features

The USB-6009 is a small external data acquisition and control device manufactured by National Instruments…

1 week ago

How X-Y Tables are used in Position Control Applications

X-Y tables are utilized as components in many systems where reprogrammable position control is desired.…

1 week ago