The PIC microcontroller 16F84A Microchip


Presentation
The IC manufacturer Microchip has developed and manufactured a very wide range of microcontrollers.
Among them, the PIC 16F84A.
This microcontroller has spread very quickly, and remains today one of the most used in the world of amateur electronics.

Why: probably for many reasons:
·       ease of implementation of the component
·       easy programming thanks to a limited instruction set (35)
·       free (or almost) tools and programmers
·       low component cost
So that currently there is a multitude of kit or assembly using them: a simple chaser to control LEDs and thus illuminate the Christmas tree, up to LCD and DDS control for HF receivers.

The PIC 16F84A is in the form of 2 different types of housings.
The classic "through" DIP18, or 2 versions CMS (SOIC 18 and SSOP20). The classic DIP18 version has the advantage of using simple 18-point support for its programming and implementation. The maximum frequency is given at 20Mhz, ie 1 clock cycle of 50ns and a time per instruction of 4x50ns or 200ns. Indeed each instruction requires 4 clock cycles of the CPU to be executed. Attention, it also depends on the type of instructions: for that see the summary table of the instruction set of the component. Version 18 pins top view

PIC microcontroller


The PIC 16F84 is powered by DC voltage between 2 and 5V for commercial and industrial versions, VSS (pin 5) and VDD (pin 14).
It possesses 2 pins for the clock noted OSC1 and OSC2: one will place the quartz between these 2 legs, or the exit of an oscillator on the between OSC1 / CLKIN. We find 2 ports A and B: the port B is composed of 8 input outputs (IO configurable by software) and a port A composed of 5 inputs only. In all the number of input outputs is 5 + 8 = 13. Each of these input outputs can power an LED and the maximum available current is given less than 25mA. For driver components requiring more than this current, it will then think of placing an external driver.


It has a flash memory area to store the program (1024 words), a ram area (68 bytes) for variables and an EEprom area (64 bytes) to store nonvolatile data that will be stored after a break power.
The instruction game remains limited. This makes it easy to program the microcontroller directly in assembler. However, many examples are available in C. The cycle number column shows that some instructions may have a longer execution time. When designing the software, we will have to take it into account to adjust timings, for example. The right column shows the registers or bits of these registers impacted by the instruction call:

·       TO (Time Out)
·       PD (Power Down)
·       C (Carry) is the restraint, or the detection of an overflow (255 + 1 for example)
·       Z (Zero) is active at 1 if the result of the instruction is 0
·       DC (Digital Carry) goes to 1 if we have an overflow of the last 4 bits
Note: all these bits are located in the status register at address 0x03 (3 in hexadecimal).

All addresses have their "coordinates" written in hexadecimal. We will not describe in detail all the registers in this article which is only a presentation of the 16F84A. We notice that the memory is organized in 2 banks. The RAM starts from the 0Ch address (12 in decimal) on 68 bytes. The configuration registers are placed between the address 00h and 0Bh included. We find the status register in 03h.

Implementation
The implementation remains quite simple:
·       provide a 5V power supply, with a linear voltage regulator, some capacitors for decoupling and filtering
·       provide a quartz between 32kHz and 20Mhz and its 2 foot capacitors (see in the specifications of the component to find the appropriate values ​​depending on the frequency.
·       provide a programmer
We will weld an 18-point bracket to a hole plate and we will avoid soldering the PIC directly on the PCB in order to develop the software. This will replace the component in case of breakage.

Comments