Файл: Microcontroller Programming. Thi Micro Chip PIC (Julio Sanchez, 2007).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 14.06.2025
Просмотров: 8599
Скачиваний: 0
The Microchip PIC |
131 |
Figure 7-1 USB PIC Programmer by MicroPro
PIC Programmers
The development system (assembler or compiler) and the programmer driver are the software components. The computer, programmer, and connectors are the hardware elements. Figure 7-1 shows a commercial programmer that connects to the USB port of a PC. The one in the illustration is made by MicroPro.
Many other programmers are available on the market. 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. Some PICs can write to their own program memory. This makes possible the use of so-called bootloaders, which are small resident programs that allow loading user software over the RS-232 or USB lines. Programmer/debugger combinations are also offered by Microchip and other vendors.
Development Boards
A development board is a demonstration circuit that usually contains an array of connected and connectable components. Their main purpose is as a learning and experimental tool. Like programmers, PIC development boards come in a wide range of prices and levels of complexity. Most boards target a specific PIC microcontroller or a PIC family of related devices. Lacking a development board the other option is to build the circuits oneself, a time-consuming but valuable experience. Figure 7-2 (in the following page) shows the LAB-X1 development board for the 16F87x PIC family.
The LAX-X1 board, as well as several other models, is a product of microEngineering Labs, Inc. Some of the sample programs developed for this book were tested on a LAB-X1 board. Development boards from Microchip and other vendors are also available.
132 |
Chapter 7 |
Figure 7-2 LAB-X1 Development Board
7.0.2 Prototyping the PIC Circuit
Very few of us are satisfied with writing a PIC program and assuming that it works correctly. Testing software is a simple matter if there happens to be a development board at hand, if the board is compatible with the PIC, and if it provides the hardware that we need to test. 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.
Breadboarding a prototype circuit is one of the options. A breadboard is a reusable, solderless 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. Wire jumper kits provide connectors of different lengths and colors for making the circuit connections on the breadboard. For complex circuits several breadboards can be easily interconnected. Figure 7-3 shows two interconnected breadboards used to test one of the programs developed for this book.
The Microchip PIC |
133 |
Figure 7-3 Circuits in Two Interconnected Breadboards
Once a circuit and the software have been tested, there are several available technologies for building a more permanent prototype. These include wire wrap, stripboards, 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. A PCB is used to mechanically support the electronic components and provides conductive pathways, called traces, that implement the circuit. The components are soldered to the PCB board using either surface mount or through-the-board technology. The PCB board is made of a non-conductive material and the conductive pathways are etched out of copper sheets laminated on one or both sides of the board. 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. Appendix B describes one technique that has been used successfully. Figure 7-4, in the followng page, shows a drawing of both sides of a simple PCB board.
134 |
Chapter 7 |
|
+9-12v |
Gnd |
||||||||||||
C2 |
C1 |
||||||||||||
R9 |
|||||||||||||
1 |
|||||||||||||
6 |
|||||||||||||
F |
|||||||||||||
8 |
|||||||||||||
4 |
|||||||||||||
O1
Led Flasher 1.0
R1 L1
R2
L2
R3 L3
R4 L4
R5
L5
R6
L6
R7
L7
R8 L8
Figure 7-4 Drawing for Etching a PCB Board
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. Refer to Appendix B for details on designing and building PCBs at the amateur level.
Several firms on the Internet offer PCB prototyping services from the circuit diagrams. In some cases the advertised turnaround time is a couple of days. One of these companies furnishes software tools for drawing the PCB in a format that they can use directly in manufacturing the prototypes. Googling “PCB prototypes” produces many hits.
7.1 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 subclassification 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. In the following subsections we describe the basic characteristics of the various subgroups of the three major PIC families with 8-bit architectures.
7.1.1 Baseline PIC Family
This group includes members of the PIC10, PIC12, and PIC16 families. 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 bat- tery-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. The following types are in the Baseline group.
The Microchip PIC |
135 |
PIC10 Devices
The PIC10 devices are low-cost, 8-bit, flash-based CMOS microcontrollers. They use 33 single-word, single-cycle instructions (except for program branches, which take two cycles). The instructions are 12-bits wide. The PIC10 devices feature power-on reset, an internal oscillator mode that saves having to use ports for an external oscillator. They have a power-saving SLEEP mode, a Watchdog Timer, and optional code protection.
The recommended applications of the PIC10 family range from personal care appliances and security systems to low-power remote transmitters and receivers. The PICs of this family have a small footprint and are manufactured in formats suitable for both through-hole and surface mount technologies. Table 7.1 summarizes the characteristics of PIC10 devices.
Table 7.1
PIC10F Devices
10F200 |
10F202 |
10F204 |
10F206 |
|
Clock: |
||||
Maximum Frequency |
||||
of Operation (MHz) |
4 |
4 |
4 |
4 |
Memory: |
||||
Flash Program |
||||
Memory |
256 |
512 |
256 |
512 |
Data Memory (bytes) |
16 |
24 |
16 |
24 |
Peripherals: |
||||
Timer Module(s) |
TMR0 |
TMR0 |
TMR0 |
TMR0 |
Wake-up from Sleep |
Yes |
Yes |
Yes |
Yes |
Comparators |
0 |
0 |
1 |
1 |
Features: |
||||
I/O Pins |
3 |
3 |
3 |
3 |
Input Only Pins |
1 |
1 |
1 |
1 |
Internal Pull-ups |
Yes |
Yes |
Yes |
Yes |
In-Circuit Serial |
||||
Programming |
Yes |
Yes |
Yes |
Yes |
Instructions |
33 |
33 |
33 |
33 |
Packages: |
6-pin SOT-23
8-pin PDIP
Two other PICs of this series are the 10F220 and the 10F222. These versions include four I/O pins and two analog-to-digital converter channels. Program memory is 256 words on the 10F220 and 512 in the 10F222. Data memory is 16 bytes on the F220 and 23 in the F222.
PIC12 Devices
The PIC12C5XX family are 8-bit, fully static, EEPROM/EPROM/ROM-based CMOS microcontrollers. They use RISC architecture and have 33 single-word, single-cycle instructions (except for program branches, which take two cycles). Like the PIC10 family, the PIC12C5XX chips have power-on reset, device reset, and internal timer. Four oscillator options can be selected, including a port-saving internal oscillator and
136 |
Chapter 7 |
a low-power oscillator. These devices can operate in SLEEP mode and have Watchdog Timer and code-protection features.
Table 7.2
PIC 12Cxxx and 12CExxx Devices
12C508(A) |
12C518 |
12CE519 |
12C671 |
12CE674 |
||
12C509A |
12C672 |
|||||
12CR509A |
||||||
Clock: |
||||||
Maximum |
||||||
Frequency |
||||||
of Operation |
||||||
(MHz) |
4 |
4 |
4 |
10 |
10 |
|
Memory: |
||||||
EPROM |
||||||
Program |
||||||
Memory |
512/1024/1024 |
512x12 |
1024x12 |
1024/2048/ |
2048x14 |
|
x12 |
1024x12 |
|||||
RAM Data |
||||||
Memory |
||||||
(bytes) |
25/41/41 |
25 |
41 |
128 |
128 |
|
Peripherals: |
||||||
EEPROM |
||||||
Data Memory |
||||||
(bytes) |
— |
16 |
16 |
0/0/16 |
16 |
|
Timer |
||||||
Module(s) |
TMR0 |
TMR0 |
TMR0 |
TMR0 |
TMR0 |
|
A/D Converter |
||||||
(8-bit) |
||||||
Channels |
— |
— |
— |
4 |
4 |
|
Features: |
||||||
Wake-up |
||||||
from SLEEP |
||||||
on pin |
||||||
change |
Yes |
Yes |
Yes |
Yes |
Yes |
|
Interrupt |
||||||
Sources |
— |
— |
— |
4 |
4 |
|
I/O Pins |
5 |
5 |
5 |
5 |
5 |
|
Input Pins |
1 |
1 |
1 |
1 |
1 |
|
Internal |
||||||
Pull-ups |
Yes/Yes/No |
Yes |
Yes |
Yes |
Yes |
|
In-Circuit |
||||||
Serial |
||||||
Programming |
Yes/No |
Yes |
Yes |
Yes |
Yes |
|
Number of |
||||||
Instructions |
33 |
33 |
33 |
35 |
35 |
|
Packages |
8-pin DIP |
8-pin DIP |
8-pin DIP |
8-pin DIP |
8-pin DIP |
|
SOIC |
JW,SOIC |
JW. SOIC |
SOIC |
JW |
||
The PIC12C5XX devices are recommended for applications including personal care appliances, security systems, and low-power remote transmitters and receivers. The internal EEPROM memory makes possible the storage of user-defined codes and passwords as well as appliance setting and receiver frequencies. The various packages allow through-hole or surface mounting technologies. Table 7.2 lists the characteristics of some selected members of this PIC family.
Two other members of the PIC12 family are the 12F510 and the 16F506. In most respects these devices are similar to the other members of the PIC12 family previously described, except that the 12F510 and 16F506 both have flash program memory. Table 7.3 lists the most important features of these two PICs.