Microcontrollers High Performance Systems and Programming 1st Edition Julio Sanchez - Download the ebook today and own the complete content
Microcontrollers High Performance Systems and Programming 1st Edition Julio Sanchez - Download the ebook today and own the complete content
com
https://ebookgate.com/product/microcontrollers-high-
performance-systems-and-programming-1st-edition-julio-
sanchez/
OR CLICK BUTTON
DOWLOAD EBOOK
https://ebookgate.com/product/microcontroller-programming-the-
microchip-pic-1st-edition-julio-sanchez/
ebookgate.com
https://ebookgate.com/product/scala-high-performance-programming-1st-
edition-theron/
ebookgate.com
https://ebookgate.com/product/julia-high-performance-programming-ivo-
balbaert/
ebookgate.com
https://ebookgate.com/product/android-high-performance-
programming-1st-edition-enrique-lopez-manas/
ebookgate.com
High Performance Computing Programming and Applications
Chapman Hall CRC Computational Science 1st Edition John
Levesque
https://ebookgate.com/product/high-performance-computing-programming-
and-applications-chapman-hall-crc-computational-science-1st-edition-
john-levesque/
ebookgate.com
https://ebookgate.com/product/phase-locking-in-high-performance-
systems-from-devices-to-architectures-1st-edition-behzad-razavi/
ebookgate.com
https://ebookgate.com/product/wind-energy-in-electricity-markets-with-
high-wind-penetration-1st-edition-julio-usaola/
ebookgate.com
https://ebookgate.com/product/high-performance-and-hardware-aware-
computing-rainer-buchty/
ebookgate.com
Electrical Engineering Sanchez
Canton
Microcontrollers
HIGH-PERFORMANCE SYSTEMS
AND PROGRAMMING
Microcontrollers
Microcontrollers
Microcontrollers: High-Performance Systems and Programming
discusses the practical factors that make the high-performance PIC
series a better choice than their mid-range predecessors for most
systems. However, one consideration in favor of the mid-range
devices is the abundance of published application circuits and code
samples. This book fills that gap:
• Provides downloadable software, including tools, resources,
supplementary materials, and code listings
HIGH-PERFORMANCE SYSTEMS
• Includes sample circuits with their corresponding programs,
as well as tested PCB files
AND PROGRAMMING
• Focuses on the popular embedded systems with PIC18
series microcontrollers
• Contains an appendix with a C language tutorial, PIC18
instruction set, links to useful tools and software
• Supplies sample circuits that are not copyrighted or patented, so
readers can freely use them in their own applications
• Covers selected topics and examples that provide solutions to
Julio Sanchez
problems that practicing engineers may encounter and are not
readily found in the literature Maria P. Canton
Designed to be functional and hands-on, this book provides sample
circuits with their corresponding programs. It clearly depicts and
labels the circuits, in a way that is easy to follow and reuse. The
book matches sample programs to the individual circuits and
discusses general programming techniques.
K16291
Microcontrollers
HIGH-PERFORMANCE SYSTEMS
AND PROGRAMMING
Julio Sanchez
Eastern Florida State College
Maria P. Canton
Brevard Public Schools
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been
made to publish reliable data and information, but the author and publisher cannot assume responsibility for the valid-
ity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright
holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this
form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may
rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or uti-
lized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopy-
ing, microfilming, and recording, or in any information storage or retrieval system, without written permission from the
publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://
www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923,
978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For
organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for
identification and explanation without intent to infringe.
Visit the Taylor & Francis Web site at
http://www.taylorandfrancis.com
and the CRC Press Web site at
http://www.crcpress.com
Table of Contents
Preface xx
v
vi Table of Contents
Index 671
Preface
Like our preced ing titles in this field, the book is intended as a ref erence and re -
source for en gineers, scientists, and electronics enthusiasts. The book focuses on
the needs of the working professional in the fields of electrical, electronic, com-
xxi
xxii Preface
puter, and software en gineering. In developing the material for this book, we have
adopted the following rules:
1. The use of standard or off-the-shelf components such as input/output devices, in-
tegrated circuits, motors, and programmable microcontrollers, which readers
can easily duplicate in their own circuits.
2. The use of inexpensive or freely available development tools for the design and
prototyping of embedded systems, such as electronic design programs, program-
ming languages and environments, and software utilities for creating printed cir-
cuit boards.
3. Our sample circuits and programs are not copyrighted or patented so that readers
can freely use them in their own applications.
Our book is designed to be func tional and hands-on. The resources furnished to
the reader include sample circuits with their corresponding programs. The circuits
are depicted and labeled clearly, in a way that is easy to follow and reuse. Each cir-
cuit includes a parts list of the resources and components required for its fabrica -
tion. For the most important circuits, we also provide tested PCB files. The sample
programs are matched to the individual circuits but general programming tech-
niques are also discussed in the text. There are appendices with useful information
and the book's online software contains a listing of all the sample programs devel-
oped in the text.
Julio Sanchez
Maria P. Canton
Chapter 1
A microcontroller or DSP usually includes a cen tral processor, input and out put
ports, memory for program and data stor age, an in ternal clock, and one or more pe -
ripheral devices such as timers, counters, analog-to-digital converters, serial com-
munica tion facilities, and watch dog circuits. More than two dozen companies in the
United States and abroad manufac ture and mar ket microcontrollers. Mostly they
range from 8- to 32-bit devices. Those at the low end are intended for very simple
circuits and provide limited functions and program space, while the ones at the high
end have many of the fea tures associated with microprocessors. The most popular
microcontrollers include several from Intel (such as the 8051), from Zilog (deriva-
tives of their famous Z-80 microprocessor) from Motorola (such as the 68HC05),
from Atmel (the AVR), the Parallax (the BASIC Stamp), and many from Microchip.
Some of the high-end Microchip microcontrollers and DSPs are the topic of this
book.
1
2 Chapter 1
The original PIC was built to complement a Gen eral Instruments 16-bit CPU des-
ignated the CP-1600. The first 8-bit PIC was developed in 1975 to improve the per-
formance of the CP-1600 by offloading I/O tasks from the CPU. In 1985, General
Instrument spun off its microelectronics division. At that time, the PIC was re-de-
signed with inter nal EPROM to produce a programmable controller. Today, hun-
dreds of ver sions and vari a tions of PIC microcontrollers are avail able from
Microchip. Typical on-board peripherals include input and output ports, serial com-
munication modules, UARTs, and motor control devices. Program memory ranges
from 256 words to 64k words and more. The word size varies from 12 to 14 or 16
bits, depending on the specific PIC family.
It is often mentioned that one of the reasons for the success of the PIC is the sup-
port provided by Microchip. This support includes development software, such as a
professional-quality development environment called MPLAB, which can be down-
loaded free from the company's website (www.microchip.com). The MPLAB pack-
age includes an assembler, a linker, a debugger, and a simulator. Microchip also sells
an in-circuit debugger called MPLAB ICD 2. Other development products intended
for the professional market are also available from Microchip.
Many other programmers are available on the market. Microchip offers several
high-end models with in-circuit serial programming (ICSP) and low-voltage pro -
gramming (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 possi-
ble 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 combi-
nations are also offered by Microchip and other vendors.
4 Chapter 1
Development Boards
A development board is a demonstration circuit that usually contains an array of con -
nected and connectable com ponents. Their main purpose is as a learning and experi-
ment 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 op tion is to build
the circuits oneself, a time-consuming but valuable experience. Figure 1.2 shows the
LAB-X1 development board for the 16F87x PIC family.
The LAX-X1 board, as well as sev eral other mod els, are prod ucts of
microEngineering Labs, Inc. Development boards from Microchip and other ven -
dors are also available.
Within each of the groups the PIC are classified based on the first two digits of
the PIC's family type. However, the sub-classification is not very strict, as there is
some overlap. In fact, we find PICs with 16X designations that belong to the base -
line family and others that be long to the mid-range group. In the fol lowing sub-sec-
tions we describe the basic charac teristics of the var ious sub-groups of the three
major PIC families with 8-bit architectures.Table 1.1 shows the principal hardware
characteristics of each of the four 8-bit PIC families
Table 1.1
8-bit PIC Architec tures Compar ison Chart
BASELINE MID-RANGE ENHANCED PIC18
battery-operated applications because they have low power requirements. The typi-
cal member of the base line group has a low pin count, flash program memory, and low
power requirements. The following types are in the Baseline group:
• PIC10 devices
• PIC12 devices
• PIC14 devices
• Some PIC16 devices
We present a short summary of the func tionality and hardware types of the base-
line PICs in the sec tions that follow, although these de vices are not cov ered in this
book.
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 re-
set, an internal oscillator mode which saves hav ing to use ports for an external oscilla-
tor. They have a power-saving SLEEP mode, A Watch dog Timer, and optional code
protection.
The recommended applications of the PIC10 family range from personal care ap-
pliances and security systems to low-power remote transmitters and receivers. The
PICs of this family have a small footprint and are manufac tured in formats suitable
for both through hole or surface mount technologies. Table 1.2 lists the charac teris-
tics of the PIC10F devices.
Table 1.2
PIC10F Devices
10F200 10F202 10F204 10F206
Clock:
Max i mum Fre quency
of Op era tion (MHz) 4 4 4 4
Mem ory:
Flash Program
Mem ory 256 512 256 512
Data Mem ory (bytes) 16 24 16 24
Pe riph er als:
Timer Mod ule(s) TMR0 TMR0 TMR0 TMR0
Wake-up from Sleep Yes Yes Yes Yes
Com para tors 0 0 1 1
Fea tures:
I/O Pins 3 3 3 3
In put Only Pins 1 1 1 1
In ter nal Pull-ups es Yes Yes Yes
In-Cir cuit Se rial
Pro gram ming Yes Yes Yes Yes
In struc tions 33 33 33 33
Pack ages: --------------------------------- 6-pin SOT-23 -------------------------------
----------------------------------- 8-pin PDIP --------------------------------
Microcontrollers for Embedded Systems 7
Two other PICs of this series are the 10F220 and the 10F222. These versions in-
clude 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 fam ily are 8-bit, fully static, EEPROM/EPROM/ROM-based CMOS
microcontrollers. The devices use RISC architecture and have 33 single-word, sin-
gle-cycle instructions (except for program branches that take two cycles). Like the
PIC10 family, the PIC12C5XX chips have power-on reset , device reset, and an internal
timer. Four oscillator options can be selected, including a port-saving internal oscilla-
tor and a low-power oscillator. These devices can also operate in SLEEP mode and
have watchdog timer and code pro tec tion features.
The PIC12C5XX devices are recommended for applications ranging from per-
sonal care appliances, security systems, and low-power remote transmitters and re-
ceivers. The internal EEPROM memory makes possible the storage of user-defined
codes and passwords as well as appliance setting and receiver frequencies. The var-
ious packages allow through-hole or surface mount ing tech nologies. Table 1.3 lists
the characteristics of some selected members of this PIC family.
Table 1.3
PIC 12CXXX and 12CEXXX Devices
Table 1.3
PIC 12CXXX and 12CEXXX Devices (continued)
Two other members of the PIC12 family are the 12F510 and the 16F506. In most
respects these devices are similar to the ones previously described, except that the
12F510 and 16F506 both have flash program memory. Table 1.4 lists the most impor-
tant features of these two PICs.
Table 1.4
PIC12F510 and 12F675
12F629 12F675
Clock:
Maximum Frequency of Operation (MHz) 20 20
Memory:
Flash Program Memory 1024 1024
Data Memory (SRAM bytes) 64 64
Peripherals:
Timers 8/16 bits 1/1 1/1
Wake-up from Sleep on Pin Change Yes Yes
Features:
I/O Pins 6 6
Analog comparator module Yes Yes
Analog-to-digital converter No 10-bit
In-Circuit Serial Programming Yes Yes
Enhanced Timer1 module Yes Yes
Interrupt capability Yes Yes
Number of Instructions 35 35
Relative addressing Yes Yes
Packages 8-pin PDIP, 8-pin PDIP
SOIC, SOIC,
DFN-S DFN-S
Two other members of the PIC12F are the 12F629 and 12F675. The only differ-
ence between these two devices is that the 12F675 has a 10-bit analog-to-digital con-
verter while the 629 has not A/D converter. Table 1.5 lists some important features
of both PICs.
Microcontrollers for Embedded Systems 9
Table 1.5
PIC12F629 and 12F675
12F629 12F675
Clock:
Maximum Frequency of Operation (MHz) 20 20
Memory:
Flash Program Memory 1024 1024
Data Mem ory (SRAM bytes) 64 64
Peripherals:
Tim ers 8/16 bits 1/1 1/1
Wake-up from Sleep on Pin Change Yes Yes
Features:
I/O pins 6 6
Analog comparator module Yes Yes
Analog-to-digital converter No 10-bit
In-cir cuit serial programming Yes Yes
Enhanced Timer1 mod ule Yes Yes
Inter rupt capability Yes Yes
Number of instructions 35 35
Relative addressing Yes Yes
Packages 8-pin PDIP 8-pin PDIP
SOIC SOIC
DFN-S DFN-S
Several members of the PIC12 family, 12F635, 12F636, 12F639, and 12F683, are
equipped with special power-management features (called nanowatt technology by
Microchip). These devices were especially designed for systems that require ex-
tended battery life.
PIC14 Devices
The single member of this family is the PIC14000, which is built with CMOS tech nol-
ogy. This makes the PIUC14000 fully static and gives it industrial temperature range.
The 14000 is recommended for battery chargers, power supply controllers, power
management system controllers, HVAC controllers, and for sensing and data acquisi-
tion applications.1.3.2
PIC16 Devices
This is by far the largest mid–range PIC group. Currently over 80 versions of the PIC16
are listed in production by Microchip. Although we do not cover the mid-range devices
10 Chapter 1
in this book, we have selected a few of its most prominent members of the PIC16 fam-
ily to list their most important fea tures. These are found in Table 1.6.
Table 1.6
PIC16 Devices
16C432 16C58 16C770 16F54 16F84A 16F946
Clock:
Memory:
Program memory type OTP OTP OTP Flash Flash Flash
K-bytes 3.5 3 3.5 0.75 1.75 14
K-words 2 2 2 0.5 1 8
Data EEPROM 0 0 0 0 64 256
Peripherals:
I/O channels 12 12 16 12 13 53
ADC channels 0 0 6 0 0 8
Comparators 0 0 0 0 0 2
Timers 1/8-bit 1/8-bit 2/8-bit 1/8-bit 1/8-bit 2/8-bit
1/16-bit 1/16-bit
Watchdog timer Yes Yes Yes Yes Yes Yes
Features:
ICSP Yes No Yes No Yes Yes
ICD No No No No 0 1
Pin count 20 18 20 18 18 64
Communications - - MPC/SPI - - AUSART
Packages 20/CERDIP, 18/CERDIP 20/CERDIP 18/PDIP 18/PDIp 64/TQFP
20/SSOP 18/PDIP 20/PDIP 18/SOIC 18/SOIC
208mil 18/SOIC 20/SOIC 300mil 300mil
300mil 300mil
tion. These devices are furnished in 18 to 80 pin packages. Microchip describes the
PICs in this family as high-performance with integrated A/D converters.
Digital Signal Processor
The notion of digital signal processing starts with the conversion of analog signal in-
formation such as voice, image, temperature, or pressure primitive data to digital val-
ues that can be stored and manipulated by a com puting device. Convert ing the data
from its primitive analog form to a digital format makes it much easier to analyze, dis-
play, store, process, or convert the data to another format. Digital signal processing is
based on the fact that com puting and data pro cessing operations are easier to perform
on digital data than on raw analog signals.
digitizer and
transmitter
sensor
optical
system
scanning
mirror
image data
processing
scan line
scanning
direction
receiving image
station
processes this data and formats it into an image. In this scheme, digital signal pro-
cessing can take place as the image data is sensed by the instrument and tempo-
rarily stored on board the satellite, or when the raw data received by the Earth
station is con verted into an image that can be manipulated, viewed, stored, or
re-processed.
Analog-to-Digital
Conversion from analog-to-digital form and vice versa are not formally operations of a
DSP. However, these conversions are so often required during signal processing that
most DSP devices include the analog-to-digital and digital-to-analog conversion hard-
ware.
sampling periods
1 2 3 4 5 6 7 8 9 10 11 12 13
80
voltage of analog signal
70
60
50
40
30
20 analog signal
10
0
15 20 28 37 12 14 35 78 69 63 85 57 28
sampled digital values
In Figure 1.5 we see that the sampled values are actually an approximation of the
analog curve, as the variations between each interval are lost in the conversion pro-
cess. Therefore, the more sampling periods, the more accurate the approximation.
On the other hand, too small a sampling rate tends to re duce the sig nificance of the
data by producing repeated values in the digital record.
Chapter 2
PIC18 Architecture
13
14 Chapter 2
Although the PIC16 series has been very successful in the microcontroller mar-
ketplace, it also suffers from limitations and constraints. Perhaps the most signifi-
cant limitation is that the devices of the PIC16 family can only be programmed in
Assembly language. Other limitations result from the device's RISC design. For ex-
ample, the absence of certain types of opcodes, such as the Branch instruction,
make it nec essary to combine a skip opcode followed by a goto op eration in order
to provide a con ditional, targeted jump. Other limitations relate to the hard ware it-
self: small stack and a single interrupt vector. As the complexity, memory size, and
the number of pe ripheral modules increased, the limitations of the PIC16 series
became more evident.
In the PIC18 series, Microchip reconsidered its PIC16 de sign rules and produced
a completely new style microcontroller, with a much more complex core, while lim-
iting the changes to the pe ripheral modules. The degree of change can be deduced
from the ex pansion of the instruction set from 35 14-bit to 83 16-bit operation codes.
Memory has gone from 14 to 128 KB; the stack from 8 levels to 32 levels. These
changes made it possible to optimize the PIC18 series for C language programming.
1 40
MCLR/VPP RB7/PGD
2 39
RAO/ANO RB6/PGC
3 38
RA1/AN1 RB5/PGM
4 37
RA2/AN2A/REF- RB4
5 36
RA3/AN3A/REF+ RB3/CCP2*
6 35
RA4/TOCKI RB2/INT2
7 34
RA5/AN4/SS/LVDIN RB1/INT1
8 33
RE0/RD/AN5 RBO/INTO
9
18F442 32
RE1/WR/AN6 Vdd
10 31
RE2/CS/AN7 Vss
11 30
Vdd 18F452 RD7/PSP7
12 29
Vss RD6/PSP6
13 28
OSC1/CLKI RD5/PSP5
14 27
OSC2/CLKO/RA6 RD4/PSP4
15 26
RCO/T1OSO/TICK1 RC7/RX/DT
16 25
RC1/T1OSI/CCP2 RC6/TX/CK
17 24
RC2/CCP1 RC5/SDO
18 23
RC3/SCK/SCL RC4/SDI/SDA
19 22
RDO/PSPO RD3/PSP3
20 21
RD1/PSP1 RD2/PSP2
For learning and experimentation the devices in DIP packages are more conve-
nient because they can be easily inserted in the ZIF (zero insertion force) sockets
found in most programming devices, development boards, and bread boards. The de-
vices in Figure 1.1 and Figure 1.2 are so equipped. A PLCC (plastic leaded chip car-
rier) package with 44 pins is also available for 18F442 and 18F452 devices. We do
not cover this option.
From Table 2.1 the following general features of the PIC18FXX2 devices can be
deduced:
1. Operating frequency is 40 MHz for all devices. They all have a 75 opcode instruc-
tion set.
2. Program memory ranges from 16K (8,192 instructions) in the PIC18F2X2 devices
to 32K (16,384 instructions) in the PIC18F4X2 devices.
3. Data memory ranges for 768 to 1,536 bytes.
4. Data EEPROM is 256 bytes in all devices.
5. The PIC18F2X2 devices have three I/O poerts (A, B, and C) and the PIC18F4X2 de-
vices have five ports (A, B, C, D, and E).
6. All devices have four timers, two Capture/Compare/PWM modules, MSSP and
adressable USART for serial communications and 10-bit analog-to-digital mod-
ules.
7. Only PIC18F4X2 devices have a parallel port.
CPU
oscillators
ports
internal modules
bits: 7 6 5 4 3 2 1 0
- - - N OV Z DC C
The 21-bit wide Program Counter register specifies the address of the next instruction
to be ex ecuted. The reg ister mapping of the Program Counter register is shown in Fig-
ure 2.5.
18 Chapter 2
Bits 20 15 7 0
As shown in Figure 2.5, the low byte of the ad dress is stored in the PCL register,
which is readable and writeable. The high byte is stored in the PCH register. The up-
per byte is in the PCU register, which contains bits <20:16>. The PCH and PCU regis-
ters are not di rectly read able or writeable. Up dates to the PCH reg is ter are
performed through the PCLATH register. Updates to the PCU register are performed
through the PCLATU register.
The Program Counter addresses byte units in program memory. In order to pre -
vent the Pro gram Counter from becoming misaligned with word instructions, the
LSB of PCL is fixed to a value of '0' (see Figure 2.5). The Program Counter incre -
ments by 2 to the ad dress of the next se quen tial in struc tions in the program
memory.
The CALL, RCALL, GOTO, and program branch instructions write to the Program
Counter directly. In these instructions, the contents of PCLATH and PCLATU are not
transferred to the pro gram counter. The contents of PCLATH and PCLATU are trans-
ferred to the Pro gram Counter by an operation that writes PCL. Similarly, the upper
2 bytes of the Program Counter will be transferred to PCLATH and PCLATU by an
operation that reads PCL.
Hardware Multiplier
All PIC18FXX2 devices contain an 8 x 8 hardware multiplier in the CPU. Because mul-
tiplication is a hardware operation it completes in a single instruction cycle. Hard-
ware multiplica tion is unsigned and produces a 16-bit re sult that is stored in a 16-bit
product reg ister pair labeled PRODH (high byte) and PRODL (low byte).
Interrupts
PIC18FXX2 devices support multiple interrupt sources and an interrupt priority
mechanism that allows each interrupt source to be as signed a high or low priority
level. The high-prior ity interrupt vector is at OOOOO8H and the low-priority interrupt
vector is at 000018H. High-priority interrupts override any low-priority interrupts that
may be in progress. Ten registers are related to interrupt operation:
PIC18 Architec ture 19
• RCON
• INTCON
• INTCON2
• INTCON3
• PIR1, PIR2
• PIE1, PIE2
• IPR1, IPR2
Interrupt priority is enabled by setting the IPEN bit {mapped to the RCON<7>
bit}. When interrupt priority is enabled, there are 2 bits that enable interrupts glob-
ally. Setting the GIEH bit (1NTCON<7>) enables all interrupts that have the priority
bit set. Setting the GIEL bit (INTCON<6>) enables all interrupts that have the prior-
ity bit cleared. When the interrupt flag, the en able bit, and the ap propriate global in-
ter rupt en able bit are set, the in ter rupt will vec tor to ad dress OOOOO8h or
000018H, de pending on the priority level. Individual in ter rupts can be dis abled
through their corresponding enable bits.
When the IPEN bit is cleared (default state), the interrupt priority feature is dis-
abled and the interrupt mechanism is compatible with PIC mid-range devices. In
this compatibility mode, the interrupt priority bits for each source have no effect
and all interrupts branch to address OOOOO8H.
When an interrupt is handled, the Global Interrupt Enable bit is cleared to disable
further interrupts. The return address is pushed onto the stack and the Pro gram
Counter is loaded with the interrupt vec tor address, which can be OOOOO8H or
000018H. In the Interrupt Service Routine, the source or sources of the interrupt can
be de termined by testing the interrupt flag bits. To avoid recursive interrupts, these
bits must be cleared in software be fore re-enabling interrupts. The “return from in-
terrupt“ instruction, RETFIE, exits the interrupt routine and sets the GIE bit {GIEH
or GIEL if priority levels are used), which re-enables interrupts.
Sev eral ex ter nal in ter rupts are also sup ported, such as the INT pins or the
PORTB input change interrupt. In these cases, the interrupt latency will be three to
four instruction cycles. Interrupts and interrupt programming are the subject of
Chapter 8.
These special features are re lated to the fol lowing functions and components:
• SLEEP mode
• Code protection
• ID locations
• In-circuit serial programming
• SLEEP mode
SLEEP mode is designed to offer a very low current mode during which the de-
vice is in a power-down state. The ap plica tion can wakeup from SLEEP through the
following mechanisms:
1. External RESET
2. Watchdog Timer Wake-up
3. An interrupt
The Watch dog Timer is a free running on-chip RC oscillator, that does not re quire
any external components. This RC oscillator is separate from the RC oscillator of
the OSC1/CLKI pin. That means that the WDT will run, even if the clock on the
OSC1/CLKI and OSC2/CLKO/ RA6 pins of the device has been stopped, for example,
by ex ecution of a SLEEP instruction.
Watchdog Timer
A Watchdog Timer time-out (WDT) generates a device RESET. If the device is in
SLEEP mode, a WDT causes the de vice to wakeup and continue in normal operation
(Watchdog Timer Wake-up). If the WDT is enabled, software ex ecution may not dis-
able this function. When the WDTEN configuration bit is cleared, the SWDTEN bit en-
ables/disables the operation of the WDT. Values for the WDT postscaler may be
assigned using the configuration bits.
The CLRWDT and SLEEP instructions clear the WDT and the postscaler (if as-
signed to the WDT) and prevent it from timing out and generating a device RESET
condition. When a CLRWDT instruction is executed and the postscaler is assigned
to the WDT, the postscaler count will be cleared, but the postscaler assignment is
not changed.
The WDT has a postscaler field that can extend the WDT Reset pe riod. The
postscaler is selected by the value written to 3 bits in the CONFIG2H register during
device programming.
PIC18 Architec ture 21
Wake-Up by Interrupt
When global interrupts are disabled (the GIE bit cleared) and any interrupt source has
both its interrupt enable bit and interrupt flag bit set, then one of the following will oc-
cur:
When an interrupt occurs before the ex ecution of a SLEEP instruction, then the
SLEEP instruction becomes a NOP. In this case, the WDT and WDT postscaler will
not be cleared, the TO bit will not be set, and PD bits will not be cleared.
If the interrupt condition occurs during or after the ex ecution of a SLEEP instruc-
tion, then the de vice will immediately wakeup from SLEEP. In this case, the SLEEP
instruction will be completely executed be fore the wake-up. Therefore, the WDT
and WDT postscaler will be cleared, the TO bit will be set, and the PD bit will be
cleared.
Even if the flag bits were checked before executing a SLEEP instruction, it may
be possible for these bits to set be fore the SLEEP instruction completes. Code can
test the PD bit in order to de termine whether a SLEEP instruction executed. If the
PD bit is set, the SLEEP instruction was executed as a NOP. To ensure that the WDT
is cleared, a CLRWDT instruction should be executed be fore a SLEEP instruction.
For many applications it is desirable to be able to detect a drop in device voltage below
a certain limit. In this case, the application can define a low voltage window in which it
can per form housekeep ing tasks before the volt age drops be low its defined operating
range. The Low Voltage Detect feature of the PIC18FXX2 devices can be used for this
purpose. For example, a voltage trip point for the de vice can be spec ified so that when
this point is reached, an interrupt flag is set. The program will then branch to the inter-
rupt's vector address and the interrupt handler software can take the cor responding
action. Because the Low Voltage Detect circuitry is completely under software con-
trol, it can be “turned off” at any time, thus saving power.
Implementing Low Voltage Detect requires setting up a comparator that reads the
reference voltage and compares it against the preset trip-point. This trip-point volt-
age is software programmable to any one of sixteen values by means of the 4 bits la-
beled LVDL3:LVDLO. When the device voltage becomes lower than the preselected
trip-point, the LVDIF bit is set and an interrupt is generated.
Device Configuration
High Priority Interrupt Vector 0008H High Priority Interrupt Vector 0008H
Low Priority Interrupt Vector 0018H Low Priority Interrupt Vector 0018H
On-Chip On-Chip
Program Memory Program Memory
3FFFH
4000H
7FFFH
8000H
Read '0'
Read '0'
1FFFFFH 1FFFFFH
200000H 200000H
PIC18F442/242 PIC18F452/252
Figure 2.6 Program memory map for the PIC18FXX2 family.
Discovering Diverse Content Through
Random Scribd Documents
MALURUS ELEGANS, Gould.
Graceful Wren.
This is not only the largest species of the genus yet discovered, but
may be considered as one of the most beautiful and elegant of its
race: the delicate verditer-blue of the centre of the back, and the
larger size and more spatulate form of its tail-feathers, at once
distinguish it from Malurus Lamberti, the species to which it is most
nearly allied. It is an inhabitant of the western coast of Australia; all
the specimens I possess were collected at Swan River, where it is
tolerably abundant. Mr. Gilbert states, that although in its economy
it very closely resembles M. splendens, it nevertheless differs from
that species in the nature of the localities it frequents, which are
usually swampy situations, while M. splendens is more generally
spread over all parts of the country. It is also said to differ slightly in
its song, in commencing with one distinct note and then singing
precisely like the former.
The nest, which is neither characterized by neatness nor
compactness, is dome-shaped, with a hole in the side for an entrance,
and is generally formed of the thin paper-like bark of the Tea-tree
(Melaleuca), and lined with feathers: it is also usually suspended to
the foliage of this tree, and occasionally to that of other shrubs which
grow in its favourite localities. The eggs are four in number, of a
delicate flesh-white freckled with spots of reddish brown, which are
much thicker at the larger end; they are about eight lines long and six
lines broad. The breeding-season commences in September and
continues during the three following months.
The food consists of insects.
The males are subject to the same law relative to the seasonal
change of plumage as the Malurus cyaneus, and the other members
of the group.
The male has the forehead, ear-coverts, sides of the face and
occiput rich verditer-blue; centre of the back light verditer-blue;
scapularies chestnut; throat, chest, back of the neck and rump deep
velvety black, the throat in certain lights tinged with blue; wings
brown; abdomen and under tail-coverts huffy white; tail dull bluish
green, crossed by numerous indistinct bars, seen only in some
positions, and very slightly tipped with white; bill black; eyes and
feet blackish brown.
The female has all the upper surface and wings brown; throat and
under surface buff-white; tail as in the male, but more dull, and
devoid of the white at the extremity of the feathers; bill dull reddish
brown, lighter beneath; space between the bill and eyes reddish
brown; legs brown.
The figures are of the natural size, on the Isopogon alternatus.
MALURUS
PULCHERRIMUS:
Gould.
J. Gould
and H. C.
Richter del
et lith.
Hullmandel
& Walton
Imp.
MALURUS PULCHERRIMUS, Gould.
Beautiful Wren.
J. & E.
Gould delt.
C.
Hullmandel
Imp.
MALURUS LAMBERTI, Vig. & Horsf.
Lambert’s Wren.
Malurus Lamberti, Vig. & Horsf. in Linn. Trans., vol. xv. p. 221.—
Jard. and Selb., Ill. Orn., vol. ii. pl. 72. fig. 2.—Gould, Syn.
Birds of Australia, Part I.
Superb Warbler, White’s Journ., pl. in p. 256, low. fig.—Phillips,
Voy., pl. in p. 157, male.
Variegated Warbler, Lewin, Birds of New Holl., pl. xv.
Although far less common and much more local than M. cyaneus,
this species ranges over a greater extent of country, being an
inhabitant of most parts of New South Wales, the interior in the
neighbourhood of the Namoi and the north-west coast, whence I
received several specimens, forming part of an interesting collection
kindly sent me by Mr. Dring. I found it tolerably abundant on the
Namoi, where it was sometimes associated with its congener M.
cyaneus.
In New South Wales the neighbourhood of Botany Bay is one of its
most favourite resorts, and it is occasionally seen near Sydney, and
even in the small gardens within the town. A beautiful specimen in
the Museum of this place was killed on the lawn in front of that
establishment, which is situated within the precincts of the town,
and surrounded on all sides by houses. It does not inhabit Van
Diemen’s Land, nor did I observe it in South Australia, or hear of its
ever having been seen there, neither have I received it from the
colony of Swan River.
Lambert’s Superb Warbler is a species with which we have been
long acquainted, being figured in the early voyages to New South
Wales as a variety of Malurus cyaneus; but the only species with
which it at all assimilates in the disposition and colour of its
markings is the M. elegans of Western Australia, of which it forms a
beautiful analogue on the eastern coast.
This is one of the few common birds of Australia of which I was
not able to find the nest; but its changes of plumage, nidification, the
number and colour of its eggs, are doubtless very similar to those of
the other members of its family. Its food consists of insects of various
kinds, which are sought for on the ground, over which it runs with
great facility.
The male has the forehead, ear-coverts, sides of the head and
occiput and centre of the back beautiful violet-blue; throat, breast,
crescent across the upper part of the back and rump black;
scapularies chestnut; wings brown; abdomen white, tinged with
brown on the flanks; tail dull greenish blue, indistinctly barred with a
darker tint, and lightly tipped with white; bill black; eyes and feet
dark brown.
The female has the body dull brown; the throat and under surface
much paler; tail-feathers as in the male, but less bright; bill and
space round the eye reddish brown; feet brown.
The Plate represents a male and female of the natural size.
MALURUS
LEUCOPTERUS: Quoy
& Gaim.
J. & E.
Gould delt.
C.
Hullmandel
Imp.
MALURUS LEUCOPTERUS, Quoy & Gaim.?
White-winged Wren.
I regret that I have not been able to clear up the doubt which exists
in my mind, whether the present beautiful bird is or is not distinct
from the one figured by Messrs. Quoy and Gaimard in the “Voyage
de l’Uranie,” since on applying at the Museum of the Jardin des
Plantes, for the purpose of examining the original specimen, it could
not be found: the figure above-quoted, if intended for the present
bird, is by no means correct, and it is, moreover, said to be from Dirk
Hatich’s Island, on the western coast, a locality very distant from
those in which I found the bird here represented; a circumstance
which strengthens my belief that they may be distinct: besides which,
the bird I have figured is supposed to be exclusively an inhabitant of
the interior; I never even observed it between the mountain ranges
and the coast; it is therefore scarcely probable that it should inhabit
an island like that of Dirk Hatich.
It was tolerably abundant in the patches of low scrub and grassy
beds, here and there scattered over the plains which stretch out to
the northward of the Liverpool range, and it was equally plentiful on
the Lower Namoi: that it extends as far as South Australia, is proved
by my having received its nest and eggs from that part of the
continent.
It was usually seen either in pairs or in small troops, and evinced
so much shyness of disposition as to render the acquisition of
specimens a task of no little difficulty, particularly of the full-
plumaged male, who appeared to be conscious that the display of his
gorgeously-coloured dress might lead to his detection. Its powers of
flight are not great, but this is fully compensated for by the
extraordinary manner in which it threads the bushes, and passes
over the surface of the ground in a series of hopping bounds,
whereby it readily eludes pursuit. The most successful mode of
obtaining it is to ascertain the precise spot in which it is located, to
approach it cautiously, and to remain silent for a short time, when
the male will soon show himself by hopping out from the bush; the
restless nature of his disposition not admitting of his remaining long
concealed.
The beautifully contrasted colours of blue and white, represented
in our Plate, is a merely seasonal dress assumed in spring, and
continued throughout the breeding-season, which commences in
August and terminates in January; before and after this season male
birds may be seen in every stage of colouring, from plain uniform
brown to that of the perfect livery.
The nest is composed of grasses, rather large and dome-shaped,
with a hole near the top for an entrance. The one sent me from South
Australia contained two eggs, one of which was the Bronze Cuckoo’s,
thus showing that this little bird is also the foster-parent of those
birds. The number of eggs laid by the Malurus leucopterus is in all
probability four; the one I possess is flesh-white, finely freckled with
reddish brown, forming a zone at the larger end, and is eight lines
long by six lines broad.
The male has the whole of the head, body above and beneath, and
the tail beautiful deep blue; scapularies, wing-coverts and tertiaries
snow-white; primaries brown, with their external edges silvery
green; bill black; feet brown; eyes dark brown.
The female has the crown of the head, and all the upper surface
and flanks brown; throat and abdomen white, faintly washed with
brown; external edges of the primaries and tail pale greenish blue;
bill reddish brown.
The Plate represents the male and female of the natural size; the
Plant is the Brunonia Australis.
MALURUS
MELANOCEPHALUS:
Vig. & Horsf.
J. & E.
Gould delt.
C.
Hullmandel
Imp.
MALURUS MELANOCEPHALUS, Vig. &
Horsf.
Black-headed Wren.
J. & E.
Gould delt.
C.
Hullmandel
Imp.
MALURUS BROWNII, Vig. & Horsf.
Brown’s Wren.
Malurus Brownii, Vig. & Horsf. in Linn. Trans., vol. xv. p. 223.
Malurus cruentatus, Gould in Proc. of Zool. Soc., Part VII. p. 143.
J. & E.
Gould delt.
C.
Hullmandel
Imp.
AMYTIS TEXTILIS.
Textile Wren.
The birds figured in this and the following Plate differ from each
other considerably in plumage, as well as in the structure of the bill,
that organ in the present bird being shorter and more robust than in
Amytis striatus.
Of the Textile Wren I killed and dissected many examples, but of
the following I only procured a single specimen, and never met with
it but in this one instance. I have considered it necessary to state this,
as it would have been more satisfactory to me to have had further
proofs from actual dissection and comparison, of their being really
distinct, although I have little doubt that such is the case. The bird
figured in the “Voyage de l’Uranie,” is doubtless referable to the one
represented on the opposite Plate, while that figured by M. Lesson in
the Atlas to his “Traité d’Ornithologie,” and which seems to have
been the subject from which he took his generic characters and
description, as clearly belongs to A. striatus.
The only place in which I observed the Textile Wren was the plains
bordering the Lower Namoi; and that its range extends far to the
northward and westward is certain, from the fact of the specimen
figured in the “Voyage” above-quoted having been procured on the
north-west coast.
In the various positions it assumes, in the elevated carriage of its
tail, and in its whole economy, it bears a close resemblance to the
true Maluri: like them also it wanders about in small troops of four
or six in number, always keeping within a short distance, and
returning towards the close of the day to its accustomed haunts. On
the Lower Namoi, where it is very abundant, it is found in all those
parts of the plains that are studded with scrubs and clumps of a low
shrub-like tree, resembling the Barilla of the coast, through and
among which it creeps with astonishing rapidity; indeed, its mode of
progression on the ground is such as no description can convey an
accurate conception of, and must be seen to be understood: I cannot
perhaps compare it with anything, unless with the motion of an
India-rubber ball when thrown forcibly along the ground. While
stealing from bush to bush, with this rapid movement, its head low
and tail perfectly erect, it presents an exceedingly droll appearance.
Like many others of its family, it seldom employs the power of flight.
Its food is insects of various kinds.
Of its nidification I have nothing to communicate: it doubtless
builds a dome-shaped nest, and in all probability lays four spotted
eggs; but to these points I would call the attention of those who are
favourably situated for observing them, as also to confirm or refute
the opinion of this and the following bird being distinct.
All the upper surface dark brown, each feather with a narrow
stripe of white down the centre; under surface the same, but much
paler; flanks and under surface of the shoulder rust-red; tail dark
brown, indistinctly barred with a still darker hue and edged with pale
brown; irides reddish hazel; base of lower mandible bluish horn-
colour; remainder of the bill black; feet flesh-brown.
The male I dissected was destitute of the rusty red colouring on the
flanks and under surface of the shoulder.
The Plate represents a male and female of the natural size.
AMYTIS STRIATUS:
Gould.
J. & E.
Gould delt.
C.
Hullmandel
Imp.
AMYTIS STRIATUS.
Striated Wren.
J. Gould
and H. C.
Richter del
et lith.
Hullmandel
& Walton
Imp.
AMYTIS MACROURUS, Gould.
Large-tailed Wren.
The present is the first species of the genus that has been
discovered in Western Australia; the two examples in my own
collection are all that I have yet seen; these were shot in the interior
by Mr. Gilbert, who states that “it inhabits the thickets, and is almost
always on the ground in families of from four to seven in number: it
carries its tail more erect than any other bird I have seen, and
certainly no bird runs or rather hops over the surface of the ground
with greater rapidity.”
It is evidently the representative of the Amytis textilis of the
eastern coast, to which it is very nearly allied, but from which, as well
as from the A. striatus, it may at once be distinguished by its more
robust form, and by the much greater length and size of its tail.
All the upper surface brown, each feather with a narrow stripe of
white down the centre; under surface the same, but much paler;
under surface of the shoulder pale rusty red; tail brown, margined
with pale brown; irides hazel; base of the lower mandible horn-
colour, remainder of the bill black; feet flesh-brown.
The figures are of the natural size.
STIPITURUS
MALACHURUS: Lefs.
J. & E.
Gould delt.
C.
Hullmandel
Imp.
STIPITURUS MALACHURUS, Less.
Emu Wren.
This curious little bird has a wide distribution; since it inhabits the
whole of the southern portion of Australia, from Moreton Bay on the
east to Swan River on the west, including Tasmania. Among the
places where it is most numerous in the latter country, are the
swampy grounds in the neighbourhood of Recherche Bay in
D’Entrecasteaux Channel, the meadows at New Norfolk, Circular
Head, and Flinder’s Island in Bass’s Straits; on the continent of
Australia, Botany Bay, and indeed all portions of the country having
a similar character are favoured with its presence.
In its actions it bears a close resemblance to the true Maluri,
among which it has been associated, but, as the nature of its plumage
would lead us to expect, it resorts to situations of a totally different
character; for while the more open forest is the favourite resort of the
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookgate.com