Professional Documents
Culture Documents
Some are general-purpose devices but most microcontrollers are used in specialized
systems such as washing machines, telephones, microwave ovens, automobiles, and
weapons of many kinds.
A microcontroller usually includes a central processor, input and output ports, memory
for program and data storage, an internal clock, and one or more peripheral devices
such as timers, counters, analog-to-digital converters, serial communication facilities,
and watchdog circuits.
More than two dozen companies in the world manufacture and market
microcontrollers.
They range from 8- to 32-bit devices. The most popular ones include several from Intel
(such as the 8051), Zilog (derivatives of their famous Z-80 microprocessor), Motorola
(such as the 68HC05), Atmel (the AVR), Parallax (the BASIC Stamp), and Microchip.
This device was called PIC for ³Programmable Intelligent Computer´ although it is now
associated with ³Programmable Interface Controller.´
PICs use an instruction set that varies in length from about 35 instructions for the low-
end PICs to more than 70 for the high-end devices.
The accumulator, which is known as the work register in PIC documentation, is part of
many instructions since the PIC contains no other internal registers accessible to the
programmer.
One of the reasons for the success of the PIC is the support provided by Microchip.
c
This includes a professional-quality development environment called MPLAB which
can be downloaded free from the company¶s website ().
The Microchip website furnishes hundreds of free support documents, including data
sheets, application notes, and sample code.
3. A hardware device called a programmer that connects to the computer through the
serial, parallel, or USB line. The PIC is inserted in the programmer and ³blown´ by
downloading the executable code generated by the development system.
5. A PIC microcontroller.
PIC Programmers
ë
åigure 7-1 USB PIC Programmer by MicroPro
Microchip offers several high-end models with In Circuit Serial Programming (ICSP) and
Low Voltage Programming (LVP) capabilities. These devices allow the PIC to be
programmed in the target circuit.
Development Boards
Ô
Prototyping the PIC Circuit
Very few of us are satisfied with writing a PIC program and assuming that it works
correctly.
But often one of these elements is missing and it becomes necessary to build the
circuit for which the program was designed. Here again, there are several options.
These range from having the circuit built for us by a professional engineering firm, to
using a breadboard to prototype the circuit ourselves.
A breadboard is a reusable, solder less device that allows building a prototype circuit,
usually for temporary use.
Breadboards have strips down one or both sides that are used as power rails. One
strip carries the circuit¶s positive voltage and the other one is wired to the ground of the
power supply.
Figure 7-3 shows two interconnected breadboards used to test one of the programs
developed.
Î
Once a circuit and the software have been tested, there are several available
technologies for building a more permanent prototype.
These include wire wrap, strip boards, and several other circuit board building tools
and techniques, including prototyping boards specially designed for PIC circuits.
Finally, one can build a semi-professional quality printed circuit board (called a PCB)
and solder the components to it.
The components are soldered to the PCB board using either surface mount or
through-the-board technology.
Once the board has been populated with electronic components it becomes a printed
circuit assembly, or PCA.
Industrial quality PCB boards are suited to high-volume production. The circuits of the
development board in Figure 7- 2 are on a commercial PCB.
Building one¶s own PCB is quite possible and requires few tools and resources. Figure
7-4, shows a drawing of both sides of a simple PCB board.
0
The PCB in Figure 7-4 is intended for a copper-plated single-sided blank. The left-side
image shows the actual circuit that is etched on the copper side of the board. The text
and diagrams on the right-hand image are engraved (usually by silk screening) on the
back side of the board and serve as a guide for welding the components.
PIC Architecture
PIC controllers are roughly classified by Microchip into three groups: baseline, mid-
range, and high-performance.
Within each of the groups the PICs are classified based on the first two digits of the
PIC¶s family type. However, the sub-classification is not very strict, since there is some
overlap.
For this reason we find PICs with 16X designations that belong to the baseline family
and others that belong to the mid-range group.
This group includes members of the PIC10, PIC12, and PIC16 families. Examples:
10F200, 12C518, 16F506.
The devices in the Baseline group have 12-bit program words and are supplied in 6- to
28-pin packages.
The microcontrollers in the baseline group are described as being suited for battery-
operated applications since they have low power requirements.
The typical member of the Baseline group has a low pin count, flash program memory,
and low power requirements.
u
Mid-range PIC åamily
The mid-range PIC family includes members of the PIC12 and PIC16 groups.
According to Microchip, the mid-range PICs all have 14-bit program words with either
flash or OTP program memory.
Those with flash program memory have EEPROM data memory and support
interrupts.
Some members of the mid-range group have USB, I2C, LCD, USART, and A/D
converters.
Implementations range from 8 to 64 pins. In the following subsections the basic
characteristics of some mid-range PICs are listed.
PIC16 Devices
This is by far the most extensive PIC family. Currently, over 80 versions of the PIC16
are listed in production by Microchip.
The remainder of this book is devoted to programming two of these PICs: the 16F84
and the 16F877.
Here we listed a few of the most prominent members of the PIC16 family and their
most important features.
-
High-Performance PIC åamily
They have 16-bit program words, flash program memory, a linear memory space of up
to two Mbytes, and protocol-based communications facilities.
They all support internal and external interrupts and have a much larger instruction set
than members of the baseline and mid-range families.
PIC18 Devices
The PIC18 family is also a large one, with over 70 different variations currently in
production.
The PIC18 family uses 16-bit program words and is furnished in 18 to 80 pin
packages.
Microchip describes the PICs in this family as high-performance with integrated A/D
converters.
The PICs in this family have flash program memory, a linear memory space of up to 2
Mbytes, 8-by-8 bit hardware multiplier, and communications peripherals and protocols.
½