Projects - Introduction to the PIC 16F84

The PIC 16F84 is an 18 pin IC produced by Microchip Technology Inc.. It is just one IC in a large selection of programmable interface controllers that Microchip produce which are essentially self-contained CPUs complete with RAM and ROM.

I deal specifically with the 16F84 because it's cheap (I get them from Crownhill, where they're a couple of UK pounds a throw). Not to mention the fact that it's dead easy to program, is relatively powerful and is virtually indistructable (so far I've only managed to kill one, and that was only because it found its way under the wheels of my chair :)

The 16F84 is CMOS based, fully static (so you can happilly stop the clock and it'll carry on from where it left off when you start it again). It can be programmed in under a minute and just as easily reprogrammed electronically by simply writing your code to the flash RAM. It even features in-circuit programming, so you don't even need to unplug the processor from your circuit to update your firmware. Each instruction word is 14 bits long, and you can load the flash with up to 1K instructions. It also has 64 bytes of data EEPROM which can be programmed and read from both the programmer and the code, allowing persistant data to be kept safe whilest it is powered down. There is also 68 bytes of data RAM for storing runtime data (presented as a large set of registers, so there is no need to load/store), 13 I/O pins for interfacing external components, timer, counter and watchdog.

The architecture is of Harvard design - two completely separate instuction and data memories and busses, featuring a two-stage pipeline. The RISC instruction set consists of 35 instructions, most of which take a single cycle each (branches take 2 cycles since they have to flush the pipeline).

Another major advantage of this processor is the number of external components required for a fully operational circuit - the only component strictly necessary is the external clock, which can consist of a resistor and a capacitor for low clock speeds. By using a crystal and a pair of capacitors instead, the chip can be run at up to 10MHz (2.5 million instructions per second), although 4MHz is usually fine for most operations. Of course it's usually a good idea to put a capacitor across the power rails as close to the chip as possible to remove noise whcih can reduce stability.

Microchip provide all the specs and the assembler/programmer software for Windows. Although, if like me you would prefer to work under a vaguely sensible OS like Linux, there are plenty of third-party assemblers and programmers available (take a look at GNUPIC for some links). There are even some compilers for C and other languages available, although their use is debatable - for tight code that you can guarantee the timing on, you really need to program in assembler.

Contact Me
Site last updated: 26th June, 2013