Programming 8 bit PIC Microcontrollers in C with
Interactive Hardware Simulation 1st Edition
Martin P. Bates pdf download
https://ebookname.com/product/programming-8-bit-pic-
microcontrollers-in-c-with-interactive-hardware-simulation-1st-
edition-martin-p-bates/
Get Instant Ebook Downloads – Browse at https://ebookname.com
Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...
Interfacing PIC Microcontrollers Embedded Design by
Interactive Simulation 1st Edition Martin P. Bates
https://ebookname.com/product/interfacing-pic-microcontrollers-
embedded-design-by-interactive-simulation-1st-edition-martin-p-
bates/
PIC Microcontrollers An Introduction to
Microelectronics 2nd Ed Second Edition Martin Bates
https://ebookname.com/product/pic-microcontrollers-an-
introduction-to-microelectronics-2nd-ed-second-edition-martin-
bates/
Microcontrollers Fundamentals and Applications with PIC
1st Edition Fernando E. Valdes-Perez
https://ebookname.com/product/microcontrollers-fundamentals-and-
applications-with-pic-1st-edition-fernando-e-valdes-perez/
King Richard II Webster s Spanish Thesaurus Edition
William Shakespeare
https://ebookname.com/product/king-richard-ii-webster-s-spanish-
thesaurus-edition-william-shakespeare/
Buddhist phenomenology A philosophical investigation of
Yog■c■ra Buddhism and the Ch■eng Wei shih lun Dan
Lusthaus
https://ebookname.com/product/buddhist-phenomenology-a-
philosophical-investigation-of-yogacara-buddhism-and-the-
ch%ca%bceng-wei-shih-lun-dan-lusthaus/
The Cronaca di Partenope An Introduction to and
Critical Edition of the First Vernacular History of
Naples c 1350 Medieval Mediterranean Samantha Kelly
https://ebookname.com/product/the-cronaca-di-partenope-an-
introduction-to-and-critical-edition-of-the-first-vernacular-
history-of-naples-c-1350-medieval-mediterranean-samantha-kelly/
Gravity Falls Dipper s and Mabel s Guide to Mystery and
Nonstop Fun Rob Renzetti
https://ebookname.com/product/gravity-falls-dipper-s-and-mabel-s-
guide-to-mystery-and-nonstop-fun-rob-renzetti/
Small Animal Cardiology 1st Edition Nelson Dvm Ms
Dacvim
https://ebookname.com/product/small-animal-cardiology-1st-
edition-nelson-dvm-ms-dacvim/
Unlocking the Prehistory of America 1st Edition Frank
Joseph
https://ebookname.com/product/unlocking-the-prehistory-of-
america-1st-edition-frank-joseph/
Luther s Theology of the Cross Martin Luther s
Theological Breakthrough Second Edition Alister E.
Mcgrath
https://ebookname.com/product/luther-s-theology-of-the-cross-
martin-luther-s-theological-breakthrough-second-edition-alister-
e-mcgrath/
Foreword
Embedded microcontrollers are everywhere today. In the average household you will
find them far beyond the obvious places like cell phones, calculators, and MP3 players.
Hardly any new appliance arrives in the home without at least one controller and, most
likely, there will be several—one microcontroller for the user interface (buttons and
display), another to control the motor, and perhaps even an overall system manager. This
applies whether the appliance in question is a washing machine, garage door opener,
curling iron, or toothbrush. If the product uses a rechargeable battery, modern high
density battery chemistries require intelligent chargers.
A decade ago, there were significant barriers to learning how to use microcontrollers.
The cheapest programmer was about a hundred dollars and application development
required both erasable windowed parts—which cost about ten times the price of the
one time programmable (OTP) version—and a UV Eraser to erase the windowed part.
Debugging tools were the realm of professionals alone. Now most microcontrollers use
Flash-based program memory that is electrically erasable. This means the device can be
reprogrammed in the circuit—no UV eraser required and no special packages needed for
development. The total cost to get started today is about twenty-five dollars which buys
a PICkit™ 2 Starter Kit, providing programming and debugging for many Microchip
Technology Inc. MCUs. Microchip Technology has always offered a free Integrated
Development Environment (IDE) including an assembler and a simulator. It has never
been less expensive to get started with embedded microcontrollers than it is today.
While MPLAB®
includes the assembler for free, assembly code is more cumbersome
to write, in the first place, and also more difficult to maintain. Developing code using
C frees the programmer from the details of multi-byte math and paging and generally
improves code readability and maintainability. CCS and Hi-Tech both offer free “student”
versions of the compiler to get started and even the full versions are relatively inexpensive
once the savings in development time has been taken into account.
www.newnespress.com
For-H8960.indd xi
For-H8960.indd xi 6/10/2008 10:36:25 AM
6/10/2008 10:36:25 AM
www.newnespress.com
While the C language eliminates the need to learn the PIC16 assembly language and frees
the user from managing all the details, it is still necessary to understand the architecture.
Clocking options, peripherals sets, and pin multiplexing issues still need to be solved.
Martin’s book guides readers, step-by-step, on the journey from “this is a micro-
controller” to “here’s how to complete an application.” Exercises use the fully featured
PIC16F877A, covering the architecture and device configuration. This is a good starting
point because other PIC16s are similar in architecture but differ in terms of IO lines,
memory, or peripheral sets. An application developed on the PIC16F877A can easily be
transferred to a smaller and cheaper midrange PICmicro. The book also introduces the
peripherals and shows how they can simplify the firmware by letting the hardware do the
work.
MPLAB®
, Microchip’s Integrated Development Environment, is also covered. MPLAB
includes an editor and a simulator and interfaces with many compilers, including the
CCS compiler used in this book. Finally, the book includes the Proteus®
simulator which
allows complete system simulation, saving time and money on prototype PCBs.
Dan Butler
Principal Applications Engineer
Microchip Technology Inc.
xii Foreword
For-H8960.indd xii
For-H8960.indd xii 6/10/2008 10:36:25 AM
6/10/2008 10:36:25 AM
www.newnespress.com
Preface
This book is the third in a series, including
● PIC Microcontrollers: An Introduction to Microelectronic Systems.
● Interfacing PIC Microcontrollers: Embedded Design by Interactive Simulation.
● Programming 8-bit PIC Microcontrollers in C: With Interactive Hardware
Simulation.
It completes a set that introduces embedded application design using the Microchip
PIC®
range, from Microchip Technology Inc. of Arizona. This is the most popular
microcontroller for education and training, which is also rapidly gaining ground in the
industrial and commercial sectors. Interfacing PIC Microcontrollers and Programming
PIC Microcontrollers present sample applications using the leading design and simulation
software for microcontroller based circuits, Proteus VSM®
from Labcenter Electronics.
Demo application files can be downloaded from the author’s support Web site (see
later for details) and run on-screen so that the operation of each program can be studied
in detail.
The purpose of this book is to
● Introduce C programming specifically for microcontrollers in easy steps.
● Demonstrate the use of the Microchip MPLAB IDE for C projects.
● Provide a beginners’ guide to the CCS PCM C compiler for 16 series PICs.
● Explain how to use Proteus VSM to test C applications in simulated hardware.
● Describe applications for the Microchip PICDEM mechatronics board.
● Outline the principles of embedded system design and project development.
Pre-H8960.indd xiii
Pre-H8960.indd xiii 6/10/2008 10:38:12 AM
6/10/2008 10:38:12 AM
www.newnespress.com
C is becoming the language of choice for embedded systems, as memory capacity
increases in microcontrollers. Microchip supplies the 18 and 24 series chips specifically
designed for C programming. However, C can be used in the less complex 16 series PIC,
as long as the applications are relatively simple and therefore do not exceed the more
limited memory capacity.
The PIC 16F877A microcontroller is used as the reference device in this book, as it
contains a full range of peripherals and a reasonable memory capacity. It was also used
in the previous work on interfacing, so there is continuity if the book series is taken as a
complete course in PIC application development.
Microcontrollers are traditionally programmed in assembly language, each type having
its own syntax, which translates directly into machine code. Some students, teachers, and
hobbyists may wish to skip a detailed study of assembler coding and go straight to C,
which is generally simpler and more powerful. It is therefore timely to produce a text that
does not assume detailed knowledge of assembler and introduces C as gently as possible.
Although several C programming books for microcontrollers are on the market, many
are too advanced for the C beginner and distract the learner with undesirable detail in the
early stages.
This text introduces embedded programming techniques using the simplest possible
programs, with on-screen, fully interactive circuit simulation to demonstrate a range of
basic techniques, which can then be applied to your own projects. The emphasis is on
simple working programs for each topic, with hardware block diagrams to clarify system
operation, full circuit schematics, simulation screenshots, and source code listings, as
well as working downloads of all examples. Students in college courses and design
engineers can document their projects to a high standard using these techniques. Each
part concludes with a complete set of self-assessment questions and assignments designed
to complete the learning package.
An additional feature of this book is the use of Proteus VSM (virtual system modeling).
The schematic capture component, ISIS, allows a circuit diagram to be created using an
extensive library of active components. The program is attached to the microcontroller,
and the animated schematic allows the application to be comprehensively debugged
before downloading to hardware. This not only saves time for the professional engineer
but provides an excellent learning tool for the student or hobbyist.
xiv Preface
Pre-H8960.indd xiv
Pre-H8960.indd xiv 6/10/2008 10:38:13 AM
6/10/2008 10:38:13 AM
Preface xv
www.newnespress.com
Links, Resources, and Acknowledgments
Microchip Technology Inc. (www.microchip.com)
Microchip Technology Inc. is a manufacturer of PIC®
microcontrollers and associated
products. I gratefully acknowledge the support and assistance of Microchip Inc. in
the development of this book and the use of the company trademarks and intellectual
property. Special thanks are due to John Roberts of Microchip UK for his assistance
and advice. The company Web site contains details of all Microchip hardware, software,
and development systems. MPLAB IDE (integrated development system) must be
downloaded and installed to develop new applications using the tools described in this
book. The data sheet for the PIC 16F877A microcontroller should also be downloaded as
a reference source.
PIC, PICmicro, MPLAB, MPASM, PICkit, dsPIC, and PICDEM are trademarks of
Microchip Technology Inc.
Labcenter Electronics (www.labcenter.co.uk)
Labcenter Electronics is the developer of Proteus VSM (virtual system modeling), the
most advanced cosimulation system for embedded applications. I gratefully acknowledge
the assistance of the Labcenter team, especially John Jameson, in the development of
this series of books. A student/evaluation version of the simulation software may be
downloaded from www.proteuslite.com. A special offer for ISIS Lite, ProSPICE Lite,
and the 16F877A simulator model can be found at www.proteuslite.com/register/
ipmbundle.htm.
Proteus VSM, ISIS, and ARES are trademarks of Labcenter Electronics Ltd.
Custom Computer Services Inc. (www.ccsinfo.com)
Custom Computer Services Inc. specializes in compilers for PIC microcontrollers. The
main range comprises PCB compiler for 12-bit PICs, PCM for 16-bit, and PCH for
the 18 series chips. The support provided by James Merriman at CCS Inc. is gratefully
acknowledged. The manual for the CCS compiler should be downloaded from the
company Web site (Version 4 was used for this book). A 30-day trial version, which will
compile code for the 16F877A, is available at the time of writing.
Pre-H8960.indd xv
Pre-H8960.indd xv 6/10/2008 10:38:13 AM
6/10/2008 10:38:13 AM
xvi Preface
www.newnespress.com
The Author’s Web Site (www.picmicros.org.uk)
This book is supported by a dedicated Web site, www.picmicros.org.uk. All the
application examples in the book may be downloaded free of charge and tested using
an evaluation version of Proteus VSM. The design files are locked so that the hardware
configuration cannot be changed without purchasing a suitable VSM license. Similarly,
the attached program cannot be modified and recompiled without a suitable compiler
license, available from the CCS Web site. Special manufacturer’s offers are available via
links at my site. This site is hosted by www.larrytech.com and special thanks are due to
Gabe Hudson of Larrytech®
Internet Services for friendly maintenance and support.
I can be contacted at the e-mail address martin@picmicros.org.uk with any queries or
comments related to the PIC book series.
Finally, thanks to Julia for doing the boring domestic stuff so I can do the interesting
technical stuff.
About the Author
Martin P. Bates is the author of PIC Microcontrollers, Second Edition. He is currently
lecturing on electronics and electrical engineering at Hastings College, UK. His interests
include microcontroller applications and embedded system design.
Pre-H8960.indd xvi
Pre-H8960.indd xvi 6/10/2008 10:38:13 AM
6/10/2008 10:38:13 AM
www.newnespress.com
Introduction
The book is organized in five parts. Part 1 includes an overview of the PIC microcontroller
internal architecture, describing the features of the 16F877A specifically. This chip is
often used as representative of the 16 series MCUs because it has a full range of
peripheral interfaces. All 16 series chips have a common program execution core, with
variation mainly in the size of program and data memory. During programming, certain
operational features are configurable: type of clock circuit, watchdog timer enable, reset
mechanisms, and so on. Internal features include the file register system, which contains
the control registers and RAM block, and a nonvolatile EEPROM block. The parallel
ports provide the default I/O for the MCU, but most pins have more than one function.
Eight analog inputs and serial interfaces (UART, SPI, and I2
C) are brought out to specific
pins. The hardware features of all these are outlined, so that I/O programming can be
more readily understood later on. The application development process is described,
using only MPLAB IDE in this initial phase. A sample C program is edited, compiled,
downloaded, and tested to demonstrate the basic process and the generated file set
analyzed. The debugging features of MPLAB are also outlined: run, single step,
breakpoints, watch windows, and so on. Disassembly of the object code allows the
intermediate assembly language version of the C source program to be analyzed.
Part 2 introduces C programming, using the simplest possible programs. Input and output
are dealt with immediately, since this is the key feature of embedded programs. Variables,
conditional blocks (IF), looping (WHILE,FOR) are quickly introduced, with a complete
example program. Variables and sequence control are considered in a little more detail
and functions introduced. This leads on to library functions for operating timers and
ports. The keypad and alphanumeric LCD are used in a simple calculator program. More
data types (long integers, floating point numbers, arrays, etc.) follow as well as assembler
directives and the purpose of the header file. Finally, insertion of assembler into C
programs is outlined.
Itr-H8960.indd xvii
Itr-H8960.indd xvii 6/10/2008 10:39:06 AM
6/10/2008 10:39:06 AM
xviii Introduction
www.newnespress.com
Part 3 focuses on programming input and output operations using the CCS C library
functions. These simplify the programming process, with a small set of functions usually
providing all the initialization and operating sequences required. Example programs
for analog input and the use of interrupts and timers are developed and the serial port
functions demonstrated in sample applications. The advantages of each type of serial bus
are compared, and examples showing the connection of external serial EEPROM for data
storage and a digital to analog converter output are provided. These applications can be
tested in VSM, but this is not essential; use of VSM is optional throughout the book.
Part 4 focuses specifically on the PICDEM mechatronics board from Microchip. This has
been selected as the main demonstration application, as it is relatively inexpensive and
contains a range of features that allow the features of a typical mechatronics system to
be examined: input sensors (temperature, light, and position) and output actuators (DC
and stepper motor). These are tested individually then the requirements of a temperature
controller outlined. Operation of the 3.5-digit seven-segment LCD is explained in detail,
as this is not covered elsewhere. A simulation version of the board is provided to aid
further application design and implementation.
Part 5 outlines some principles of software and hardware design and provides some
further examples. A simple temperature controller provides an alternative design to that
based on the mechatronics board, and a data logger design is based on another standard
hardware system, which can be adapted to a range of applications—the BASE board.
Again, a full-simulation version is provided for testing and further development work.
This is followed by a section on operating systems, which compares three program
design options: a polling loop, interrupt driven systems, and real-time operating systems.
Consideration of criteria for the final selection of the MCU for a given application and
some general design points follow.
Three appendices (A, B, and C) cover hardware design using ISIS schematic capture,
software design using CCS C, and system testing using Proteus VSM. These topics are
separated from the main body of the book as they are related more to specific products.
Taken together, MPLAB, CCS C, and Proteus VSM constitute a complete learning/design
package, but using them effectively requires careful study of product-specific tutorials.
VSM, in particular, has comprehensive, well-designed help files; and it is therefore
unnecessary to duplicate that material here. Furthermore, as with all good design tools,
VSM evolves very quickly, so a detailed tutorial quickly becomes outdated.
Appendix D compares alternative compilers, and application development areas are
identified that would suit each one. Appendix E provides a summary of CCS C syntax
Itr-H8960.indd xviii
Itr-H8960.indd xviii 6/10/2008 10:39:06 AM
6/10/2008 10:39:06 AM
Introduction xix
www.newnespress.com
requirements, and Appendix F contains a list of the CCS C library functions provided
with the compiler, organized in functional groups for ease of reference. These are
intended to provide a convenient reference source when developing CCS C programs, in
addition to the full CCS compiler reference manual.
Each part of the book is designed to be as self-contained as possible, so that parts can be
skipped or studied in detail, depending on the reader’s previous knowledge and interests.
On the other hand, the entire book should provide a coherent narrative leading to a solid
grounding in C programming for embedded systems in general.
Itr-H8960.indd xix
Itr-H8960.indd xix 6/10/2008 10:39:06 AM
6/10/2008 10:39:06 AM
www.newnespress.com
PIC Microcontroller Systems
1.1 PIC16 Microcontrollers
● MCU features
● Program execution
● RAM file registers
● Other PIC chips
The microcontroller unit (MCU) is now big, or rather small, in electronics. It is one of the
most significant developments in the continuing miniaturization of electronic hardware.
Now, even trivial products, such as a musical birthday card or electronic price tag, can
include an MCU. They are an important factor in the digitization of analog systems, such
as sound systems or television. In addition, they provide an essential component of larger
systems, such as automobiles, robots, and industrial systems. There is no escape from
microcontrollers, so it is pretty useful to know how they work.
The computer or digital controller has three main elements: input and output devices,
which communicate with the outside world; a processor, to make calculations and handle
data operations; and memory, to store programs and data. Figure 1.1 shows these in a
little more detail. Unlike the conventional microprocessor system (such as a PC), which
has separate chips on a printed circuit board, the microcontroller contains all these
elements in one chip. The MCU is essentially a computer on a chip; however, it still
needs input and output devices, such as a keypad and display, to form a working system.
The microcontroller stores its program in ROM (read only memory). In the past, UV
(ultraviolet) erasable programmable ROM (EPROM) was used for prototyping or
P A R T 1
Ch01-H8960.indd 1
Ch01-H8960.indd 1 6/10/2008 4:56:37 PM
6/10/2008 4:56:37 PM
2 Part 1
www.newnespress.com
small batch production, and one-time programmable ROM for longer product runs.
Programmable ROM chips are programmed in the final stages of manufacture, while
EPROM could be programmed by the user.
Flash ROM is now normally used for prototyping and low-volume production. This can
be programmed in circuit by the user after the circuit has been built. The prototyping
cycle is faster, and software variations are easier to accommodate. We are all now familiar
with flash ROM as used in USB memory sticks, digital camera memory, and so on, with
Gb (109
byte) capacities commonplace.
The range of microcontrollers available is expanding rapidly. The first to be widely used,
the Intel 8051, was developed alongside the early Intel PC processors, such as the 8086.
This device dominated the field for some time; others emerged only slowly, mainly
in the form of complex processors for applications such as engine management systems.
These devices were relatively expensive, so they were justified only in high-value
products. The potential of microcontrollers seems to have been realized only slowly.
The development of flash ROM helped open up the market, and Microchip was among
the first to take advantage. The cheap and reprogrammable PIC16F84 became the most
widely known, rapidly becoming the number one device for students and hobbyists. On
the back of this success, the Microchip product range rapidly developed and diversified.
The supporting development system, MPLAB, was distributed free, which helped the PIC
to dominate the low-end market.
Flash ROM is one of the technical developments that made learning about microsystems
easier and more interesting. Interactive circuit design software is another. The whole
design process is now much more transparent, so that working systems are more quickly
achievable by the beginner. Low-cost in-circuit debugging is another technique that
helps get the final hardware up and running quickly, with only a modest expenditure on
development tools.
User Input User Output
Input
Peripherals
Output
Peripherals
RAM
Read & Write
Memory
CPU
Central
Processing
Unit
ROM
Read Only
Memory
Program
Download
Figure 1.1: Elements of a Digital Controller
Ch01-H8960.indd 2
Ch01-H8960.indd 2 6/10/2008 4:56:37 PM
6/10/2008 4:56:37 PM
PIC Microcontroller Systems 3
www.newnespress.com
MCU Features
The range of microcontrollers now available developed because the features of the MCU
used in any particular circuit must be as closely matched as possible to the actual needs of
the application. Some of the main features to consider are
● Number of inputs and outputs.
● Program memory size.
● Data RAM size.
● Nonvolatile data memory.
● Maximum clock speed.
● Range of interfaces.
● Development system support.
● Cost and availability.
The PIC16F877A is useful as a reference device because it has a minimal instruction
set but a full range of peripheral features. The general approach to microcontroller
application design followed here is to develop a design using a chip that has spare
capacity, then later select a related device that has the set of features most closely
matching the application requirements. If necessary, we can drop down to a lower range
(PIC10/12 series), or if it becomes clear that more power is needed, we can move up
to a higher specification chip (PIC18/24 series). This is possible as all devices have
the same core architecture and compatible instructions sets.
The most significant variation among PIC chips is the instruction size, which can be
12, 14, or 16 bits. The A suffix indicates that the chip has a maximum clock speed of
20MHz, the main upgrade from the original 16F877 device. These chips can otherwise be
regarded as identical, the suffix being optional for most purposes. The 16F877A pin-out
is seen in Figure 1.2 and the internal architecture in Figure 1.3. The latter is a somewhat
simplified version of the definitive block diagram in the data sheet.
Program Execution
The chip has 8k (8096 ⫻ 14 bits) of flash ROM program memory, which has to be
programmed via the serial programming pins PGM, PGC, and PGD. The fixed-length
Ch01-H8960.indd 3
Ch01-H8960.indd 3 6/10/2008 4:56:53 PM
6/10/2008 4:56:53 PM
4 Part 1
www.newnespress.com
instructions contain both the operation code and operand (immediate data, register
address, or jump address). The mid-range PIC has a limited number of instructions (35)
and is therefore classified as a RISC (reduced instruction set computer) processor.
Looking at the internal architecture, we can identify the blocks involved in program
execution. The program memory ROM contains the machine code, in locations numbered
from 0000h to 1FFFh (8k). The program counter holds the address of the current
instruction and is incremented or modified after each step. On reset or power up, it is reset
to zero and the first instruction at address 0000 is loaded into the instruction register,
decoded, and executed. The program then proceeds in sequence, operating on the contents
of the file registers (000–1FFh), executing data movement instructions to transfer data
between ports and file registers or arithmetic and logic instructions to process it. The CPU
has one main working register (W), through which all the data must pass.
If a branch instruction (conditional jump) is decoded, a bit test is carried out; and if
the result is true, the destination address included in the instruction is loaded into the
program counter to force the jump. If the result is false, the execution sequence continues
unchanged. In assembly language, when CALL and RETURN are used to implement
RB7/PGD
MCLR/VPP
RA0/AN0 RB6/PGC
RB5
RB4
RB3/PGM
RB2
RB1
RB0/INT
VDD
VSS
RD7/PSP7
RD6/PSP6
RD5/PSP5
RD4/PSP4
RC7/RX/DT
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
RD3/PSP3
RD2/PSP2
RA1/AN1
RA2/AN2/VREF⫺/CVREF
RA3/AN3/VREF⫹
RA4/T0CKI/C1OUT
RA5/AN4/SS/C2OUT
RE0/RD/AN5
RE1/WR/AN6
RE2/CS/AN7
VDD
VSS
OSC1/CLKI
OSC2/CLKO
RC0/T1OSO/T1CKI
RC1/T1OSI/CCP2
RC2/CCP1
RC3/SCK/SCL
RD0/PSP0
RD1/PSP1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
PIC16F874A/877A
Figure 1.2: 16F877 Pin-out (reproduced by permission of Microchip Inc.)
Ch01-H8960.indd 4
Ch01-H8960.indd 4 6/10/2008 4:56:53 PM
6/10/2008 4:56:53 PM
PIC Microcontroller Systems 5
www.newnespress.com
subroutines, a similar process occurs. The stack is used to store return addresses, so
that the program can return automatically to the original program position. However,
this mechanism is not used by the CCS C compiler, as it limits the number of levels of
subroutine (or C functions) to eight, which is the depth of the stack. Instead, a simple
GOTO instruction is used for function calls and returns, with the return address computed
by the compiler.
Flash
ROM
Program
Memory
8192
⫻ 14 bits
Program Counter
(13 bits)
Address
Instructions
File Address
Program Address
Stack
13 bits
⫻ 8
Levels
RAM
File
Registers
368
⫻ 8 bits
Instruction Register
File Select
Register
MCU
control
lines
Working (W)
Register
Arithmetic & Logic
Unit
Status (Flag)
Register
Literal
Status
Op-
code Data Bus
(8 bits)
Instruction
Decode &
CPU control
EEPROM
256 bytes
Ports, Timers
ADC, Serial I/O
Clock Reset
Port A B C D E
Timing control
Figure 1.3: PIC16F877 MCU Block Diagram
Ch01-H8960.indd 5
Ch01-H8960.indd 5 6/10/2008 4:56:53 PM
6/10/2008 4:56:53 PM
6 Part 1
www.newnespress.com
Table 1.1: PIC16F877 Simplified File Register Map
Bank 0 (000–07F) Bank 1 (080–0FF) Bank 2 (100–180) Bank 3 (180–1FF)
Address Register Address Register Address Register Address Register
000h Indirect 080h Indirect 100h Indirect 180h Indirect
001h Timer0 081h Option 101h Timer0 181h Option
002h
Prog.
count.
low
082h
Prog.
count.
low
102h
Prog.
count.
low
182h
Prog.
count.
low
003h Status reg 083h Status reg 103h Status reg 183h Status reg
004h File select 084h File select 104h File select 184h File select
005h
Port A
data
085h
Port A
direction
105h — 185h —
006h Port B
data
086h Port B
direction
106h
Port B
data
186h Port B
direction
007h
Port C
data
087h
Port C
direction
107h — 187h —
008h
Port D
data
088h
Port D
direction
108h — 188h —
009h
Port E
data
089h
Port E
direction
109h — 189h —
00Ah
Prog.
count.
high
08Ah
Prog.
count.
high
10Ah
Prog.
count.
high
18Ah
Prog.
count.
high
00Bh
Interrupt
control
08Bh
Interrupt
control
10Bh
Interrupt
control
18Bh
Interrupt
control
00Ch–
01Fh
20
peripheral
control
registers
08Ch–
09Fh
20
peripheral
control
registers
10Ch–
10Fh
4
peripheral
control
registers
18Ch–
18Fh
4
peripheral
control
registers
110h–
11Fh
16 general
purpose
registers
190h–
19Fh
16 general
purpose
registers
020h–
06Fh
80 general
purpose
registers
0A0h–
0EFh
80 general
purpose
registers
120h–
16Fh
80 general
purpose
registers
1A0h–
1EFh
80 general
purpose
registers
070h–
07Fh
16
common
access
GPRs
0F0h–
0FFh
Accesses
070h–
07Fh
170h–
17Fh
Accesses
070h–
07Fh
1F0h–
1FFh
Accesses
070h–
07Fh
Ch01-H8960.indd 6
Ch01-H8960.indd 6 6/10/2008 4:56:54 PM
6/10/2008 4:56:54 PM
PIC Microcontroller Systems 7
www.newnespress.com
RAM File Registers
The main RAM block (Table 1.1) is a set of 368 8-bit file registers, including the special
function registers (SFRs), which have a dedicated function, and the general purpose
registers (GPRs). When variables are created in C, they are stored in the GPRs, starting at
address 0020h. The file registers are divided into four blocks, register banks 0 to 3. The
SFRs are located at the low addresses in each RAM bank.
Some registers are addressable across the bank boundaries; for example, the status
register can be accessed in all blocks at the corresponding address in each bank. Others
are addressable in only a specific page, for example, Port A data register. Some register
addresses are not physically implemented. Since some registers are accessible in multiple
banks, bank switching can be minimized by the compiler when assembling the machine
code, thus saving program code space and execution time. For full details of the file
register set, see the MCU data sheet.
The program counter uses two 8-bit registers to store a 13-bit program memory address.
Only the low byte at address 002h is directly addressable. The status register 003h
records results from ALU (arithmetic and logic unit) operations, such as zero and carry/
borrow. The indirect and file select registers are used for indexed addressing of the GPRs.
Timer0 is the timer/counter register available in all PIC MCUs, while Timer1 and Timer2
registers are in the peripheral block. The port registers are located in Bank 0 at addresses
05h (Port A) to 09h (Port E) with the data direction register for each at the corresponding
location in bank 1. We can see that a total of 80 ⫹ 16 ⫹ 80 ⫹ 96 ⫹ 96 ⫽ 368 GPRs are
available for use as data RAM. Note that the number of registers used for each C variable
depends on the variable type and can range from 1 to 32 bits (1–4 GPRs).
Other PIC Chips
In any embedded design, the features of the MCU need to be matched to the application
requirements. The manufacturer needs to make sure that, as applications become more
demanding, a more powerful device of a familiar type is available. We can see this
process at work where Microchip started out producing basic chips such as the 16C84,
then developed the product range to meet the growing market. PIC microcontrollers are
currently available in distinct groups, designated the 10, 12, 16, 18, and 24 series. Their
general characteristics are outlined in Table 1.2.
The original 16 series CMOS devices were designated as 16CXX. When flash memory
was introduced, they became 16FXXX. Currently, a limited number of devices are
Ch01-H8960.indd 7
Ch01-H8960.indd 7 6/10/2008 4:56:54 PM
6/10/2008 4:56:54 PM
8 Part 1
www.newnespress.com
available in the low pin count (LPC) ranges (10/12 series), while the power ranges are
expanding rapidly. In addition are those listed in the 24HXXXX range, which runs at 40
MIPS, and the dsPIC (digital signal processor) high-specification range.
1.2 PIC16 MCU Configuration
● Clock oscillator types
● Watchdog, power-up, brown-out timers
● Low-voltage programming
● Code protection
● In-circuit debug mode
When programming the PIC microcontroller, certain operational modes must be set
prior to the main program download. These are controlled by individual bits in a special
Table 1.2: PIC Microcontroller Types
MCU Pins Data
Word
(bits)
Program
Memory
(bytes)
Typical
Instruction
Set
Speed
MIPS
Description
10FXXX ⫽ 6 8 ⱕ512 33 ⫻ 12 bits ⱕ2
Low pin count, small
form factor, cheap, no
EEPROM, no low-power,
assembler program
12FXXX ⫽ 8 8 ⱕ2 kB 12/14 bits ⱕ0.5
Low pin count, small form
factor, cheap, EEPROM,
10-bit ADC, some low
power, assembler
16FXXX ⱕ64 8 ⱕ14 kB 35 ⫻ 14 bits ⱕ5
Mid-range, UART, I2C,
SPI, many low power, C or
assembler program
18FXXXX ⱕ100 8 ⱕ128 kB 75 ⫻ 16 bits ⱕ16
High range, CAN, USB
J series 3V supply, C
program
24FXXXX ⱕ100 16 ⱕ128 kB 76 ⫻ 24 bits ⫽ 16
Power range, 3V supply,
no EEPROM, data RAM
ⱕ8 kB, C program
Ch01-H8960.indd 8
Ch01-H8960.indd 8 6/10/2008 4:56:54 PM
6/10/2008 4:56:54 PM
PIC Microcontroller Systems 9
www.newnespress.com
configuration register separated from the main memory block. The main options are as
follows.
Clock Options
The ‘877 chip has two main clock modes, CR and XT. The CR mode needs a simple
capacitor and resistor circuit attached to CLKIN, whose time constant (C ⫻ R)
determines the clock period. R should be between 3k and 100k, and C greater than 20pF.
For example, if R ⫽ 10kΩ and C ⫽ 10nF, the clock period will be around 2 ⫻ C ⫻
R ⫽ 200 μs (calculated from the CR rise/fall time) and the frequency about 5kHz. This
option is acceptable when the program timing is not critical.
The XT mode is the one most commonly used, since the extra component cost is small
compared with the cost of the chip itself and accurate timing is often a necessity. An
external crystal and two capacitors are fitted to CLKIN and CLKOUT pins. The crystal
frequency in this mode can be from 200kHz to 4MHz and is typically accurate to better
than 50ppm (parts per million) or 0.005%. A convenient value is 4Mz, as this is the
maximum frequency possible with a standard crystal and gives an instruction execution
time of 1.000 μs (1 million instructions per second, or 1Mip).
A low-speed crystal can be used to reduce power consumption, which is proportional to
clock speed in CMOS devices. The LP (low-power) mode supports the clock frequency
range 32–200kHz. To achieve the maximum clock speed of 20MHz, a high-speed (HS)
crystal is needed, with a corresponding increase in power consumption.
The MCU configuration fuses must be set to the required clock mode when the chip is
programmed. Many PIC chips now have an internal oscillator, which needs no external
components. It is more accurate than the RC clock but less accurate than a crystal. It
typically runs at 8MHz and can be calibrated in the chip configuration phase to provide a
more accurate timing source.
Configuration Options
Apart from the clock options, several other hardware options must be selected.
Watchdog Timer
When enabled, the watchdog timer (WDT) automatically resets the processor after a
given period (default 18ms). This allows, for example, an application to escape from
an endless loop caused by a program bug or run-time condition not anticipated by the
Ch01-H8960.indd 9
Ch01-H8960.indd 9 6/10/2008 4:56:54 PM
6/10/2008 4:56:54 PM
10 Part 1
www.newnespress.com
software designer. To maintain normal operation, the WDT must be disabled or reset
within the program loop before the set time-out period has expired. It is therefore
important to set the MCU configuration bits to disable the WDT if it is not intended to
use this feature. Otherwise, the program is liable to misbehave, due to random resetting of
the MCU.
Power-up Timer
The power-up timer (PuT) provides a nominal 72ms delay between the power supply
voltage reaching the operating value and the start of program execution. This ensures
that the supply voltage is stable before the clock starts up. It is recommended that it be
enabled as a precaution, as there is no adverse effect on normal program execution.
Oscillator Start-up Timer
After the power-up timer has expired, a further delay allows the clock to stabilize before
program execution begins. When one of the crystal clock modes is selected, the CPU
waits 1024 cycles before the CPU is enabled.
Brown-out Reset (BoR)
It is possible for a transitory supply voltage drop, or brown-out, to disrupt the MCU
program execution. When enabled, the brown-out detection circuit holds the MCU in
reset while the supply voltage is below a given threshold and releases it when the supply
has recovered. In CCS C, a low-voltage detect function triggers an interrupt that allows
the program to be restarted in an orderly way.
Code Protection (CP)
The chip can be configured during programming to prevent the machine code being read
back from the chip to protect commercially valuable or secure code. Optionally, only
selected portions of the program code may be write protected (see WRT_X% later).
In-Circuit Programming and Debugging
Most PIC chips now support in-circuit programming and debugging (ICPD), which
allows the program code to be downloaded and tested in the target hardware, under the
control of the host system. This provides a final test stage after software simulation has
been used to eliminate most of the program bugs. MPLAB allows the same interface to be
Ch01-H8960.indd 10
Ch01-H8960.indd 10 6/10/2008 4:56:55 PM
6/10/2008 4:56:55 PM
PIC Microcontroller Systems 11
www.newnespress.com
used for debugging in both the simulation and in-circuit modes. The slight disadvantage
of this option is that care must be taken that any application circuit connected to the
programming/ICPD pins does not interfere with the operation of these features. It is
preferable to leave these pins for the exclusive use of the ICPD system. In addition, a
small section of program memory is required to run the debugging code.
Low-Voltage Programming Mode
The low-voltage programming mode can be selected during programming so that
the customary high (12V) programming voltage is not needed, and the chip can be
programmed at Vdd (⫹5V). The downside is that the programming pin cannot then be
used for digital I/O. In any case, it is recommended here that the programming pins not
be used for I/O by the inexperienced designer, as hardware contention could occur.
Electrically Erasable Programmable Read Only Memory
Many PIC MCUs have a block of nonvolatile user memory where data can be stored
during power-down. These data could, for example, be the secure code for an electronic
lock or smart card reader. The electrically erasable programmable read only memory
(EEPROM) can be rewritten by individual location, unlike flash program ROM. The ‘877
has a block of 256 bytes, which is a fairly typical value. There is a special read/write
sequence to prevent accidental overwriting of the data.
Configuration in C
The preprocessor directive #fuses is used to set the configuration fuses in C programs
for PICs. A typical statement is
#fuses XT,PUT,NOWDT,NOPROTECT,NOBROWNOUT
The options defined in the standard CCS C 16F877 header file are
Clock Type Select LP, XT, HS, RC
Watchdog Timer Enable WDT, NOWDT
Power Up Timer Enable PUT, NOPUT
Program Code Protect PROTECT, NOPROTECT
In Circuit Debugging Enable DEBUG, NODEBUG
Brownout Reset Enable BROWNOUT, NOBROWNOUT
Low Voltage Program Enable LVP, NOLVP
EEPROM Write Protect CPD, NOCPD
Program Memory Write Protect WRT_50%, WRT_25%,
(with percentage protected) WRT_5%, NOWRT
Ch01-H8960.indd 11
Ch01-H8960.indd 11 6/10/2008 4:56:55 PM
6/10/2008 4:56:55 PM
12 Part 1
www.newnespress.com
The default condition for the fuses if no such directive is included is equivalent to
#fuses RC,WDT,NOPUT,BROWNOUT,LVP,NOCPD,NOWRT
This corresponds to all the bits of configuration register being default high.
1.3 PIC16 MCU Peripherals
● Digital I/O
● Timers
● A/D converter
● Comparator
● Parallel slave port
● Interrupts
Basic digital input and output (I/O) in the microcontroller uses a bidirectional port
pin. The default pin configuration is generally digital input, as this is the safest option
if some error has been made in the external connections. To set the pin as output, the
corresponding data direction bit must be cleared in the port data direction register (e.g.,
TRISD). Note, however, that pins connected to the analog-to-digital (A/D) converter
default to the analog input mode.
The basic digital I/O hardware is illustrated in simplified form in Figure 1.4, with
provision for analog input. The 16 series reference manual shows equivalent circuits for
individual pins in more detail. For input, the current driver output is disabled by loading
the data direction bit with a 1, which switches off the tristate gate. Data are read into the
input data latch from the outside world when its control line is pulsed by the CPU in the
course of a port register read instruction. The data are then copied to the CPU working
register for processing.
When the port is set up for output, a 0 is loaded into the data direction bit, enabling the
current output. The output data are loaded into the data latch from the CPU. A data 1 at
the output allows the current driver to source up to 25mA at 5V, or whatever the supply
voltage is (2–6V). A data 0 allows the pin to sink a similar current at 0V.
Ch01-H8960.indd 12
Ch01-H8960.indd 12 6/10/2008 4:56:55 PM
6/10/2008 4:56:55 PM
PIC Microcontroller Systems 13
www.newnespress.com
The 16F877 has the following digital I/O ports available:
Port A RA0–RA5 6 bits
Port B RB0–RB7 8 bits
Port C RC0–RC7 8 bits
Port D RD0–RD7 8 bits
Port E RE0–RE2 3 bits
Total digital I/O available 33 pins
Most of the pins have alternate functions, which are described later.
Timers
Most microcontrollers provide hardware binary counters that allow a time interval
measurement or count to be carried out separately from program execution. For example,
a fixed period output pulse train can be generated while the program continues with
another task. The features of the timers found in the typical PIC chip are represented in
Figure 1.5, but none of those in the ‘877 has all the features shown.
The count register most commonly is operated by driving it from the internal instruction
clock to form a timer. This signal runs at one quarter of the clock frequency; that is, one
instruction takes four cycles to execute. Therefore, with a 4-MHz clock, the timer counts
in microseconds (1-MHz instruction clock). The number of bits in the timer (8 or 16)
Data
Direction
Latch
Output
Data
Latch
Input
Data
Latch
Output
Current
Driver
Tristate
Output
Enable
Write TRIS bit
CPU Data Bus
Write Data bit
Read Data bit
Analog Input
Multiplexer
Figure 1.4: I/O Pin Operation
Ch01-H8960.indd 13
Ch01-H8960.indd 13 6/10/2008 4:56:55 PM
6/10/2008 4:56:55 PM
14 Part 1
www.newnespress.com
determines the maximum count (256 or 65536, respectively). When the timer register
overflows and returns to zero, an overflow flag bit is set. This flag can be polled (tested)
to check if an overflow has occurred or an interrupt generated, to trigger the required
action.
To modify the count period, the timer register can be preloaded with a given number.
For example, if an 8-bit register is preloaded with the value 156, a time-out occurs after
256 ⫺ 156 ⫽ 100 clocks. Many timer modules allow automatic preloading each time
it is restarted, in which case the required value is stored in a preload register during timer
initialization.
A prescaler typically allows the timer input frequency to be divided by 2, 4, 8, 16, 32,
64, or 128. This extends the maximum count proportionately but at the expense of timer
precision. For example, the 8-bit timer driven at 1MHz with a prescale value of 4 counts
up to 256 ⫻ 4 ⫽ 1024 μs, at 4 μs per bit. A postscaler has a similar effect, connected at
the output of the counter.
In the compare mode, a separate period register stores a value that is compared with the
current count after each clock and the status flag set when they match. This is a more
elegant method of modifying the time-out period, which can be used in generating a pulse
width modulated (PWM) output. A typical application is to control the output power to
a current load, such as a small DC motor—more on this later. In the capture mode, the
timer count is captured (copied to another register) at the point in time when an external
signal changes at one of the MCU pins. This can be used to measure the length of an
input pulse or the period of a waveform.
The ’877 has three counter/timer registers. Timer0 has an 8-bit counter and 8-bit
prescaler. It can be clocked from the instruction clock or an external signal applied to
RA4. The prescaler can also be used to extend the watchdog timer interval (see later),
in which case it is not available for use with Timer0. Timer1 has a 16-bit counter and
prescaler and can be clocked internally or externally as per Timer0. It offers capture and
Clock
Source
Select
Prescaler
(Clock
Divide)
Postscaler
(Output
Divide)
Timer
Overflow/
Time-out
(Interrupt)
Flag
Capture Signal Capture Register
Compare Register
Binary Counter
Match Flag
Instruction Clock
External Pulse
Figure 1.5: General Timer Operation
Ch01-H8960.indd 14
Ch01-H8960.indd 14 6/10/2008 4:56:55 PM
6/10/2008 4:56:55 PM
PIC Microcontroller Systems 15
www.newnespress.com
compare modes of operation. Timer2 is another 8-bit counter but has both a prescaler and
postscaler (up to 1:16) and a compare register for period control.
Further details are provided in Interfacing PIC Microcontrollers by the author and the
MCU data books. When programming in C, only a limited knowledge of timer operation
is necessary, as the C functions generally take care of the details.
A/D Converter
Certain PIC pins can be set up as inputs to an analog-to-digital converter (ADC). The
’877 has eight analog inputs, which are connected to Port A and Port E. When used
in this mode, they are referred to as AD0–AD7. The necessary control registers are
initialized in CCS C using a set of functions that allow the ADC operating mode and
inputs to be selected. An additional “device” directive at the top of the program sets the
ADC resolution. An analog voltage presented at the input is then converted to binary and
the value assigned to an integer variable when the function to read the ADC is invoked.
The default input range is set by the supply (nominally 0–5V). If a battery supply is used
(which drops over time) or additional accuracy is needed, a separate reference voltage
can be fed in at AN2 (⫹Vref) and optionally AN3 (–Vref). If only ⫹Vref is used, the
lower limit remains 0V, while the upper is set by the reference voltage. This is typically
supplied using a zener diode and voltage divider. The 2.56V derived from a 2V7 zener
gives a conversion factor of 10mV per bit for an 8-bit conversion. For a 10-bit input,
a reference of 4.096V might be convenient, giving a resolution of 4mV per bit. The
essentials of ADC operation are illustrated in Figure 1.6.
Comparator
The comparator (Figure 1.7) is an alternative type of analog input found in some
microcontrollers, such as the 16F917 used in the mechatronics board described later.
Figure 1.6: ADC Operation
Multiplexer
Input
Volts
0-Vf
Setup ADC
Read ADC
8-bit or 16-bit
Integer Result
Analog-
to-Digital
Converter
ANx
⫹Vref
Analog
Inputs
Reference Volts
Ch01-H8960.indd 15
Ch01-H8960.indd 15 6/10/2008 4:56:56 PM
6/10/2008 4:56:56 PM
Another Random Document on
Scribd Without Any Related Topics
string have been washed. As it grows up, the tree is called the
“contemporary” of the child.870
So in Bali a cocoa-palm is planted at
the birth of a child. It is believed to grow up equally with the child,
and is called its “life-plant.”871
On certain occasions the Dyaks of
Borneo plant a palm-tree, which is believed to be a complete index
of their fate. If it flourishes, they reckon on good fortune; but if it
withers or dies, they [pg 330] expect misfortune.872
It is said that
there are still families in Russia, Germany, England, France, and Italy
who are accustomed to plant a tree at the birth of a child. The tree,
it is hoped, will grow with the child, and it is tended with special
care.873
The custom is still pretty general in the canton of Aargau in
Switzerland; an apple-tree is planted for a boy and a pear-tree for a
girl, and the people think that the child will flourish or dwindle with
the tree.874
In Mecklenburg the after-birth is thrown out at the foot
of a young tree, and the child is then believed to grow with the
tree.875
In England persons are sometimes passed through a cleft
tree as a cure for rupture, and thenceforward a sympathetic
connection is believed to exist between them and the tree. “Thomas
Chillingworth, son of the owner of an adjoining farm, now about
thirty-four years of age, was, when an infant of a year old, passed
through a similar tree, now perfectly sound, which he preserves with
so much care that he will not suffer a single branch to be touched,
for it is believed that the life of the patient depends on the life of the
tree; and the moment that it is cut down, be the patient ever so
distant, the rupture returns, and a mortification ensues.”876
When
Lord Byron first visited his ancestral estate of Newstead “he planted,
it seems, a young oak in some part of the grounds, and had an idea
that as it flourished so should he.”877
But in practice, as in folk-tales, it is not merely [pg 331] with trees
and plants that the life of an individual is occasionally believed to be
united by a bond of physical sympathy. The same bond, it is
supposed, may exist between a man and an animal or a thing, so
that the death or destruction of the animal or thing is immediately
followed by the death of the man. The Emperor Romanus Lecapenus
was once informed by an astronomer that the life of Simeon prince
of Bulgaria was bound up with a certain column in Constantinople,
so that if the capital of the column were removed Simeon would
immediately die. The Emperor took the hint and removed the capital,
and at the same hour, as the emperor learned by inquiry, Simeon
died of heart disease in Bulgaria.878
Amongst the Karens of Burma
“the knife with which the navel-string is cut is carefully preserved for
the child. The life of the child is supposed to be in some way
connected with it, for if lost or destroyed it is said the child will not
be long-lived.”879
The Malays believe that “the soul of a person may
pass into another person or into an animal, or rather that such a
mysterious relation can arise between the two that the fate of the
one is wholly dependent on that of the other.”880
In the Banks
Islands “some people connect themselves with an object, generally
an animal, as a lizard or a snake, or with a stone, which they
imagine to have a certain very close natural relation to themselves.
This, at Mota, is called tamaniu—likeness. This word at Aurora is
used for the ‘atai’ [i.e. soul] of Mota. Some fancy dictates the choice
of a tamaniu; or it may be [pg 332] found by drinking the infusion of
certain herbs and heaping together the dregs. Whatever living thing
is first seen in or upon the heap is the tamaniu. It is watched, but
not fed or worshipped. The natives believe that it comes at call. The
life of the man is bound up with the life of his tamaniu. If it dies,
gets broken or lost, the man will die. In sickness they send to see
how the tamaniu is, and judge the issue accordingly. This is only the
fancy of some.”881
But what among the Banks Islanders and the Malays is irregular and
occasional, among other peoples is systematic and universal. The
Zulus believe that every man has his ihlozi, a kind of mysterious
serpent, “which specially guards and helps him, lives with him,
wakes with him, sleeps and travels with him, but always under
ground. If it ever makes its appearance, great is the joy, and the
man must seek to discover the meaning of its appearance. He who
has no ihlozi must die. Therefore if any one unintentionally kills an
ihlozi serpent, the man whose ihlozi it was dies, but the serpent
comes to life again.”882
Amongst the Zapotecs of Central America,
when a woman was about to be confined, her relations assembled in
the hut, and began to draw on the floor figures of different animals,
rubbing each one out as soon as it was completed. This went on till
the moment of birth, and the figure that then remained sketched
upon the ground was called the child's tona or second self. “When
the child grew old enough he procured the animal that represented
him and took care of it, as it [pg 333] was believed that health and
existence were bound up with that of the animal's, in fact that the
death of both would occur simultaneously,” or rather that when the
animal died the man would die.883
Among the Indians of Guatemala
the nagual or naual is an “animate or inanimate object, generally an
animal, which stands in a parallel relation to a particular man, so
that the weal and woe of the man depend on the fate of the animal.”
Among the Chontal Indians who inhabit the part of Honduras
bordering on Guatemala and in point of social culture stand very
close to the Pipil Indians of Guatemala, the nagual used to be
obtained as follows. The young Indian went into the forest to a
lonely place by a river or to the top of a mountain, and prayed with
tears to the gods that they would vouchsafe to him what his
forefathers had possessed before him. After sacrificing a dog or a
bird he laid himself down to sleep. Then in a dream or after
awakening from sleep there appeared to him a jaguar, puma, coyote
(prairie-wolf), crocodile, serpent, or bird. To this visionary animal the
Indian offered blood drawn from his tongue, his ears, and other
parts of his body, and prayed for an abundant yield of salt and
cacao. Then the animal said to him, “On such and such a day you
shall go out hunting, and the first animal that meets you will be
myself, who will always be your companion and nagual.” A man who
had no nagual could never grow rich. The Indians were persuaded
that the death of their nagual would entail their own. Legend affirms
that in the first battles with the Spaniards on [pg 334] the plateau of
Quetzaltenango the naguals of the Indian chiefs fought in the form
of serpents. The nagual of the highest chief was especially
conspicuous, because it had the form of a great bird, resplendent in
green plumage. The Spanish general Pedro de Alvarado killed the
bird with his lance, and at the same moment the Indian chief fell
dead to the ground.884
In many of the Australian tribes each sex regards a particular
species of animals in the same way that a Central American Indian
regards his nagual, but with this difference, that whereas the Indian
apparently knows the individual animal with which his life is bound
up, the Australians only know that each of their lives is bound up
with some one animal of the species, but they cannot say with
which. The result naturally is that every man spares and protects all
the animals of the species with which the lives of the men are bound
up; and every woman spares and protects all the animals of the
species with which the lives of the women are bound up; because no
one knows but that the death of any animal of the respective species
might entail his or her own; just as the killing of the green bird was
immediately followed by the death of the Indian chief, and the killing
of the parrot by the death of Punchkin in the fairy tale. Thus, for
example, the Wotjobaluk tribe of South Eastern Australia “held that
‘the life of Ngŭnŭngŭnŭt (the Bat) is the life of a man and the life of
Yártatgŭrk (the Nightjar) is the life of a woman,’ and that when
either of these creatures is killed the life of some man or of some
woman is shortened. In such a case every man or every woman [pg
335] in the camp feared that he or she might be the victim, and
from this cause great fights arose in this tribe. I learn that in these
fights, men on one side and women on the other, it was not at all
certain which would be victorious, for at times the women gave the
men a severe drubbing with their yamsticks while often women were
injured or killed by spears.”885
The particular species of animals with
which the lives of the sexes were believed to be respectively bound
up varied somewhat from tribe to tribe. Thus whereas among the
Wotjobaluk the bat was the animal of the men, at Gunbower Creek
on the lower Murray the bat seems to have been the animal of the
women, for the natives would not kill it for the reason that “if it was
killed, one of their lubras [women] would be sure to die in
consequence.”886
But the belief itself and the fights to which it gave
rise are known to have extended over a large part of South Eastern
Australia, and probably they extended much farther.887
The belief is a
very serious one, and so consequently are the fights which spring
from it. Thus where the bat is the men's animal they “protect it
against injury, even to the half-killing of their wives for its sake;” and
where the fern owl or large goatsucker (a night bird) is the women's
animal, “it is jealously protected by them. If a man kills one, they
are as much enraged as if it was one of their children, and will strike
him with their long poles.”888
The jealous protection thus afforded by Australian men and women
to bats and owls respectively (for bats [pg 336] and owls seem to be
the creatures usually allotted to men and women respectively) is not
based upon purely selfish considerations. For each man believes that
not only his own life, but the lives of his father, brothers, sons, etc.,
are bound up with the lives of particular bats, and that therefore in
protecting the bat species he is protecting the lives of all his male
relations as well as his own. Similarly, each woman believes that the
lives of her mother, sisters, daughters, etc., equally with her own,
are bound up with the lives of particular owls, and that in guarding
the owl species she is guarding the lives of all her female relations in
addition to her own. Now, when men's lives are thus supposed to be
contained in certain animals, it is obvious that the animals can
hardly be distinguished from the men, or the men from the animals.
If my brother John's life is in a bat, then, on the one hand, the bat is
my brother as well as John; and, on the other hand, John is in a
sense a bat, since his life is in a bat. Similarly, if my sister Mary's life
is in an owl, then the owl is my sister and Mary is an owl. This is a
natural enough conclusion, and the Australians have not failed to
draw it. When the bat is the man's animal, it is called his brother;
and when the owl is the woman's animal, it is called her sister. And
conversely a man addresses a woman as an owl, and she addresses
him as a bat.889
So with the other animals allotted to the sexes
respectively in other tribes. For example, among the Kurnai all Emu
Wrens were “brothers” of the men, and all the men were Emu
Wrens; all Superb Warblers were “sisters” of the women, and all the
women were Superb Warblers.890
[pg 337]
But when a savage names himself after an animal, calls it his
brother, and refuses to kill it, the animal is said to be his totem.
Accordingly the bat and the owl, the Emu Wren and the Superb
Warbler, may properly be described as totems of the sexes. But the
assignation of a totem to a sex is comparatively rare, and has
hitherto been discovered nowhere but in Australia. Far more
commonly the totem is appropriated not to a sex, but to a tribe or
clan, and is hereditary either in the male or female line. The relation
of an individual to the tribal totem does not differ in kind from his
relation to the sex totem; he will not kill it, he speaks of it as his
brother, and he calls himself by its name.891
Now if the relations are
similar, the explanation which holds good of the one ought equally to
hold good of the other. Therefore the reason why a tribe revere a
particular species of animals or plants (for the tribal totem may be a
plant) and call themselves after it, must be a belief that the life of
each individual of the tribe is bound up with some one animal or
plant of the species, and that his or her death would be the
consequence of killing that particular animal, or destroying that
particular plant. This explanation of totemism squares very well with
Sir George Grey's definition of a totem or kobong in Western
Australia. He says, “A certain mysterious connection exists between
a family and its kobong, so that a member of the family will never
kill an animal of the species to which his kobong belongs, should he
find it asleep; indeed he always kills it reluctantly, and never without
affording it a chance to escape. This arises from the family belief
that some one individual of the species is their nearest friend, to [pg
338] kill whom would be a great crime, and to be carefully avoided.
Similarly, a native who has a vegetable for his kobong may not
gather it under certain circumstances, and at a particular period of
the year.”892
Here it will be observed that though each man spares all
the animals or plants of the species, they are not all equally precious
to him; far from it, out of the whole species there is only one which
is specially dear to him; but as he does not know which the dear one
is, he is obliged to spare them all from fear of injuring the one.
Again, this explanation of the tribal totem harmonises with the
supposed effect of killing one of the totem species. “One day one of
the blacks killed a crow. Three or four days afterwards a Boortwa
(crow) [i.e. a man of the Crow clan or tribe] named Larry died. He
had been ailing for some days, but the killing of his wingong [totem]
hastened his death.”893
Here the killing of the crow caused the death
of a man of the Crow clan, exactly as, in the case of the sex totems,
the killing of a bat causes the death of a Bat man, or the killing of an
owl causes the death of an Owl woman. Similarly, the killing of his
nagual causes the death of a Central American Indian, the killing of
his ihlozi causes the death of a Zulu, the killing of his tamaniu
causes the death of a Banks Islander, and the killing of the animal in
which his life is stowed away causes the death of the giant or
warlock in the fairy tale.
Thus it appears that the story of “The giant who had no heart in his
body” furnishes the key to the religious aspect of totemism, that is,
to the relation which is supposed to subsist between a man and his
totem. The totem, if I am right, is simply the receptacle [pg 339] in
which a man keeps his life, as Punchkin kept his life in a parrot, and
Bidasari kept her soul in a golden fish. It is no valid objection to this
view that when a savage has both a sex totem and a tribal totem his
life must be bound up with two different animals, the death of either
of which would entail his own. If a man has more vital places than
one in his body, why, the savage may think, should he not have
more vital places than one outside it? Why, since he can externalise
his life, should he not transfer one portion of it to one animal and
another to another? The divisibility of life, or, to put it otherwise, the
plurality of souls, is an idea suggested by many familiar facts, and
has commended itself to philosophers like Plato as well as to
savages. It is only when the notion of a soul, from being a quasi-
scientific hypothesis, becomes a theological dogma that its unity and
indivisibility are insisted upon as essential. The savage, unshackled
by dogma, is free to explain the facts of life by the assumption of as
many souls as he thinks necessary. Hence, for example, the Caribs
supposed that there was one soul in the head, another in the heart,
and other souls at all the places where an artery is felt pulsating.894
Some of the Hidatsa Indians explain the phenomena of gradual
death, when the extremities appear dead first, by supposing that
man has four souls, and that they quit the body, not simultaneously,
but one after the other, dissolution being only complete when all
four have departed.895
The Laos suppose that the body is the seat of
thirty spirits, which reside in the hands, the feet, the mouth, the
eyes, etc.896
Hence, [pg 340] from the primitive point of view, it is
perfectly possible that a savage should have one soul in his sex
totem, and another in his tribal totem. However, as I have observed,
sex totems occur nowhere but in Australia; so that as a rule the
savage who practises totemism need not have more than one soul
out of his body at a time.
If this explanation of the totem as a receptacle in which a man
keeps his soul or one of his souls is correct, we should expect to find
some totemistic tribes of whom it is expressly stated that every man
amongst them is believed to keep at least one soul permanently out
of his body, and that the destruction of this external soul is supposed
to entail the death of its owner. Such a tribe are the Battas of
Sumatra. The Battas are divided into exogamous clans (margas)
with descent in the male line; and each clan is forbidden to eat the
flesh of a particular animal. One clan may not eat the tiger, another
the ape, another the crocodile, another the dog, another the cat,
another the dove, another the white buffalo. The reason given by
members of a clan for abstaining from the flesh of the particular
animal is either that they are descended from animals of that
species, and that their souls after death may transmigrate into the
animals, or that they or their forefathers have been under certain
obligations to the animals. Sometimes, but not always, the clan
bears the name of the animal.897
Thus the Battas have [pg 341]
totemism in full. But, further, each Batta believes that he has seven
or, on a more moderate computation, three souls. One of these souls
is always outside the body, but nevertheless whenever it dies,
however far away it may be at the time, that same moment the man
dies also.898
The writer who mentions this belief says nothing about
the Batta totems; but on the analogy of the Australian and Central
American evidence we can scarcely avoid concluding that the
external soul, whose death entails the death of the man, must be
housed in the totem animal or plant.
Against this view it can hardly be thought to militate that the Batta
does not in set terms affirm his external soul to be in his totem, but
alleges other, though hardly contradictory, grounds for respecting
the sacred animal or plant of his clan. For if a savage seriously
believes that his life is bound up with an external object, it is in the
last degree unlikely that he will let any stranger into the secret. In all
that touches his inmost life and beliefs the savage is exceedingly
suspicious and reserved; Europeans have resided among savages for
years without discovering some of their capital articles of faith, and
in the end the discovery has often been the result of accident. Above
all, the savage lives in an intense and perpetual dread of
assassination by sorcery; the most trifling relics of his person—the
clippings of his hair and nails, his spittle, the remnants of his food,
his very name—all these may, he fancies, be turned by the sorcerer
to his destruction, and he is therefore anxiously careful to conceal or
destroy them. But if in matters such as [pg 342] these, which are
but the outposts and outworks of his life, he is shy and secretive to a
degree, how close must be the concealment, how impenetrable the
reserve in which he enshrouds the inner keep and citadel of his
being! When the princess in the fairy tale asks the giant where he
keeps his soul, he generally gives false or evasive answers, and it is
only after much coaxing and wheedling that the secret is at last
wrung from him. In his jealous reticence the giant resembles the
timid and furtive savage; but whereas the exigencies of the story
demand that the giant should at last reveal his secret, no such
obligation is laid on the savage; and no inducement that can be
offered is likely to tempt him to imperil his soul by revealing its
hiding-place to a stranger. It is therefore no matter for surprise that
the central mystery of the savage's life should so long have
remained a secret, and that we should be left to piece it together
from scattered hints and fragments and from the recollections of it
which linger in fairy tales.
This view of totemism throws light on a class of religious rites of
which no adequate explanation, so far as I am aware, has yet been
offered. Amongst many savage tribes, especially such as are known
to practise totemism, it is customary for lads at puberty to undergo
certain initiatory rites, of which one of the commonest is a pretence
of killing the lad and bringing him to life again. Such rites become
intelligible if we suppose that their substance consists in extracting
the youth's soul in order to transfer it to his totem. For the extraction
of his soul would naturally be supposed to kill the youth or, at least,
to throw him into a death-like trance, which the savage hardly
distinguishes from death. His recovery would then be attributed
either [pg 343] to the gradual recovery of his system from the
violent shock which it had received, or, more probably, to the
infusion into him of fresh life drawn from the totem. Thus the
essence of these initiatory rites, so far as they consist in a simulation
of death and resurrection, would be an exchange of life or souls
between the man and his totem. The primitive belief in the
possibility of such an exchange of souls comes clearly out in the
story of the Basque hunter who affirmed that he had been killed by
a bear, but that the bear had, after killing him, breathed its own soul
into him, so that the bear's body was now dead, but he himself was
a bear, being animated by the bear's soul.899
This revival of the dead
hunter as a bear is exactly analogous to what, if I am right, is
supposed to take place in the totemistic ceremony of killing a lad at
puberty and bringing him to life again. The lad dies as a man and
comes to life again as an animal; the animal's soul is now in him,
and his human soul is in the animal. With good right, therefore, does
he call himself a Bear or a Wolf, etc., according to his totem; and
with good right does he treat the bears or the wolves, etc., as his
brethren, since in these animals are lodged the souls of himself and
his kindred.
Examples of this supposed death and resurrection at initiation are
the following. Among some of the Australian tribes of New South
Wales, when lads are initiated, it is thought that a being called
Thuremlin takes each lad to a distance, kills him, and sometimes
cuts him up, after which he restores him to life and knocks out a
tooth.900
In one part of Queensland the [pg 344] humming sound of
the Bullroarer, which is swung at the initiatory rites, is said to be the
noise made by the wizards in swallowing the boys and bringing them
up again as young men. “The Ualaroi of the Upper Darling River say
that the boy meets a ghost which kills him and brings him to life
again as a man.”901
This resurrection appears to be represented at
the initiatory rites by the following ceremony. An old man, disguised
with stringy bark fibre, lies down in a grave, and is lightly covered up
with sticks and earth, and as far as possible the natural appearance
of the ground is restored, the excavated earth being carried away.
The buried man holds a small bush in his hand; it appears to be
growing in the soil, and other bushes are stuck in the soil to
heighten the effect. The novices are then brought to the edge of the
grave, and a song is sung, in which the only words used are the
“class-name” of the buried man and the word for stringy bark fibre.
Gradually, as the song continues, the bush held by the buried man
begins to quiver and then to move more and more, and finally the
man himself starts up from the grave.902
Similarly, Fijian lads at
initiation were shown a row of apparently dead men, covered with
blood, their bodies seemingly cut open, and their entrails protruding.
But at a yell from the [pg 345] priest the pretended dead men
sprang to their feet and ran to the river to cleanse themselves from
the blood and entrails of pigs with which they had been
besmeared.903
In the valley of the Congo initiatory rites of this sort are common. In
some places they are called Ndembo. “In the practice of Ndembo the
initiating doctors get some one to fall down in a pretended fit, and in
that state he is carried away to an enclosed place outside the town.
This is called ‘dying Ndembo.’ Others follow suit, generally boys and
girls, but often young men and women.... They are supposed to
have died. But the parents and friends supply food, and after a
period varying, according to custom, from three months to three
years, it is arranged that the doctor shall bring them to life again....
When the doctor's fee has been paid, and money (goods) saved for
a feast, the Ndembo people are brought to life. At first they pretend
to know no one and nothing; they do not even know how to
masticate food, and friends have to perform that office for them.
They want everything nice that any one uninitiated may have, and
beat them if it is not granted, or even strangle and kill people. They
do not get into trouble for this, because it is thought that they do
not know better. Sometimes they carry on the pretence of talking
gibberish, and behaving as if they had returned from the spirit-
world. After this they are known by another name, peculiar to those
who have ‘died Ndembo.’ ... We hear of the custom far along on the
upper river, as well as in the cataract region.”904
The following
account of [pg 346] the rites, as practised in this part of Africa, was
given to Bastian by an interpreter. “In the land of Ambamba every
one must die once, and when the fetish priest shakes his calabash
against a village, all the men and lads whose hour is come fall into a
state of lifeless torpidity, from which they generally awake after
three days. But if the fetish loves a man he carries him away into the
bush and buries him in the fetish house, often for many years. When
he comes to life again, he begins to eat and drink as before, but his
understanding is gone and the fetish man must teach him and direct
him in every motion, like the smallest child. At first this can only be
done with a stick, but gradually his senses return, so that it is
possible to talk with him, and when his education is complete, the
priest brings him back to his parents. They would seldom recognise
their son but for the express assurances of the fetish priest, who
moreover recalls previous events to their memory. He who has not
gone through the ceremony of the new birth in Ambamba is
universally looked down upon and is not admitted to the dances.”
During the period of initiation the novice is sympathetically united to
the fetish by which his life is henceforward determined.905
The
novice, plunged in the magic sleep or death-like trance within the
sacred hut, “beholds a bird or other object with which his existence
is thenceforward sympathetically bound up, just as the life of the
young Indian is bound up with the animal which he sees in his
dreams at puberty.”906
[pg 347]
Rites of this sort were formerly observed in Quoja, on the west coast
of Africa, to the north of the Congo. They are thus described by an
old writer:—“They have another ceremony which they call Belli-
Paaro, but it is not for everybody. For it is an incorporation in the
assembly of the spirits, and confers the right of entering their
groves, that is to say, of going and eating the offerings which the
simple folk bring thither. The initiation or admission to the Belli-Paaro
is celebrated every twenty or twenty-five years. The initiated recount
marvels of the ceremony, saying that they are roasted, that they
entirely change their habits and life, and that they receive a spirit
quite different from that of other people and quite new lights. The
badge of membership consists in some lines traced on the neck
between the shoulders; the lines seem to be pricked with a needle.
Those who have this mark pass for persons of spirit, and when they
have attained a certain age they are allowed a voice in all public
assemblies; whereas the uninitiated are regarded as profane,
impure, and ignorant persons, who dare not express an opinion on
any subject of importance. When the time for the ceremony has
come, it is celebrated as follows: By order of the king a place is
appointed in the forest, whither they bring the youths who have not
been marked, not without much crying and weeping; for it is
impressed upon the youths that in order to undergo this change it is
necessary to suffer death. So they dispose of their property, as if it
were all over with them. There are always some of the initiated
beside the novices to instruct them. They teach them to dance a
certain dance called killing, and to sing verses in praise of Belli.
Above all, they are very careful not to let them die of hunger, [pg
348] because if they did so, it is much to be feared that the spiritual
resurrection would profit them nothing. This manner of life lasts five
or six years, and is comfortable enough, for there is a village in the
forest, and they amuse themselves with hunting and fishing. Other
lads are brought thither from time to time, so that the last comers
have not long to stay. No woman or uninitiated person is suffered to
pass within four or five leagues of the sacred wood. When their
instruction is completed, they are taken from the wood and shut up
in small huts made for the purpose. Here they begin once more to
hold communion with mankind and to talk with the women who
bring them their food. It is amusing to see their affected simplicity.
They pretend to know no one, and to be ignorant of all the customs
of the country, such as the customs of washing themselves, rubbing
themselves with oil, etc. When they enter these huts, their bodies
are all covered with the feathers of birds, and they wear caps of
bark which hang down before their faces. But after a time they are
dressed in clothes and taken to a great open place, where all the
people of the neighbourhood are assembled. Here the novices give
the first proof of their capacity by dancing a dance which is called
the dance of Belli. After the dance is over, the novices are taken to
the houses of their parents by their instructors.”907
Among the Indians of Virginia, an initiatory ceremony, called
Huskanaw, took place every sixteen or twenty years, or oftener, as
the young men happened to grow up. The youths were kept in
solitary confinement in the woods for several months, [pg 349]
receiving no food but an infusion of some intoxicating roots, so that
they went raving mad, and continued in this state eighteen or
twenty days. “Upon this occasion it is pretended that these poor
creatures drink so much of the water of Lethe that they perfectly
lose the remembrance of all former things, even of their parents,
their treasure, and their language. When the doctors find that they
have drank sufficiently of the Wysoccan (so they call this mad
potion), they gradually restore them to their senses again by
lessening the intoxication of their diet; but before they are perfectly
well they bring them back into their towns, while they are still wild
and crazy through the violence of the medicine. After this they are
very fearful of discovering anything of their former remembrance; for
if such a thing should happen to any of them, they must immediately
be Huskanaw'd again; and the second time the usage is so severe
that seldom any one escapes with life. Thus they must pretend to
have forgot the very use of their tongues, so as not to be able to
speak, nor understand anything that is spoken, till they learn it
again. Now, whether this be real or counterfeit, I don't know; but
certain it is that they will not for some time take notice of any body
nor any thing with which they were before acquainted, being still
under the guard of their keepers, who constantly wait upon them
everywhere till they have learnt all things perfectly over again. Thus
they unlive their former lives, and commence men by forgetting that
they ever have been boys.”908
Among some of the Indian tribes of North America there are certain
religious associations which are only open to candidates who have
gone through a pretence [pg 350] of being killed and brought to life
again. Captain Carver witnessed the admission of a candidate to an
association called “the friendly society of the Spirit” among the
Naudowessies. The candidate knelt before the chief, who told him
that “he himself was now agitated by the same spirit which he
should in a few moments communicate to him; that it would strike
him dead, but that he would instantly be restored again to life.... As
he spoke this, he appeared to be greatly agitated, till at last his
emotions became so violent that his countenance was distorted and
his whole frame convulsed. At this juncture he threw something that
appeared both in shape and colour like a small bean at the young
man, which seemed to enter his mouth, and he instantly fell as
motionless as if he had been shot.” For a time the man lay like dead,
but under a shower of blows he showed signs of consciousness, and
finally, discharging from his mouth the bean, or whatever it was the
chief had thrown at him, he came to life.909
In other tribes the
instrument by which the candidate is apparently slain is the
medicine-bag. The bag is made of the skin of an animal (such as the
otter, wild cat, serpent, bear, raccoon, wolf, owl, weasel), of which it
roughly preserves the shape. Each member of the society has one of
these bags, in which he keeps the odds and ends that make up his
“medicine” or charms. “They believe that from the miscellaneous
contents in the belly of the skin bag or animal there issues a spirit or
breath, which has the power, not only to knock down and kill a man,
but also to set him up and restore him to life.” The mode of killing a
man with one of these medicine-bags is to thrust it at him; [pg 351]
he falls like dead, but a second thrust of the bag restores him to
life.910
A ceremony witnessed by Jewitt during his captivity among the
Indians of Nootka Sound doubtless belongs to this class of customs.
The Indian king or chief “discharged a pistol close to his son's ear,
who immediately fell down as if killed, upon which all the women of
the house set up a most lamentable cry, tearing handfuls of hair
from their heads, and exclaiming that the prince was dead; at the
same time a great number of the inhabitants rushed into the house
armed with their daggers, muskets, etc., inquiring the cause of their
outcry. These were immediately followed by two others dressed in
wolf skins, with masks over their faces representing the head of that
animal. The latter came in on their hands and feet in the manner of
a beast, and taking up the prince, carried him off upon their backs,
retiring in the same manner as they entered.”911
In another place
Jewitt mentions that the young prince—a lad of about eleven years
of age—wore a mask in imitation of a wolf's head.912
Now, as the
Indians of this part of America are divided into totem clans, of which
the Wolf clan is one of the principal, and as the members of each
clan are in the habit of wearing some portion of the totem animal
about their person,913
it is probable that the prince belonged to the
Wolf clan, and that the ceremony described by Jewitt represented
the killing [pg 352] of the lad in order that he might be born anew
as a wolf, much in the same way that the Basque hunter supposed
himself to have been killed and to have come to life again as a bear.
The Toukaway Indians of Texas, one of whose totems is the wolf,
have a ceremony in which men, dressed in wolf skins, run about on
all fours, howling and mimicking wolves. At last they scratch up a
living tribesman, who has been buried on purpose, and putting a
bow and arrows in his hands, bid him do as the wolves do—rob, kill,
and murder.914
The ceremony probably forms part of an initiatory rite
like the resurrection from the grave of the old man in the Australian
rites.
The people of Rook, an island east of New Guinea, hold festivals at
which one or two disguised men, their heads covered with wooden
masks, go dancing through the village, followed by all the other
men. They demand that the circumcised boys who have not yet
been swallowed by Marsaba (the devil) shall be given up to them.
The boys, trembling and shrieking, are delivered to them, and must
creep between the legs of the disguised men. Then the procession
moves through the village again, and announces that Marsaba has
eaten up the boys, and will not disgorge them till he receives a
present of pigs, taro, etc. So all the villagers, according to their
means, contribute provisions, which are then consumed in the name
of Marsaba.915
In New Britain all males are members [pg 353] of an
association called the Duk-duk. The boys are admitted to it very
young, but are not fully initiated till their fourteenth year, when they
receive from the Tubuvan a terrible blow with a cane, which is
supposed to kill them. The Tubuvan and the Duk-duk are two
disguised men who represent cassowaries. They dance with a short
hopping step in imitation of the cassowary. Each of them wears a
huge hat like an extinguisher, woven of grass or palm-fibres; it is six
feet high, and descends to the wearer's shoulders, completely
concealing his head and face. From the neck to the knees the man's
body is hidden by a crinoline made of the leaves of a certain tree
fastened on hoops, one above the other. The Tubuvan is regarded as
a female, the Duk-duk as a male. No woman may see these
disguised men. The institution of the Duk-duk is common to the
neighbouring islands of New Ireland and the Duke of York.916
Amongst the Galela and Tobelorese of Halmahera, an island to the
west of New Guinea, boys go through a form of initiation, part of
which seems to consist in a pretence of begetting them anew. When
a number of boys have reached the proper age, their parents agree
to celebrate the ceremony at their common expense, and they invite
others to be present at it. A shed is erected, and two long tables are
placed in it, with [pg 354] benches to match, one for the men and
one for the women. When all the preparations have been made for a
feast, a great many skins of the rayfish, and some pieces of a wood
which imparts a red colour to water, are taken to the shed. A priest
or elder causes a vessel to be placed in the sight of all the people,
and then begins, with significant gestures, to rub a piece of the
wood with the ray-skin. The powder so produced is put in the vessel,
and at the same time the name of one of the boys is called out. The
same proceeding is repeated for each boy. Then the vessels are
filled with water, after which the feast begins. At the third cock-crow
the priest smears the faces and bodies of the boys with the red
water, which represents the blood shed at the perforation of the
hymen. Towards daybreak the boys are taken to the wood, and must
hide behind the largest trees. The men, armed with sword and
shield, accompany them, dancing and singing. The priest knocks
thrice on each of the trees behind which a boy is hiding. All day the
boys stay in the wood, exposing themselves to the heat of the sun
as much as possible. In the evening they bathe and return to the
shed, where the women supply them with food.917
In the west of Ceram boys at puberty are admitted to the Kakian
association.918
Modern writers [pg 355] have commonly regarded
this association as primarily a political league instituted to resist
foreign domination. In reality its objects are purely religious and
social, though it is possible that the priests may have occasionally
used their powerful influence for political ends. The society is in fact
merely one of those widely-diffused primitive institutions, of which a
chief object is the initiation of young men. In recent years the true
nature of the association has been duly recognised by the
distinguished Dutch ethnologist, J. G. F. Riedel. The Kakian house is
an oblong wooden shed, situated under the darkest trees in the
depth of the forest, and is built to admit so little light that it is
impossible to see what goes on in it. Every village has such a house.
Thither the boys who are to be initiated are conducted blindfolded,
followed by their parents and relations. Each boy is led by the hand
by two men, who act as his sponsors or guardians, looking after him
during the period of initiation. When all are assembled before the
shed, the high priest calls aloud upon the devils. Immediately a
hideous uproar is heard to proceed from the shed. It is made by
men with bamboo trumpets, who have been secretly introduced into
the building by a back door, but the women and children think it is
made by the devils, and are much terrified. Then the priests enter
the shed, followed by the boys, one at a time. As soon as each boy
has disappeared within the precincts, a dull chopping sound is
heard, a fearful cry rings out, and a sword or spear, dripping with
blood, is thrust [pg 356] through the roof of the shed. This is a
token that the boy's head has been cut off, and that the devil has
carried him away to the other world, there to regenerate and
transform him. So at sight of the bloody sword the mothers weep
and wail, crying that the devil has murdered their children. In some
places, it would seem, the boys are pushed through an opening
made in the shape of a crocodile's jaws or a cassowary's beak, and it
is then said that the devil has swallowed them. The boys remain in
the shed for five or nine days. Sitting in the dark, they hear the blast
of the bamboo trumpets, and from time to time the sound of musket
shots and the clash of swords. Every day they bathe, and their faces
and bodies are smeared with a yellow dye, to give them the
appearance of having been swallowed by the devil. During his stay
in the Kakian house each boy has one or two crosses tattooed with
thorns on his breast or arm. When they are not sleeping, the lads
must sit in a crouching posture without moving a muscle. As they sit
in a row cross-legged, with their hands stretched out, the chief takes
his trumpet, and placing the mouth of it on the hands of each lad,
speaks through it in strange tones, imitating the voice of the spirits.
He warns the lads, under pain of death, to observe the rules of the
Kakian society, and never to reveal what has passed in the Kakian
house. The novices are also told by the priests to behave well to
their blood relations, and are taught the traditions and secrets of the
tribe.
Meantime the mothers and sisters of the lads have gone home to
weep and mourn. But in a day or two the men who acted as
guardians or sponsors to the novices return to the village with the
glad tidings that the devil, at the intercession of the priests, has
restored [pg 357] the lads to life. The men who bring this news
come in a fainting state and daubed with mud, like messengers
freshly arrived from the nether world. Before leaving the Kakian
house, each lad receives from the priest a stick adorned at both
ends with cock's or cassowary's feathers. The sticks are supposed to
have been given to the lads by the devil at the time when he
restored them to life, and they serve as a token that the lads have
been in the spirit-land. When they return to their homes they totter
in their walk, and enter the house backward, as if they had forgotten
how to walk properly; or they enter the house by the back door. If a
plate of food is given to them, they hold it upside down. They
remain dumb, indicating their wants by signs only. All this is to show
that they are still under the influence of the devil or the spirits. Their
sponsors have to teach them all the common acts of life, as if they
were new-born children. Further, upon leaving the Kakian house the
boys are strictly forbidden to eat of certain fruits until the next
celebration of the rites has taken place. And for twenty or thirty days
their hair may not be combed by their mothers or sisters. At the end
of that time the high priest takes them to a lonely place in the
forest, and cuts off a lock of hair from the crown of each of their
heads. After these initiatory rites the lads are deemed men, and may
marry; it would be a scandal if they married before.
The simulation of death and resurrection or of a new birth at
initiation appears to have lingered on, or at least to have left traces
of itself, among peoples who have advanced far beyond the stage of
savagery. Thus, after his investiture with the sacred thread—the
symbol of his order—a Brahman is called “twice-born.” [pg 358]
Manu says, “According to the injunction of the revealed texts the
first birth of an Aryan is from his natural mother, the second happens
on the tying of the girdle of Muñga grass, and the third on the
initiation to the performance of a Srauta sacrifice.”919
A pretence of
killing the candidate appears to have formed part of the initiation to
the Mithraic mysteries.920
Thus, if I am right, wherever totemism is found, and wherever a
pretence is made of killing and bringing to life again at initiation,
there must exist or have existed not only a belief in the possibility of
permanently depositing the soul in some external object—animal,
plant, or what not—but an actual intention of so depositing it. If the
question is put, why do men desire to deposit their life outside their
bodies? the answer can only be that, like the giant in the fairy tale,
they think it safer to do so than to carry it about with them, just as
people deposit their money with a banker rather than carry it on
their persons. We have seen that at critical periods the life or soul is
sometimes temporarily deposited in a safe place till the danger is
past. But institutions like totemism are not resorted to merely on
special occasions of danger; they are systems into which every one,
or at least every male, is obliged to be initiated at a certain period of
life. Now the period of life at which initiation takes place is regularly
puberty; and this fact suggests that the special danger which
totemism and systems like it are intended to obviate is supposed not
to arise till sexual maturity has been attained, in fact, that the
danger [pg 359] apprehended is believed to attend the relation of
the sexes to each other. It would be easy to prove by a long array of
facts that the sexual relation is associated in the primitive mind with
many supernatural perils; but the exact nature of the danger
apprehended is still obscure. We may hope that a more exact
acquaintance with savage modes of thought will in time disclose this
central mystery of primitive society, and will thereby furnish the clue,
not only to the social aspect of totemism (the prohibition of sexual
union between persons of the same totem), but to the origin of the
marriage system.
§ 5.—Conclusion.
Thus the view that Balder's life was in the mistletoe is entirely in
harmony with primitive modes of thought. It may indeed sound like
a contradiction that, if his life was in the mistletoe, he should
nevertheless have been killed by a blow from it. But when a person's
life is conceived as embodied in a particular object, with the
existence of which his own existence is inseparably bound up, and
the destruction of which involves his own, the object in question
may be regarded and spoken of indifferently as the person's life or
as his death, as happens in the fairy tales. Hence if a man's death is
in an object, it is perfectly natural that he should be killed by a blow
from it. In the fairy tales Koshchei the Deathless is killed by a blow
from the egg or the stone in which his life or death is;921
the ogres
burst when a certain grain of sand—doubtless containing their life or
death—is carried over their [pg 360] heads;922
the magician dies
when the stone in which his life or death is contained is put under
his pillow;923
and the Tartar hero is warned that he may be killed by
the golden arrow or golden sword in which his soul has been stowed
away.924
The idea that the life of the oak was in the mistletoe was probably
suggested, as I have said, by the observation that in winter the
mistletoe growing on the oak remains green, while the oak itself is
leafless. But the position of the plant—growing, not from the
ground, but from the trunk or branches of the tree—might confirm
this idea. Primitive man might think that, like himself, the oak-spirit
had sought to deposit his life in some safe place, and for this
purpose had pitched on the mistletoe, which, being in a sense
neither on earth nor in heaven, was as secure a place as could be
found. At the beginning of this chapter we saw that primitive man
seeks to preserve the life of his human divinities by keeping them in
a sort of intermediate position between earth and heaven, as the
place where they are least likely to be assailed by the dangers that
encompass the life of man on earth. We can therefore [pg 361]
understand why in modern folk-medicine the mistletoe is not allowed
to touch the ground; if it touches the ground, its healing virtue is
supposed to be gone.925
This may be a survival of the old
superstition that the plant in which the life of the sacred tree was
concentrated should not be exposed to the risk incurred by contact
with the ground. In an Indian legend, which offers a parallel to the
Balder myth, Indra promised the demon Namuci not to kill him by
day or by night, nor with what was wet or what was dry. But he
killed him in the morning twilight by sprinkling over him the foam of
the sea.926
The foam of the sea is just such an object as a savage
might choose to put his life in, because it occupies that sort of
intermediate or nondescript position between earth and sky or sea
and sky in which primitive man sees safety. It is therefore not
surprising that the foam of the river should be the totem of a clan in
India.927
Again, the view that the mistletoe owes its mystic character
partly to the fact of its not growing on the ground is confirmed by a
parallel superstition about the mountain-ash or rowan-tree. In
Jutland a rowan that is found growing out of the top of another tree
is esteemed “exceedingly effective against witchcraft: since it does
not grow on the ground witches have no power over it; if it is to
have its full effect it must be cut on Ascension Day.”928
Hence it is
placed over doors to prevent the ingress of witches.929
Similarly the
mistletoe in Germany is still [pg 362] universally considered a
protection against witchcraft, and in Sweden, as we saw, the
mistletoe which is gathered on Midsummer Eve is attached to the
ceiling of the house, the horse stall, or the cow's crib, in the belief
that this renders the Troll powerless to injure man or beast.930
The view that the mistletoe was not merely the instrument of
Balder's death, but that it contained his life, is countenanced by the
analogy of a Scottish superstition. Tradition ran that the fate of the
family of Hay was bound up with the mistletoe of a certain oak.
“While the mistletoe bats on Errol's oak,
And that oak stands fast,
The Hays shall flourish, and their good gray hawk
Shall not flinch before the blast.
“But when the root of the oak decays,
And the mistletoe dwines on its withered breast,
The grass shall grow on the Earl's hearthstone,
And the corbies craw in the falcon's nest.”
“A large oak with the mistletoe growing on it was long pointed out
as the tree referred to. A piece of the mistletoe cut by a Hay was
believed to have magical virtues. ‘The oak is gone and the estate is
lost to the family,’ as a local historian says.”931
The idea that the fate
of a family, as distinct from the lives of its members, is bound up
with a particular plant or tree, is no doubt comparatively modern.
The older view probably was that the lives of all the Hays were in
this particular mistletoe, just as in the Indian story the lives of all the
ogres are in a lemon; to break a twig of the mistletoe would then
have been to kill one [pg 363] of the Hays. Similarly in the island of
Rum, whose bold mountains the voyager from Oban to Skye
observes to seaward, it was thought that if one of the family of
Lachlin shot a deer on the mountain of Finchra, he would die
suddenly or contract a distemper which would soon prove fatal.932
Probably the life of the Lachlins was bound up with the deer on
Finchra, as the life of the Hays was bound up with the mistletoe on
Errol's oak.
It is not a new opinion that the Golden Bough was the mistletoe.933
True, Virgil does not identify but only compares it with the mistletoe.
But this may be only a poetical device to cast a mystic glamour over
the humble plant. Or, more probably, his description was based on a
popular superstition that at certain times the mistletoe blazed out
into a supernatural golden glory. The poet tells how two doves,
guiding Aeneas to the gloomy vale in whose depth grew the Golden
Bough, alighted upon a tree, “whence shone a flickering gleam of
gold. As in the woods in winter cold the mistletoe—a plant not native
to its tree—is green with fresh leaves and twines its yellow berries
about the boles; such seemed upon the shady oak the leafy gold, so
rustled in the gentle breeze the golden leaf.”934
Here Virgil definitely
describes the Golden Bough as growing on an oak, and compares it
with the mistletoe. The inference is almost inevitable that the Golden
Bough was nothing but the mistletoe seen through the haze of
poetry or of popular superstition.
Now grounds have been shown for believing that [pg 364] the priest
of the Arician grove—the King of the Wood—personified the tree on
which grew the Golden Bough.935
Hence, if that tree was the oak,
the King of the Wood must have been a personification of the oak-
spirit. It is, therefore, easy to understand why, before he could be
slain, it was necessary to break the Golden Bough. As an oak-spirit,
his life or death was in the mistletoe on the oak, and so long as the
mistletoe remained intact, he, like Balder, could not die. To slay him,
therefore, it was necessary to break the mistletoe, and probably, as
in the case of Balder, to throw it at him. And to complete the
parallel, it is only necessary to suppose that the King of the Wood
was formerly burned, dead or alive, at the midsummer fire festival
which, as we have seen, was annually celebrated in the Arician
grove.936
The perpetual fire which burned in the grove, like the
perpetual fire under the oak at Romove, was probably fed with the
sacred oak-wood; and thus it would be in a great fire of oak that the
King of the Wood formerly met his end. At a later time, as I have
suggested, his annual tenure of office was lengthened or shortened,
as the case might be, by the rule which allowed him to live so long
as he could prove his divine right by the strong hand. But he only
escaped the fire to fall by the sword.
Thus it seems that at a remote age in the heart of Italy, beside the
sweet lake of Nemi, the same fiery tragedy was annually enacted
which Italian merchants and soldiers were afterwards to witness
among their rude kindred, the Celts of Gaul, and which, if the [pg
365] Roman eagles had ever swooped on Norway, might have been
found repeated with little difference among the barbarous Aryans of
the North. The rite was probably an essential feature in the primitive
Aryan worship of the oak.937
It only remains to ask, Why was the mistletoe called the Golden
Bough? The name was not simply a poet's fancy, nor even peculiarly
Italian; for in Welsh also the mistletoe is known as “the tree of pure
gold.”938
The whitish-yellow of the mistletoe berries is hardly enough
to account for the name. For Virgil says that the Bough was
altogether golden, stem as well as leaves,939
and the same is implied
in the Welsh name, “the tree of pure gold.” A clue to the real
meaning of the name is furnished by the mythical fern-seed or fern-
bloom.
We saw that fern-seed is popularly supposed to bloom like gold or
fire on Midsummer Eve. Thus in Bohemia it is said that “on St. John's
Day fern-seed blooms with golden blossoms that gleam like fire.”940
Now it is a property of this mythical fern-seed that whoever has it,
or will ascend a mountain holding it in his hand on Midsummer Eve,
will discover a vein of gold or will see the treasures of the earth
shining with a bluish flame.941
And if you place fern-seed [pg 366]
among money, the money will never decrease, however much of it
you spend.942
Sometimes the fern-seed is supposed to bloom at
Christmas, and whoever catches it will become very rich.943
Thus, on
the principle of like by like, fern-seed is supposed to discover gold
because it is itself golden; and for a similar reason it enriches its
possessor with an unfailing supply of gold. But while the fern-seed is
described as golden, it is equally described as glowing and fiery.944
Hence, when we consider that two great days for gathering the
fabulous seed are Midsummer Eve and Christmas—that is, the two
solstices (for Christmas is nothing but an old heathen celebration of
the winter solstice)—we are led to regard the fiery aspect of the
fern-seed as primary, and its golden aspect as secondary and
derivative. Fern-seed, in fact, would seem to be an emanation of the
sun's fire at the two turning-points of its course, the summer and
winter solstices. This view is confirmed by a German story in which a
hunter is said to have procured fern-seed by shooting at the sun on
Midsummer Day at noon; three drops of blood fell down, which he
caught in a white cloth, and these blood-drops were the fern-
seed.945
Here the blood is clearly the blood of the sun, from which
the fern-seed is thus directly derived. Thus it may be taken as
certain that fern-seed is golden, because it is believed to be an
emanation of the sun's golden fire.
Now, like fern-seed, the mistletoe is gathered [pg 367] either at
Midsummer or Christmas946
—that is, at the summer and winter
solstices—and, like fern-seed, it is supposed to possess the power of
revealing treasures in the earth. On Midsummer Eve people in
Sweden make divining-rods of mistletoe or of four different kinds of
wood, one of which must be mistletoe. The treasure-seeker places
the rod on the ground after sundown, and when it rests directly over
treasure, the rod begins to move as if it were alive.947
Now, if the
mistletoe discovers gold, it must be in its character of the Golden
Bough; and if it is gathered at the solstices, must not the Golden
Bough, like the golden fern-seed, be an emanation of the sun's fire?
The question cannot be answered with a simple affirmative. We have
seen that the primitive Aryans probably kindled the midsummer
bonfires as sun-charms, that is, with the intention of supplying the
sun with fresh fire. But as this fire was always elicited by the friction
of oak wood,948
it must have appeared to the primitive Aryan that
the sun was periodically recruited from the fire which resided in the
sacred oak. In other words, the oak must have seemed to him the
original storehouse or reservoir of the fire which was from time to
time drawn out to feed the sun. But the life of the oak was
conceived to be in the mistletoe; therefore the mistletoe must have
contained the seed or germ of the [pg 368] fire which was elicited
by friction from the wood of the oak. Thus, instead of saying that
the mistletoe was an emanation of the sun's fire, it would be more
correct to say that the sun's fire was regarded as an emanation of
the mistletoe. No wonder, then, that the mistletoe shone with a
golden splendour, and was called the Golden Bough. Probably,
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookname.com

Programming 8 bit PIC Microcontrollers in C with Interactive Hardware Simulation 1st Edition Martin P. Bates

  • 1.
    Programming 8 bitPIC Microcontrollers in C with Interactive Hardware Simulation 1st Edition Martin P. Bates pdf download https://ebookname.com/product/programming-8-bit-pic- microcontrollers-in-c-with-interactive-hardware-simulation-1st- edition-martin-p-bates/ Get Instant Ebook Downloads – Browse at https://ebookname.com
  • 2.
    Instant digital products(PDF, ePub, MOBI) available Download now and explore formats that suit you... Interfacing PIC Microcontrollers Embedded Design by Interactive Simulation 1st Edition Martin P. Bates https://ebookname.com/product/interfacing-pic-microcontrollers- embedded-design-by-interactive-simulation-1st-edition-martin-p- bates/ PIC Microcontrollers An Introduction to Microelectronics 2nd Ed Second Edition Martin Bates https://ebookname.com/product/pic-microcontrollers-an- introduction-to-microelectronics-2nd-ed-second-edition-martin- bates/ Microcontrollers Fundamentals and Applications with PIC 1st Edition Fernando E. Valdes-Perez https://ebookname.com/product/microcontrollers-fundamentals-and- applications-with-pic-1st-edition-fernando-e-valdes-perez/ King Richard II Webster s Spanish Thesaurus Edition William Shakespeare https://ebookname.com/product/king-richard-ii-webster-s-spanish- thesaurus-edition-william-shakespeare/
  • 3.
    Buddhist phenomenology Aphilosophical investigation of Yog■c■ra Buddhism and the Ch■eng Wei shih lun Dan Lusthaus https://ebookname.com/product/buddhist-phenomenology-a- philosophical-investigation-of-yogacara-buddhism-and-the- ch%ca%bceng-wei-shih-lun-dan-lusthaus/ The Cronaca di Partenope An Introduction to and Critical Edition of the First Vernacular History of Naples c 1350 Medieval Mediterranean Samantha Kelly https://ebookname.com/product/the-cronaca-di-partenope-an- introduction-to-and-critical-edition-of-the-first-vernacular- history-of-naples-c-1350-medieval-mediterranean-samantha-kelly/ Gravity Falls Dipper s and Mabel s Guide to Mystery and Nonstop Fun Rob Renzetti https://ebookname.com/product/gravity-falls-dipper-s-and-mabel-s- guide-to-mystery-and-nonstop-fun-rob-renzetti/ Small Animal Cardiology 1st Edition Nelson Dvm Ms Dacvim https://ebookname.com/product/small-animal-cardiology-1st- edition-nelson-dvm-ms-dacvim/ Unlocking the Prehistory of America 1st Edition Frank Joseph https://ebookname.com/product/unlocking-the-prehistory-of- america-1st-edition-frank-joseph/
  • 4.
    Luther s Theologyof the Cross Martin Luther s Theological Breakthrough Second Edition Alister E. Mcgrath https://ebookname.com/product/luther-s-theology-of-the-cross- martin-luther-s-theological-breakthrough-second-edition-alister- e-mcgrath/
  • 6.
    Foreword Embedded microcontrollers areeverywhere today. In the average household you will find them far beyond the obvious places like cell phones, calculators, and MP3 players. Hardly any new appliance arrives in the home without at least one controller and, most likely, there will be several—one microcontroller for the user interface (buttons and display), another to control the motor, and perhaps even an overall system manager. This applies whether the appliance in question is a washing machine, garage door opener, curling iron, or toothbrush. If the product uses a rechargeable battery, modern high density battery chemistries require intelligent chargers. A decade ago, there were significant barriers to learning how to use microcontrollers. The cheapest programmer was about a hundred dollars and application development required both erasable windowed parts—which cost about ten times the price of the one time programmable (OTP) version—and a UV Eraser to erase the windowed part. Debugging tools were the realm of professionals alone. Now most microcontrollers use Flash-based program memory that is electrically erasable. This means the device can be reprogrammed in the circuit—no UV eraser required and no special packages needed for development. The total cost to get started today is about twenty-five dollars which buys a PICkit™ 2 Starter Kit, providing programming and debugging for many Microchip Technology Inc. MCUs. Microchip Technology has always offered a free Integrated Development Environment (IDE) including an assembler and a simulator. It has never been less expensive to get started with embedded microcontrollers than it is today. While MPLAB® includes the assembler for free, assembly code is more cumbersome to write, in the first place, and also more difficult to maintain. Developing code using C frees the programmer from the details of multi-byte math and paging and generally improves code readability and maintainability. CCS and Hi-Tech both offer free “student” versions of the compiler to get started and even the full versions are relatively inexpensive once the savings in development time has been taken into account. www.newnespress.com For-H8960.indd xi For-H8960.indd xi 6/10/2008 10:36:25 AM 6/10/2008 10:36:25 AM
  • 7.
    www.newnespress.com While the Clanguage eliminates the need to learn the PIC16 assembly language and frees the user from managing all the details, it is still necessary to understand the architecture. Clocking options, peripherals sets, and pin multiplexing issues still need to be solved. Martin’s book guides readers, step-by-step, on the journey from “this is a micro- controller” to “here’s how to complete an application.” Exercises use the fully featured PIC16F877A, covering the architecture and device configuration. This is a good starting point because other PIC16s are similar in architecture but differ in terms of IO lines, memory, or peripheral sets. An application developed on the PIC16F877A can easily be transferred to a smaller and cheaper midrange PICmicro. The book also introduces the peripherals and shows how they can simplify the firmware by letting the hardware do the work. MPLAB® , Microchip’s Integrated Development Environment, is also covered. MPLAB includes an editor and a simulator and interfaces with many compilers, including the CCS compiler used in this book. Finally, the book includes the Proteus® simulator which allows complete system simulation, saving time and money on prototype PCBs. Dan Butler Principal Applications Engineer Microchip Technology Inc. xii Foreword For-H8960.indd xii For-H8960.indd xii 6/10/2008 10:36:25 AM 6/10/2008 10:36:25 AM
  • 8.
    www.newnespress.com Preface This book isthe third in a series, including ● PIC Microcontrollers: An Introduction to Microelectronic Systems. ● Interfacing PIC Microcontrollers: Embedded Design by Interactive Simulation. ● Programming 8-bit PIC Microcontrollers in C: With Interactive Hardware Simulation. It completes a set that introduces embedded application design using the Microchip PIC® range, from Microchip Technology Inc. of Arizona. This is the most popular microcontroller for education and training, which is also rapidly gaining ground in the industrial and commercial sectors. Interfacing PIC Microcontrollers and Programming PIC Microcontrollers present sample applications using the leading design and simulation software for microcontroller based circuits, Proteus VSM® from Labcenter Electronics. Demo application files can be downloaded from the author’s support Web site (see later for details) and run on-screen so that the operation of each program can be studied in detail. The purpose of this book is to ● Introduce C programming specifically for microcontrollers in easy steps. ● Demonstrate the use of the Microchip MPLAB IDE for C projects. ● Provide a beginners’ guide to the CCS PCM C compiler for 16 series PICs. ● Explain how to use Proteus VSM to test C applications in simulated hardware. ● Describe applications for the Microchip PICDEM mechatronics board. ● Outline the principles of embedded system design and project development. Pre-H8960.indd xiii Pre-H8960.indd xiii 6/10/2008 10:38:12 AM 6/10/2008 10:38:12 AM
  • 9.
    www.newnespress.com C is becomingthe language of choice for embedded systems, as memory capacity increases in microcontrollers. Microchip supplies the 18 and 24 series chips specifically designed for C programming. However, C can be used in the less complex 16 series PIC, as long as the applications are relatively simple and therefore do not exceed the more limited memory capacity. The PIC 16F877A microcontroller is used as the reference device in this book, as it contains a full range of peripherals and a reasonable memory capacity. It was also used in the previous work on interfacing, so there is continuity if the book series is taken as a complete course in PIC application development. Microcontrollers are traditionally programmed in assembly language, each type having its own syntax, which translates directly into machine code. Some students, teachers, and hobbyists may wish to skip a detailed study of assembler coding and go straight to C, which is generally simpler and more powerful. It is therefore timely to produce a text that does not assume detailed knowledge of assembler and introduces C as gently as possible. Although several C programming books for microcontrollers are on the market, many are too advanced for the C beginner and distract the learner with undesirable detail in the early stages. This text introduces embedded programming techniques using the simplest possible programs, with on-screen, fully interactive circuit simulation to demonstrate a range of basic techniques, which can then be applied to your own projects. The emphasis is on simple working programs for each topic, with hardware block diagrams to clarify system operation, full circuit schematics, simulation screenshots, and source code listings, as well as working downloads of all examples. Students in college courses and design engineers can document their projects to a high standard using these techniques. Each part concludes with a complete set of self-assessment questions and assignments designed to complete the learning package. An additional feature of this book is the use of Proteus VSM (virtual system modeling). The schematic capture component, ISIS, allows a circuit diagram to be created using an extensive library of active components. The program is attached to the microcontroller, and the animated schematic allows the application to be comprehensively debugged before downloading to hardware. This not only saves time for the professional engineer but provides an excellent learning tool for the student or hobbyist. xiv Preface Pre-H8960.indd xiv Pre-H8960.indd xiv 6/10/2008 10:38:13 AM 6/10/2008 10:38:13 AM
  • 10.
    Preface xv www.newnespress.com Links, Resources,and Acknowledgments Microchip Technology Inc. (www.microchip.com) Microchip Technology Inc. is a manufacturer of PIC® microcontrollers and associated products. I gratefully acknowledge the support and assistance of Microchip Inc. in the development of this book and the use of the company trademarks and intellectual property. Special thanks are due to John Roberts of Microchip UK for his assistance and advice. The company Web site contains details of all Microchip hardware, software, and development systems. MPLAB IDE (integrated development system) must be downloaded and installed to develop new applications using the tools described in this book. The data sheet for the PIC 16F877A microcontroller should also be downloaded as a reference source. PIC, PICmicro, MPLAB, MPASM, PICkit, dsPIC, and PICDEM are trademarks of Microchip Technology Inc. Labcenter Electronics (www.labcenter.co.uk) Labcenter Electronics is the developer of Proteus VSM (virtual system modeling), the most advanced cosimulation system for embedded applications. I gratefully acknowledge the assistance of the Labcenter team, especially John Jameson, in the development of this series of books. A student/evaluation version of the simulation software may be downloaded from www.proteuslite.com. A special offer for ISIS Lite, ProSPICE Lite, and the 16F877A simulator model can be found at www.proteuslite.com/register/ ipmbundle.htm. Proteus VSM, ISIS, and ARES are trademarks of Labcenter Electronics Ltd. Custom Computer Services Inc. (www.ccsinfo.com) Custom Computer Services Inc. specializes in compilers for PIC microcontrollers. The main range comprises PCB compiler for 12-bit PICs, PCM for 16-bit, and PCH for the 18 series chips. The support provided by James Merriman at CCS Inc. is gratefully acknowledged. The manual for the CCS compiler should be downloaded from the company Web site (Version 4 was used for this book). A 30-day trial version, which will compile code for the 16F877A, is available at the time of writing. Pre-H8960.indd xv Pre-H8960.indd xv 6/10/2008 10:38:13 AM 6/10/2008 10:38:13 AM
  • 11.
    xvi Preface www.newnespress.com The Author’sWeb Site (www.picmicros.org.uk) This book is supported by a dedicated Web site, www.picmicros.org.uk. All the application examples in the book may be downloaded free of charge and tested using an evaluation version of Proteus VSM. The design files are locked so that the hardware configuration cannot be changed without purchasing a suitable VSM license. Similarly, the attached program cannot be modified and recompiled without a suitable compiler license, available from the CCS Web site. Special manufacturer’s offers are available via links at my site. This site is hosted by www.larrytech.com and special thanks are due to Gabe Hudson of Larrytech® Internet Services for friendly maintenance and support. I can be contacted at the e-mail address martin@picmicros.org.uk with any queries or comments related to the PIC book series. Finally, thanks to Julia for doing the boring domestic stuff so I can do the interesting technical stuff. About the Author Martin P. Bates is the author of PIC Microcontrollers, Second Edition. He is currently lecturing on electronics and electrical engineering at Hastings College, UK. His interests include microcontroller applications and embedded system design. Pre-H8960.indd xvi Pre-H8960.indd xvi 6/10/2008 10:38:13 AM 6/10/2008 10:38:13 AM
  • 12.
    www.newnespress.com Introduction The book isorganized in five parts. Part 1 includes an overview of the PIC microcontroller internal architecture, describing the features of the 16F877A specifically. This chip is often used as representative of the 16 series MCUs because it has a full range of peripheral interfaces. All 16 series chips have a common program execution core, with variation mainly in the size of program and data memory. During programming, certain operational features are configurable: type of clock circuit, watchdog timer enable, reset mechanisms, and so on. Internal features include the file register system, which contains the control registers and RAM block, and a nonvolatile EEPROM block. The parallel ports provide the default I/O for the MCU, but most pins have more than one function. Eight analog inputs and serial interfaces (UART, SPI, and I2 C) are brought out to specific pins. The hardware features of all these are outlined, so that I/O programming can be more readily understood later on. The application development process is described, using only MPLAB IDE in this initial phase. A sample C program is edited, compiled, downloaded, and tested to demonstrate the basic process and the generated file set analyzed. The debugging features of MPLAB are also outlined: run, single step, breakpoints, watch windows, and so on. Disassembly of the object code allows the intermediate assembly language version of the C source program to be analyzed. Part 2 introduces C programming, using the simplest possible programs. Input and output are dealt with immediately, since this is the key feature of embedded programs. Variables, conditional blocks (IF), looping (WHILE,FOR) are quickly introduced, with a complete example program. Variables and sequence control are considered in a little more detail and functions introduced. This leads on to library functions for operating timers and ports. The keypad and alphanumeric LCD are used in a simple calculator program. More data types (long integers, floating point numbers, arrays, etc.) follow as well as assembler directives and the purpose of the header file. Finally, insertion of assembler into C programs is outlined. Itr-H8960.indd xvii Itr-H8960.indd xvii 6/10/2008 10:39:06 AM 6/10/2008 10:39:06 AM
  • 13.
    xviii Introduction www.newnespress.com Part 3focuses on programming input and output operations using the CCS C library functions. These simplify the programming process, with a small set of functions usually providing all the initialization and operating sequences required. Example programs for analog input and the use of interrupts and timers are developed and the serial port functions demonstrated in sample applications. The advantages of each type of serial bus are compared, and examples showing the connection of external serial EEPROM for data storage and a digital to analog converter output are provided. These applications can be tested in VSM, but this is not essential; use of VSM is optional throughout the book. Part 4 focuses specifically on the PICDEM mechatronics board from Microchip. This has been selected as the main demonstration application, as it is relatively inexpensive and contains a range of features that allow the features of a typical mechatronics system to be examined: input sensors (temperature, light, and position) and output actuators (DC and stepper motor). These are tested individually then the requirements of a temperature controller outlined. Operation of the 3.5-digit seven-segment LCD is explained in detail, as this is not covered elsewhere. A simulation version of the board is provided to aid further application design and implementation. Part 5 outlines some principles of software and hardware design and provides some further examples. A simple temperature controller provides an alternative design to that based on the mechatronics board, and a data logger design is based on another standard hardware system, which can be adapted to a range of applications—the BASE board. Again, a full-simulation version is provided for testing and further development work. This is followed by a section on operating systems, which compares three program design options: a polling loop, interrupt driven systems, and real-time operating systems. Consideration of criteria for the final selection of the MCU for a given application and some general design points follow. Three appendices (A, B, and C) cover hardware design using ISIS schematic capture, software design using CCS C, and system testing using Proteus VSM. These topics are separated from the main body of the book as they are related more to specific products. Taken together, MPLAB, CCS C, and Proteus VSM constitute a complete learning/design package, but using them effectively requires careful study of product-specific tutorials. VSM, in particular, has comprehensive, well-designed help files; and it is therefore unnecessary to duplicate that material here. Furthermore, as with all good design tools, VSM evolves very quickly, so a detailed tutorial quickly becomes outdated. Appendix D compares alternative compilers, and application development areas are identified that would suit each one. Appendix E provides a summary of CCS C syntax Itr-H8960.indd xviii Itr-H8960.indd xviii 6/10/2008 10:39:06 AM 6/10/2008 10:39:06 AM
  • 14.
    Introduction xix www.newnespress.com requirements, andAppendix F contains a list of the CCS C library functions provided with the compiler, organized in functional groups for ease of reference. These are intended to provide a convenient reference source when developing CCS C programs, in addition to the full CCS compiler reference manual. Each part of the book is designed to be as self-contained as possible, so that parts can be skipped or studied in detail, depending on the reader’s previous knowledge and interests. On the other hand, the entire book should provide a coherent narrative leading to a solid grounding in C programming for embedded systems in general. Itr-H8960.indd xix Itr-H8960.indd xix 6/10/2008 10:39:06 AM 6/10/2008 10:39:06 AM
  • 15.
    www.newnespress.com PIC Microcontroller Systems 1.1PIC16 Microcontrollers ● MCU features ● Program execution ● RAM file registers ● Other PIC chips The microcontroller unit (MCU) is now big, or rather small, in electronics. It is one of the most significant developments in the continuing miniaturization of electronic hardware. Now, even trivial products, such as a musical birthday card or electronic price tag, can include an MCU. They are an important factor in the digitization of analog systems, such as sound systems or television. In addition, they provide an essential component of larger systems, such as automobiles, robots, and industrial systems. There is no escape from microcontrollers, so it is pretty useful to know how they work. The computer or digital controller has three main elements: input and output devices, which communicate with the outside world; a processor, to make calculations and handle data operations; and memory, to store programs and data. Figure 1.1 shows these in a little more detail. Unlike the conventional microprocessor system (such as a PC), which has separate chips on a printed circuit board, the microcontroller contains all these elements in one chip. The MCU is essentially a computer on a chip; however, it still needs input and output devices, such as a keypad and display, to form a working system. The microcontroller stores its program in ROM (read only memory). In the past, UV (ultraviolet) erasable programmable ROM (EPROM) was used for prototyping or P A R T 1 Ch01-H8960.indd 1 Ch01-H8960.indd 1 6/10/2008 4:56:37 PM 6/10/2008 4:56:37 PM
  • 16.
    2 Part 1 www.newnespress.com smallbatch production, and one-time programmable ROM for longer product runs. Programmable ROM chips are programmed in the final stages of manufacture, while EPROM could be programmed by the user. Flash ROM is now normally used for prototyping and low-volume production. This can be programmed in circuit by the user after the circuit has been built. The prototyping cycle is faster, and software variations are easier to accommodate. We are all now familiar with flash ROM as used in USB memory sticks, digital camera memory, and so on, with Gb (109 byte) capacities commonplace. The range of microcontrollers available is expanding rapidly. The first to be widely used, the Intel 8051, was developed alongside the early Intel PC processors, such as the 8086. This device dominated the field for some time; others emerged only slowly, mainly in the form of complex processors for applications such as engine management systems. These devices were relatively expensive, so they were justified only in high-value products. The potential of microcontrollers seems to have been realized only slowly. The development of flash ROM helped open up the market, and Microchip was among the first to take advantage. The cheap and reprogrammable PIC16F84 became the most widely known, rapidly becoming the number one device for students and hobbyists. On the back of this success, the Microchip product range rapidly developed and diversified. The supporting development system, MPLAB, was distributed free, which helped the PIC to dominate the low-end market. Flash ROM is one of the technical developments that made learning about microsystems easier and more interesting. Interactive circuit design software is another. The whole design process is now much more transparent, so that working systems are more quickly achievable by the beginner. Low-cost in-circuit debugging is another technique that helps get the final hardware up and running quickly, with only a modest expenditure on development tools. User Input User Output Input Peripherals Output Peripherals RAM Read & Write Memory CPU Central Processing Unit ROM Read Only Memory Program Download Figure 1.1: Elements of a Digital Controller Ch01-H8960.indd 2 Ch01-H8960.indd 2 6/10/2008 4:56:37 PM 6/10/2008 4:56:37 PM
  • 17.
    PIC Microcontroller Systems3 www.newnespress.com MCU Features The range of microcontrollers now available developed because the features of the MCU used in any particular circuit must be as closely matched as possible to the actual needs of the application. Some of the main features to consider are ● Number of inputs and outputs. ● Program memory size. ● Data RAM size. ● Nonvolatile data memory. ● Maximum clock speed. ● Range of interfaces. ● Development system support. ● Cost and availability. The PIC16F877A is useful as a reference device because it has a minimal instruction set but a full range of peripheral features. The general approach to microcontroller application design followed here is to develop a design using a chip that has spare capacity, then later select a related device that has the set of features most closely matching the application requirements. If necessary, we can drop down to a lower range (PIC10/12 series), or if it becomes clear that more power is needed, we can move up to a higher specification chip (PIC18/24 series). This is possible as all devices have the same core architecture and compatible instructions sets. The most significant variation among PIC chips is the instruction size, which can be 12, 14, or 16 bits. The A suffix indicates that the chip has a maximum clock speed of 20MHz, the main upgrade from the original 16F877 device. These chips can otherwise be regarded as identical, the suffix being optional for most purposes. The 16F877A pin-out is seen in Figure 1.2 and the internal architecture in Figure 1.3. The latter is a somewhat simplified version of the definitive block diagram in the data sheet. Program Execution The chip has 8k (8096 ⫻ 14 bits) of flash ROM program memory, which has to be programmed via the serial programming pins PGM, PGC, and PGD. The fixed-length Ch01-H8960.indd 3 Ch01-H8960.indd 3 6/10/2008 4:56:53 PM 6/10/2008 4:56:53 PM
  • 18.
    4 Part 1 www.newnespress.com instructionscontain both the operation code and operand (immediate data, register address, or jump address). The mid-range PIC has a limited number of instructions (35) and is therefore classified as a RISC (reduced instruction set computer) processor. Looking at the internal architecture, we can identify the blocks involved in program execution. The program memory ROM contains the machine code, in locations numbered from 0000h to 1FFFh (8k). The program counter holds the address of the current instruction and is incremented or modified after each step. On reset or power up, it is reset to zero and the first instruction at address 0000 is loaded into the instruction register, decoded, and executed. The program then proceeds in sequence, operating on the contents of the file registers (000–1FFh), executing data movement instructions to transfer data between ports and file registers or arithmetic and logic instructions to process it. The CPU has one main working register (W), through which all the data must pass. If a branch instruction (conditional jump) is decoded, a bit test is carried out; and if the result is true, the destination address included in the instruction is loaded into the program counter to force the jump. If the result is false, the execution sequence continues unchanged. In assembly language, when CALL and RETURN are used to implement RB7/PGD MCLR/VPP RA0/AN0 RB6/PGC RB5 RB4 RB3/PGM RB2 RB1 RB0/INT VDD VSS RD7/PSP7 RD6/PSP6 RD5/PSP5 RD4/PSP4 RC7/RX/DT RC6/TX/CK RC5/SDO RC4/SDI/SDA RD3/PSP3 RD2/PSP2 RA1/AN1 RA2/AN2/VREF⫺/CVREF RA3/AN3/VREF⫹ RA4/T0CKI/C1OUT RA5/AN4/SS/C2OUT RE0/RD/AN5 RE1/WR/AN6 RE2/CS/AN7 VDD VSS OSC1/CLKI OSC2/CLKO RC0/T1OSO/T1CKI RC1/T1OSI/CCP2 RC2/CCP1 RC3/SCK/SCL RD0/PSP0 RD1/PSP1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 PIC16F874A/877A Figure 1.2: 16F877 Pin-out (reproduced by permission of Microchip Inc.) Ch01-H8960.indd 4 Ch01-H8960.indd 4 6/10/2008 4:56:53 PM 6/10/2008 4:56:53 PM
  • 19.
    PIC Microcontroller Systems5 www.newnespress.com subroutines, a similar process occurs. The stack is used to store return addresses, so that the program can return automatically to the original program position. However, this mechanism is not used by the CCS C compiler, as it limits the number of levels of subroutine (or C functions) to eight, which is the depth of the stack. Instead, a simple GOTO instruction is used for function calls and returns, with the return address computed by the compiler. Flash ROM Program Memory 8192 ⫻ 14 bits Program Counter (13 bits) Address Instructions File Address Program Address Stack 13 bits ⫻ 8 Levels RAM File Registers 368 ⫻ 8 bits Instruction Register File Select Register MCU control lines Working (W) Register Arithmetic & Logic Unit Status (Flag) Register Literal Status Op- code Data Bus (8 bits) Instruction Decode & CPU control EEPROM 256 bytes Ports, Timers ADC, Serial I/O Clock Reset Port A B C D E Timing control Figure 1.3: PIC16F877 MCU Block Diagram Ch01-H8960.indd 5 Ch01-H8960.indd 5 6/10/2008 4:56:53 PM 6/10/2008 4:56:53 PM
  • 20.
    6 Part 1 www.newnespress.com Table1.1: PIC16F877 Simplified File Register Map Bank 0 (000–07F) Bank 1 (080–0FF) Bank 2 (100–180) Bank 3 (180–1FF) Address Register Address Register Address Register Address Register 000h Indirect 080h Indirect 100h Indirect 180h Indirect 001h Timer0 081h Option 101h Timer0 181h Option 002h Prog. count. low 082h Prog. count. low 102h Prog. count. low 182h Prog. count. low 003h Status reg 083h Status reg 103h Status reg 183h Status reg 004h File select 084h File select 104h File select 184h File select 005h Port A data 085h Port A direction 105h — 185h — 006h Port B data 086h Port B direction 106h Port B data 186h Port B direction 007h Port C data 087h Port C direction 107h — 187h — 008h Port D data 088h Port D direction 108h — 188h — 009h Port E data 089h Port E direction 109h — 189h — 00Ah Prog. count. high 08Ah Prog. count. high 10Ah Prog. count. high 18Ah Prog. count. high 00Bh Interrupt control 08Bh Interrupt control 10Bh Interrupt control 18Bh Interrupt control 00Ch– 01Fh 20 peripheral control registers 08Ch– 09Fh 20 peripheral control registers 10Ch– 10Fh 4 peripheral control registers 18Ch– 18Fh 4 peripheral control registers 110h– 11Fh 16 general purpose registers 190h– 19Fh 16 general purpose registers 020h– 06Fh 80 general purpose registers 0A0h– 0EFh 80 general purpose registers 120h– 16Fh 80 general purpose registers 1A0h– 1EFh 80 general purpose registers 070h– 07Fh 16 common access GPRs 0F0h– 0FFh Accesses 070h– 07Fh 170h– 17Fh Accesses 070h– 07Fh 1F0h– 1FFh Accesses 070h– 07Fh Ch01-H8960.indd 6 Ch01-H8960.indd 6 6/10/2008 4:56:54 PM 6/10/2008 4:56:54 PM
  • 21.
    PIC Microcontroller Systems7 www.newnespress.com RAM File Registers The main RAM block (Table 1.1) is a set of 368 8-bit file registers, including the special function registers (SFRs), which have a dedicated function, and the general purpose registers (GPRs). When variables are created in C, they are stored in the GPRs, starting at address 0020h. The file registers are divided into four blocks, register banks 0 to 3. The SFRs are located at the low addresses in each RAM bank. Some registers are addressable across the bank boundaries; for example, the status register can be accessed in all blocks at the corresponding address in each bank. Others are addressable in only a specific page, for example, Port A data register. Some register addresses are not physically implemented. Since some registers are accessible in multiple banks, bank switching can be minimized by the compiler when assembling the machine code, thus saving program code space and execution time. For full details of the file register set, see the MCU data sheet. The program counter uses two 8-bit registers to store a 13-bit program memory address. Only the low byte at address 002h is directly addressable. The status register 003h records results from ALU (arithmetic and logic unit) operations, such as zero and carry/ borrow. The indirect and file select registers are used for indexed addressing of the GPRs. Timer0 is the timer/counter register available in all PIC MCUs, while Timer1 and Timer2 registers are in the peripheral block. The port registers are located in Bank 0 at addresses 05h (Port A) to 09h (Port E) with the data direction register for each at the corresponding location in bank 1. We can see that a total of 80 ⫹ 16 ⫹ 80 ⫹ 96 ⫹ 96 ⫽ 368 GPRs are available for use as data RAM. Note that the number of registers used for each C variable depends on the variable type and can range from 1 to 32 bits (1–4 GPRs). Other PIC Chips In any embedded design, the features of the MCU need to be matched to the application requirements. The manufacturer needs to make sure that, as applications become more demanding, a more powerful device of a familiar type is available. We can see this process at work where Microchip started out producing basic chips such as the 16C84, then developed the product range to meet the growing market. PIC microcontrollers are currently available in distinct groups, designated the 10, 12, 16, 18, and 24 series. Their general characteristics are outlined in Table 1.2. The original 16 series CMOS devices were designated as 16CXX. When flash memory was introduced, they became 16FXXX. Currently, a limited number of devices are Ch01-H8960.indd 7 Ch01-H8960.indd 7 6/10/2008 4:56:54 PM 6/10/2008 4:56:54 PM
  • 22.
    8 Part 1 www.newnespress.com availablein the low pin count (LPC) ranges (10/12 series), while the power ranges are expanding rapidly. In addition are those listed in the 24HXXXX range, which runs at 40 MIPS, and the dsPIC (digital signal processor) high-specification range. 1.2 PIC16 MCU Configuration ● Clock oscillator types ● Watchdog, power-up, brown-out timers ● Low-voltage programming ● Code protection ● In-circuit debug mode When programming the PIC microcontroller, certain operational modes must be set prior to the main program download. These are controlled by individual bits in a special Table 1.2: PIC Microcontroller Types MCU Pins Data Word (bits) Program Memory (bytes) Typical Instruction Set Speed MIPS Description 10FXXX ⫽ 6 8 ⱕ512 33 ⫻ 12 bits ⱕ2 Low pin count, small form factor, cheap, no EEPROM, no low-power, assembler program 12FXXX ⫽ 8 8 ⱕ2 kB 12/14 bits ⱕ0.5 Low pin count, small form factor, cheap, EEPROM, 10-bit ADC, some low power, assembler 16FXXX ⱕ64 8 ⱕ14 kB 35 ⫻ 14 bits ⱕ5 Mid-range, UART, I2C, SPI, many low power, C or assembler program 18FXXXX ⱕ100 8 ⱕ128 kB 75 ⫻ 16 bits ⱕ16 High range, CAN, USB J series 3V supply, C program 24FXXXX ⱕ100 16 ⱕ128 kB 76 ⫻ 24 bits ⫽ 16 Power range, 3V supply, no EEPROM, data RAM ⱕ8 kB, C program Ch01-H8960.indd 8 Ch01-H8960.indd 8 6/10/2008 4:56:54 PM 6/10/2008 4:56:54 PM
  • 23.
    PIC Microcontroller Systems9 www.newnespress.com configuration register separated from the main memory block. The main options are as follows. Clock Options The ‘877 chip has two main clock modes, CR and XT. The CR mode needs a simple capacitor and resistor circuit attached to CLKIN, whose time constant (C ⫻ R) determines the clock period. R should be between 3k and 100k, and C greater than 20pF. For example, if R ⫽ 10kΩ and C ⫽ 10nF, the clock period will be around 2 ⫻ C ⫻ R ⫽ 200 μs (calculated from the CR rise/fall time) and the frequency about 5kHz. This option is acceptable when the program timing is not critical. The XT mode is the one most commonly used, since the extra component cost is small compared with the cost of the chip itself and accurate timing is often a necessity. An external crystal and two capacitors are fitted to CLKIN and CLKOUT pins. The crystal frequency in this mode can be from 200kHz to 4MHz and is typically accurate to better than 50ppm (parts per million) or 0.005%. A convenient value is 4Mz, as this is the maximum frequency possible with a standard crystal and gives an instruction execution time of 1.000 μs (1 million instructions per second, or 1Mip). A low-speed crystal can be used to reduce power consumption, which is proportional to clock speed in CMOS devices. The LP (low-power) mode supports the clock frequency range 32–200kHz. To achieve the maximum clock speed of 20MHz, a high-speed (HS) crystal is needed, with a corresponding increase in power consumption. The MCU configuration fuses must be set to the required clock mode when the chip is programmed. Many PIC chips now have an internal oscillator, which needs no external components. It is more accurate than the RC clock but less accurate than a crystal. It typically runs at 8MHz and can be calibrated in the chip configuration phase to provide a more accurate timing source. Configuration Options Apart from the clock options, several other hardware options must be selected. Watchdog Timer When enabled, the watchdog timer (WDT) automatically resets the processor after a given period (default 18ms). This allows, for example, an application to escape from an endless loop caused by a program bug or run-time condition not anticipated by the Ch01-H8960.indd 9 Ch01-H8960.indd 9 6/10/2008 4:56:54 PM 6/10/2008 4:56:54 PM
  • 24.
    10 Part 1 www.newnespress.com softwaredesigner. To maintain normal operation, the WDT must be disabled or reset within the program loop before the set time-out period has expired. It is therefore important to set the MCU configuration bits to disable the WDT if it is not intended to use this feature. Otherwise, the program is liable to misbehave, due to random resetting of the MCU. Power-up Timer The power-up timer (PuT) provides a nominal 72ms delay between the power supply voltage reaching the operating value and the start of program execution. This ensures that the supply voltage is stable before the clock starts up. It is recommended that it be enabled as a precaution, as there is no adverse effect on normal program execution. Oscillator Start-up Timer After the power-up timer has expired, a further delay allows the clock to stabilize before program execution begins. When one of the crystal clock modes is selected, the CPU waits 1024 cycles before the CPU is enabled. Brown-out Reset (BoR) It is possible for a transitory supply voltage drop, or brown-out, to disrupt the MCU program execution. When enabled, the brown-out detection circuit holds the MCU in reset while the supply voltage is below a given threshold and releases it when the supply has recovered. In CCS C, a low-voltage detect function triggers an interrupt that allows the program to be restarted in an orderly way. Code Protection (CP) The chip can be configured during programming to prevent the machine code being read back from the chip to protect commercially valuable or secure code. Optionally, only selected portions of the program code may be write protected (see WRT_X% later). In-Circuit Programming and Debugging Most PIC chips now support in-circuit programming and debugging (ICPD), which allows the program code to be downloaded and tested in the target hardware, under the control of the host system. This provides a final test stage after software simulation has been used to eliminate most of the program bugs. MPLAB allows the same interface to be Ch01-H8960.indd 10 Ch01-H8960.indd 10 6/10/2008 4:56:55 PM 6/10/2008 4:56:55 PM
  • 25.
    PIC Microcontroller Systems11 www.newnespress.com used for debugging in both the simulation and in-circuit modes. The slight disadvantage of this option is that care must be taken that any application circuit connected to the programming/ICPD pins does not interfere with the operation of these features. It is preferable to leave these pins for the exclusive use of the ICPD system. In addition, a small section of program memory is required to run the debugging code. Low-Voltage Programming Mode The low-voltage programming mode can be selected during programming so that the customary high (12V) programming voltage is not needed, and the chip can be programmed at Vdd (⫹5V). The downside is that the programming pin cannot then be used for digital I/O. In any case, it is recommended here that the programming pins not be used for I/O by the inexperienced designer, as hardware contention could occur. Electrically Erasable Programmable Read Only Memory Many PIC MCUs have a block of nonvolatile user memory where data can be stored during power-down. These data could, for example, be the secure code for an electronic lock or smart card reader. The electrically erasable programmable read only memory (EEPROM) can be rewritten by individual location, unlike flash program ROM. The ‘877 has a block of 256 bytes, which is a fairly typical value. There is a special read/write sequence to prevent accidental overwriting of the data. Configuration in C The preprocessor directive #fuses is used to set the configuration fuses in C programs for PICs. A typical statement is #fuses XT,PUT,NOWDT,NOPROTECT,NOBROWNOUT The options defined in the standard CCS C 16F877 header file are Clock Type Select LP, XT, HS, RC Watchdog Timer Enable WDT, NOWDT Power Up Timer Enable PUT, NOPUT Program Code Protect PROTECT, NOPROTECT In Circuit Debugging Enable DEBUG, NODEBUG Brownout Reset Enable BROWNOUT, NOBROWNOUT Low Voltage Program Enable LVP, NOLVP EEPROM Write Protect CPD, NOCPD Program Memory Write Protect WRT_50%, WRT_25%, (with percentage protected) WRT_5%, NOWRT Ch01-H8960.indd 11 Ch01-H8960.indd 11 6/10/2008 4:56:55 PM 6/10/2008 4:56:55 PM
  • 26.
    12 Part 1 www.newnespress.com Thedefault condition for the fuses if no such directive is included is equivalent to #fuses RC,WDT,NOPUT,BROWNOUT,LVP,NOCPD,NOWRT This corresponds to all the bits of configuration register being default high. 1.3 PIC16 MCU Peripherals ● Digital I/O ● Timers ● A/D converter ● Comparator ● Parallel slave port ● Interrupts Basic digital input and output (I/O) in the microcontroller uses a bidirectional port pin. The default pin configuration is generally digital input, as this is the safest option if some error has been made in the external connections. To set the pin as output, the corresponding data direction bit must be cleared in the port data direction register (e.g., TRISD). Note, however, that pins connected to the analog-to-digital (A/D) converter default to the analog input mode. The basic digital I/O hardware is illustrated in simplified form in Figure 1.4, with provision for analog input. The 16 series reference manual shows equivalent circuits for individual pins in more detail. For input, the current driver output is disabled by loading the data direction bit with a 1, which switches off the tristate gate. Data are read into the input data latch from the outside world when its control line is pulsed by the CPU in the course of a port register read instruction. The data are then copied to the CPU working register for processing. When the port is set up for output, a 0 is loaded into the data direction bit, enabling the current output. The output data are loaded into the data latch from the CPU. A data 1 at the output allows the current driver to source up to 25mA at 5V, or whatever the supply voltage is (2–6V). A data 0 allows the pin to sink a similar current at 0V. Ch01-H8960.indd 12 Ch01-H8960.indd 12 6/10/2008 4:56:55 PM 6/10/2008 4:56:55 PM
  • 27.
    PIC Microcontroller Systems13 www.newnespress.com The 16F877 has the following digital I/O ports available: Port A RA0–RA5 6 bits Port B RB0–RB7 8 bits Port C RC0–RC7 8 bits Port D RD0–RD7 8 bits Port E RE0–RE2 3 bits Total digital I/O available 33 pins Most of the pins have alternate functions, which are described later. Timers Most microcontrollers provide hardware binary counters that allow a time interval measurement or count to be carried out separately from program execution. For example, a fixed period output pulse train can be generated while the program continues with another task. The features of the timers found in the typical PIC chip are represented in Figure 1.5, but none of those in the ‘877 has all the features shown. The count register most commonly is operated by driving it from the internal instruction clock to form a timer. This signal runs at one quarter of the clock frequency; that is, one instruction takes four cycles to execute. Therefore, with a 4-MHz clock, the timer counts in microseconds (1-MHz instruction clock). The number of bits in the timer (8 or 16) Data Direction Latch Output Data Latch Input Data Latch Output Current Driver Tristate Output Enable Write TRIS bit CPU Data Bus Write Data bit Read Data bit Analog Input Multiplexer Figure 1.4: I/O Pin Operation Ch01-H8960.indd 13 Ch01-H8960.indd 13 6/10/2008 4:56:55 PM 6/10/2008 4:56:55 PM
  • 28.
    14 Part 1 www.newnespress.com determinesthe maximum count (256 or 65536, respectively). When the timer register overflows and returns to zero, an overflow flag bit is set. This flag can be polled (tested) to check if an overflow has occurred or an interrupt generated, to trigger the required action. To modify the count period, the timer register can be preloaded with a given number. For example, if an 8-bit register is preloaded with the value 156, a time-out occurs after 256 ⫺ 156 ⫽ 100 clocks. Many timer modules allow automatic preloading each time it is restarted, in which case the required value is stored in a preload register during timer initialization. A prescaler typically allows the timer input frequency to be divided by 2, 4, 8, 16, 32, 64, or 128. This extends the maximum count proportionately but at the expense of timer precision. For example, the 8-bit timer driven at 1MHz with a prescale value of 4 counts up to 256 ⫻ 4 ⫽ 1024 μs, at 4 μs per bit. A postscaler has a similar effect, connected at the output of the counter. In the compare mode, a separate period register stores a value that is compared with the current count after each clock and the status flag set when they match. This is a more elegant method of modifying the time-out period, which can be used in generating a pulse width modulated (PWM) output. A typical application is to control the output power to a current load, such as a small DC motor—more on this later. In the capture mode, the timer count is captured (copied to another register) at the point in time when an external signal changes at one of the MCU pins. This can be used to measure the length of an input pulse or the period of a waveform. The ’877 has three counter/timer registers. Timer0 has an 8-bit counter and 8-bit prescaler. It can be clocked from the instruction clock or an external signal applied to RA4. The prescaler can also be used to extend the watchdog timer interval (see later), in which case it is not available for use with Timer0. Timer1 has a 16-bit counter and prescaler and can be clocked internally or externally as per Timer0. It offers capture and Clock Source Select Prescaler (Clock Divide) Postscaler (Output Divide) Timer Overflow/ Time-out (Interrupt) Flag Capture Signal Capture Register Compare Register Binary Counter Match Flag Instruction Clock External Pulse Figure 1.5: General Timer Operation Ch01-H8960.indd 14 Ch01-H8960.indd 14 6/10/2008 4:56:55 PM 6/10/2008 4:56:55 PM
  • 29.
    PIC Microcontroller Systems15 www.newnespress.com compare modes of operation. Timer2 is another 8-bit counter but has both a prescaler and postscaler (up to 1:16) and a compare register for period control. Further details are provided in Interfacing PIC Microcontrollers by the author and the MCU data books. When programming in C, only a limited knowledge of timer operation is necessary, as the C functions generally take care of the details. A/D Converter Certain PIC pins can be set up as inputs to an analog-to-digital converter (ADC). The ’877 has eight analog inputs, which are connected to Port A and Port E. When used in this mode, they are referred to as AD0–AD7. The necessary control registers are initialized in CCS C using a set of functions that allow the ADC operating mode and inputs to be selected. An additional “device” directive at the top of the program sets the ADC resolution. An analog voltage presented at the input is then converted to binary and the value assigned to an integer variable when the function to read the ADC is invoked. The default input range is set by the supply (nominally 0–5V). If a battery supply is used (which drops over time) or additional accuracy is needed, a separate reference voltage can be fed in at AN2 (⫹Vref) and optionally AN3 (–Vref). If only ⫹Vref is used, the lower limit remains 0V, while the upper is set by the reference voltage. This is typically supplied using a zener diode and voltage divider. The 2.56V derived from a 2V7 zener gives a conversion factor of 10mV per bit for an 8-bit conversion. For a 10-bit input, a reference of 4.096V might be convenient, giving a resolution of 4mV per bit. The essentials of ADC operation are illustrated in Figure 1.6. Comparator The comparator (Figure 1.7) is an alternative type of analog input found in some microcontrollers, such as the 16F917 used in the mechatronics board described later. Figure 1.6: ADC Operation Multiplexer Input Volts 0-Vf Setup ADC Read ADC 8-bit or 16-bit Integer Result Analog- to-Digital Converter ANx ⫹Vref Analog Inputs Reference Volts Ch01-H8960.indd 15 Ch01-H8960.indd 15 6/10/2008 4:56:56 PM 6/10/2008 4:56:56 PM
  • 30.
    Another Random Documenton Scribd Without Any Related Topics
  • 31.
    string have beenwashed. As it grows up, the tree is called the “contemporary” of the child.870 So in Bali a cocoa-palm is planted at the birth of a child. It is believed to grow up equally with the child, and is called its “life-plant.”871 On certain occasions the Dyaks of Borneo plant a palm-tree, which is believed to be a complete index of their fate. If it flourishes, they reckon on good fortune; but if it withers or dies, they [pg 330] expect misfortune.872 It is said that there are still families in Russia, Germany, England, France, and Italy who are accustomed to plant a tree at the birth of a child. The tree, it is hoped, will grow with the child, and it is tended with special care.873 The custom is still pretty general in the canton of Aargau in Switzerland; an apple-tree is planted for a boy and a pear-tree for a girl, and the people think that the child will flourish or dwindle with the tree.874 In Mecklenburg the after-birth is thrown out at the foot of a young tree, and the child is then believed to grow with the tree.875 In England persons are sometimes passed through a cleft tree as a cure for rupture, and thenceforward a sympathetic connection is believed to exist between them and the tree. “Thomas Chillingworth, son of the owner of an adjoining farm, now about thirty-four years of age, was, when an infant of a year old, passed through a similar tree, now perfectly sound, which he preserves with so much care that he will not suffer a single branch to be touched, for it is believed that the life of the patient depends on the life of the tree; and the moment that it is cut down, be the patient ever so distant, the rupture returns, and a mortification ensues.”876 When Lord Byron first visited his ancestral estate of Newstead “he planted, it seems, a young oak in some part of the grounds, and had an idea that as it flourished so should he.”877 But in practice, as in folk-tales, it is not merely [pg 331] with trees and plants that the life of an individual is occasionally believed to be united by a bond of physical sympathy. The same bond, it is supposed, may exist between a man and an animal or a thing, so that the death or destruction of the animal or thing is immediately followed by the death of the man. The Emperor Romanus Lecapenus
  • 32.
    was once informedby an astronomer that the life of Simeon prince of Bulgaria was bound up with a certain column in Constantinople, so that if the capital of the column were removed Simeon would immediately die. The Emperor took the hint and removed the capital, and at the same hour, as the emperor learned by inquiry, Simeon died of heart disease in Bulgaria.878 Amongst the Karens of Burma “the knife with which the navel-string is cut is carefully preserved for the child. The life of the child is supposed to be in some way connected with it, for if lost or destroyed it is said the child will not be long-lived.”879 The Malays believe that “the soul of a person may pass into another person or into an animal, or rather that such a mysterious relation can arise between the two that the fate of the one is wholly dependent on that of the other.”880 In the Banks Islands “some people connect themselves with an object, generally an animal, as a lizard or a snake, or with a stone, which they imagine to have a certain very close natural relation to themselves. This, at Mota, is called tamaniu—likeness. This word at Aurora is used for the ‘atai’ [i.e. soul] of Mota. Some fancy dictates the choice of a tamaniu; or it may be [pg 332] found by drinking the infusion of certain herbs and heaping together the dregs. Whatever living thing is first seen in or upon the heap is the tamaniu. It is watched, but not fed or worshipped. The natives believe that it comes at call. The life of the man is bound up with the life of his tamaniu. If it dies, gets broken or lost, the man will die. In sickness they send to see how the tamaniu is, and judge the issue accordingly. This is only the fancy of some.”881 But what among the Banks Islanders and the Malays is irregular and occasional, among other peoples is systematic and universal. The Zulus believe that every man has his ihlozi, a kind of mysterious serpent, “which specially guards and helps him, lives with him, wakes with him, sleeps and travels with him, but always under ground. If it ever makes its appearance, great is the joy, and the man must seek to discover the meaning of its appearance. He who has no ihlozi must die. Therefore if any one unintentionally kills an ihlozi serpent, the man whose ihlozi it was dies, but the serpent
  • 33.
    comes to lifeagain.”882 Amongst the Zapotecs of Central America, when a woman was about to be confined, her relations assembled in the hut, and began to draw on the floor figures of different animals, rubbing each one out as soon as it was completed. This went on till the moment of birth, and the figure that then remained sketched upon the ground was called the child's tona or second self. “When the child grew old enough he procured the animal that represented him and took care of it, as it [pg 333] was believed that health and existence were bound up with that of the animal's, in fact that the death of both would occur simultaneously,” or rather that when the animal died the man would die.883 Among the Indians of Guatemala the nagual or naual is an “animate or inanimate object, generally an animal, which stands in a parallel relation to a particular man, so that the weal and woe of the man depend on the fate of the animal.” Among the Chontal Indians who inhabit the part of Honduras bordering on Guatemala and in point of social culture stand very close to the Pipil Indians of Guatemala, the nagual used to be obtained as follows. The young Indian went into the forest to a lonely place by a river or to the top of a mountain, and prayed with tears to the gods that they would vouchsafe to him what his forefathers had possessed before him. After sacrificing a dog or a bird he laid himself down to sleep. Then in a dream or after awakening from sleep there appeared to him a jaguar, puma, coyote (prairie-wolf), crocodile, serpent, or bird. To this visionary animal the Indian offered blood drawn from his tongue, his ears, and other parts of his body, and prayed for an abundant yield of salt and cacao. Then the animal said to him, “On such and such a day you shall go out hunting, and the first animal that meets you will be myself, who will always be your companion and nagual.” A man who had no nagual could never grow rich. The Indians were persuaded that the death of their nagual would entail their own. Legend affirms that in the first battles with the Spaniards on [pg 334] the plateau of Quetzaltenango the naguals of the Indian chiefs fought in the form of serpents. The nagual of the highest chief was especially conspicuous, because it had the form of a great bird, resplendent in
  • 34.
    green plumage. TheSpanish general Pedro de Alvarado killed the bird with his lance, and at the same moment the Indian chief fell dead to the ground.884 In many of the Australian tribes each sex regards a particular species of animals in the same way that a Central American Indian regards his nagual, but with this difference, that whereas the Indian apparently knows the individual animal with which his life is bound up, the Australians only know that each of their lives is bound up with some one animal of the species, but they cannot say with which. The result naturally is that every man spares and protects all the animals of the species with which the lives of the men are bound up; and every woman spares and protects all the animals of the species with which the lives of the women are bound up; because no one knows but that the death of any animal of the respective species might entail his or her own; just as the killing of the green bird was immediately followed by the death of the Indian chief, and the killing of the parrot by the death of Punchkin in the fairy tale. Thus, for example, the Wotjobaluk tribe of South Eastern Australia “held that ‘the life of Ngŭnŭngŭnŭt (the Bat) is the life of a man and the life of Yártatgŭrk (the Nightjar) is the life of a woman,’ and that when either of these creatures is killed the life of some man or of some woman is shortened. In such a case every man or every woman [pg 335] in the camp feared that he or she might be the victim, and from this cause great fights arose in this tribe. I learn that in these fights, men on one side and women on the other, it was not at all certain which would be victorious, for at times the women gave the men a severe drubbing with their yamsticks while often women were injured or killed by spears.”885 The particular species of animals with which the lives of the sexes were believed to be respectively bound up varied somewhat from tribe to tribe. Thus whereas among the Wotjobaluk the bat was the animal of the men, at Gunbower Creek on the lower Murray the bat seems to have been the animal of the women, for the natives would not kill it for the reason that “if it was killed, one of their lubras [women] would be sure to die in consequence.”886 But the belief itself and the fights to which it gave
  • 35.
    rise are knownto have extended over a large part of South Eastern Australia, and probably they extended much farther.887 The belief is a very serious one, and so consequently are the fights which spring from it. Thus where the bat is the men's animal they “protect it against injury, even to the half-killing of their wives for its sake;” and where the fern owl or large goatsucker (a night bird) is the women's animal, “it is jealously protected by them. If a man kills one, they are as much enraged as if it was one of their children, and will strike him with their long poles.”888 The jealous protection thus afforded by Australian men and women to bats and owls respectively (for bats [pg 336] and owls seem to be the creatures usually allotted to men and women respectively) is not based upon purely selfish considerations. For each man believes that not only his own life, but the lives of his father, brothers, sons, etc., are bound up with the lives of particular bats, and that therefore in protecting the bat species he is protecting the lives of all his male relations as well as his own. Similarly, each woman believes that the lives of her mother, sisters, daughters, etc., equally with her own, are bound up with the lives of particular owls, and that in guarding the owl species she is guarding the lives of all her female relations in addition to her own. Now, when men's lives are thus supposed to be contained in certain animals, it is obvious that the animals can hardly be distinguished from the men, or the men from the animals. If my brother John's life is in a bat, then, on the one hand, the bat is my brother as well as John; and, on the other hand, John is in a sense a bat, since his life is in a bat. Similarly, if my sister Mary's life is in an owl, then the owl is my sister and Mary is an owl. This is a natural enough conclusion, and the Australians have not failed to draw it. When the bat is the man's animal, it is called his brother; and when the owl is the woman's animal, it is called her sister. And conversely a man addresses a woman as an owl, and she addresses him as a bat.889 So with the other animals allotted to the sexes respectively in other tribes. For example, among the Kurnai all Emu Wrens were “brothers” of the men, and all the men were Emu
  • 36.
    Wrens; all SuperbWarblers were “sisters” of the women, and all the women were Superb Warblers.890 [pg 337] But when a savage names himself after an animal, calls it his brother, and refuses to kill it, the animal is said to be his totem. Accordingly the bat and the owl, the Emu Wren and the Superb Warbler, may properly be described as totems of the sexes. But the assignation of a totem to a sex is comparatively rare, and has hitherto been discovered nowhere but in Australia. Far more commonly the totem is appropriated not to a sex, but to a tribe or clan, and is hereditary either in the male or female line. The relation of an individual to the tribal totem does not differ in kind from his relation to the sex totem; he will not kill it, he speaks of it as his brother, and he calls himself by its name.891 Now if the relations are similar, the explanation which holds good of the one ought equally to hold good of the other. Therefore the reason why a tribe revere a particular species of animals or plants (for the tribal totem may be a plant) and call themselves after it, must be a belief that the life of each individual of the tribe is bound up with some one animal or plant of the species, and that his or her death would be the consequence of killing that particular animal, or destroying that particular plant. This explanation of totemism squares very well with Sir George Grey's definition of a totem or kobong in Western Australia. He says, “A certain mysterious connection exists between a family and its kobong, so that a member of the family will never kill an animal of the species to which his kobong belongs, should he find it asleep; indeed he always kills it reluctantly, and never without affording it a chance to escape. This arises from the family belief that some one individual of the species is their nearest friend, to [pg 338] kill whom would be a great crime, and to be carefully avoided. Similarly, a native who has a vegetable for his kobong may not gather it under certain circumstances, and at a particular period of the year.”892 Here it will be observed that though each man spares all the animals or plants of the species, they are not all equally precious to him; far from it, out of the whole species there is only one which
  • 37.
    is specially dearto him; but as he does not know which the dear one is, he is obliged to spare them all from fear of injuring the one. Again, this explanation of the tribal totem harmonises with the supposed effect of killing one of the totem species. “One day one of the blacks killed a crow. Three or four days afterwards a Boortwa (crow) [i.e. a man of the Crow clan or tribe] named Larry died. He had been ailing for some days, but the killing of his wingong [totem] hastened his death.”893 Here the killing of the crow caused the death of a man of the Crow clan, exactly as, in the case of the sex totems, the killing of a bat causes the death of a Bat man, or the killing of an owl causes the death of an Owl woman. Similarly, the killing of his nagual causes the death of a Central American Indian, the killing of his ihlozi causes the death of a Zulu, the killing of his tamaniu causes the death of a Banks Islander, and the killing of the animal in which his life is stowed away causes the death of the giant or warlock in the fairy tale. Thus it appears that the story of “The giant who had no heart in his body” furnishes the key to the religious aspect of totemism, that is, to the relation which is supposed to subsist between a man and his totem. The totem, if I am right, is simply the receptacle [pg 339] in which a man keeps his life, as Punchkin kept his life in a parrot, and Bidasari kept her soul in a golden fish. It is no valid objection to this view that when a savage has both a sex totem and a tribal totem his life must be bound up with two different animals, the death of either of which would entail his own. If a man has more vital places than one in his body, why, the savage may think, should he not have more vital places than one outside it? Why, since he can externalise his life, should he not transfer one portion of it to one animal and another to another? The divisibility of life, or, to put it otherwise, the plurality of souls, is an idea suggested by many familiar facts, and has commended itself to philosophers like Plato as well as to savages. It is only when the notion of a soul, from being a quasi- scientific hypothesis, becomes a theological dogma that its unity and indivisibility are insisted upon as essential. The savage, unshackled by dogma, is free to explain the facts of life by the assumption of as
  • 38.
    many souls ashe thinks necessary. Hence, for example, the Caribs supposed that there was one soul in the head, another in the heart, and other souls at all the places where an artery is felt pulsating.894 Some of the Hidatsa Indians explain the phenomena of gradual death, when the extremities appear dead first, by supposing that man has four souls, and that they quit the body, not simultaneously, but one after the other, dissolution being only complete when all four have departed.895 The Laos suppose that the body is the seat of thirty spirits, which reside in the hands, the feet, the mouth, the eyes, etc.896 Hence, [pg 340] from the primitive point of view, it is perfectly possible that a savage should have one soul in his sex totem, and another in his tribal totem. However, as I have observed, sex totems occur nowhere but in Australia; so that as a rule the savage who practises totemism need not have more than one soul out of his body at a time. If this explanation of the totem as a receptacle in which a man keeps his soul or one of his souls is correct, we should expect to find some totemistic tribes of whom it is expressly stated that every man amongst them is believed to keep at least one soul permanently out of his body, and that the destruction of this external soul is supposed to entail the death of its owner. Such a tribe are the Battas of Sumatra. The Battas are divided into exogamous clans (margas) with descent in the male line; and each clan is forbidden to eat the flesh of a particular animal. One clan may not eat the tiger, another the ape, another the crocodile, another the dog, another the cat, another the dove, another the white buffalo. The reason given by members of a clan for abstaining from the flesh of the particular animal is either that they are descended from animals of that species, and that their souls after death may transmigrate into the animals, or that they or their forefathers have been under certain obligations to the animals. Sometimes, but not always, the clan bears the name of the animal.897 Thus the Battas have [pg 341] totemism in full. But, further, each Batta believes that he has seven or, on a more moderate computation, three souls. One of these souls is always outside the body, but nevertheless whenever it dies,
  • 39.
    however far awayit may be at the time, that same moment the man dies also.898 The writer who mentions this belief says nothing about the Batta totems; but on the analogy of the Australian and Central American evidence we can scarcely avoid concluding that the external soul, whose death entails the death of the man, must be housed in the totem animal or plant. Against this view it can hardly be thought to militate that the Batta does not in set terms affirm his external soul to be in his totem, but alleges other, though hardly contradictory, grounds for respecting the sacred animal or plant of his clan. For if a savage seriously believes that his life is bound up with an external object, it is in the last degree unlikely that he will let any stranger into the secret. In all that touches his inmost life and beliefs the savage is exceedingly suspicious and reserved; Europeans have resided among savages for years without discovering some of their capital articles of faith, and in the end the discovery has often been the result of accident. Above all, the savage lives in an intense and perpetual dread of assassination by sorcery; the most trifling relics of his person—the clippings of his hair and nails, his spittle, the remnants of his food, his very name—all these may, he fancies, be turned by the sorcerer to his destruction, and he is therefore anxiously careful to conceal or destroy them. But if in matters such as [pg 342] these, which are but the outposts and outworks of his life, he is shy and secretive to a degree, how close must be the concealment, how impenetrable the reserve in which he enshrouds the inner keep and citadel of his being! When the princess in the fairy tale asks the giant where he keeps his soul, he generally gives false or evasive answers, and it is only after much coaxing and wheedling that the secret is at last wrung from him. In his jealous reticence the giant resembles the timid and furtive savage; but whereas the exigencies of the story demand that the giant should at last reveal his secret, no such obligation is laid on the savage; and no inducement that can be offered is likely to tempt him to imperil his soul by revealing its hiding-place to a stranger. It is therefore no matter for surprise that the central mystery of the savage's life should so long have
  • 40.
    remained a secret,and that we should be left to piece it together from scattered hints and fragments and from the recollections of it which linger in fairy tales. This view of totemism throws light on a class of religious rites of which no adequate explanation, so far as I am aware, has yet been offered. Amongst many savage tribes, especially such as are known to practise totemism, it is customary for lads at puberty to undergo certain initiatory rites, of which one of the commonest is a pretence of killing the lad and bringing him to life again. Such rites become intelligible if we suppose that their substance consists in extracting the youth's soul in order to transfer it to his totem. For the extraction of his soul would naturally be supposed to kill the youth or, at least, to throw him into a death-like trance, which the savage hardly distinguishes from death. His recovery would then be attributed either [pg 343] to the gradual recovery of his system from the violent shock which it had received, or, more probably, to the infusion into him of fresh life drawn from the totem. Thus the essence of these initiatory rites, so far as they consist in a simulation of death and resurrection, would be an exchange of life or souls between the man and his totem. The primitive belief in the possibility of such an exchange of souls comes clearly out in the story of the Basque hunter who affirmed that he had been killed by a bear, but that the bear had, after killing him, breathed its own soul into him, so that the bear's body was now dead, but he himself was a bear, being animated by the bear's soul.899 This revival of the dead hunter as a bear is exactly analogous to what, if I am right, is supposed to take place in the totemistic ceremony of killing a lad at puberty and bringing him to life again. The lad dies as a man and comes to life again as an animal; the animal's soul is now in him, and his human soul is in the animal. With good right, therefore, does he call himself a Bear or a Wolf, etc., according to his totem; and with good right does he treat the bears or the wolves, etc., as his brethren, since in these animals are lodged the souls of himself and his kindred.
  • 41.
    Examples of thissupposed death and resurrection at initiation are the following. Among some of the Australian tribes of New South Wales, when lads are initiated, it is thought that a being called Thuremlin takes each lad to a distance, kills him, and sometimes cuts him up, after which he restores him to life and knocks out a tooth.900 In one part of Queensland the [pg 344] humming sound of the Bullroarer, which is swung at the initiatory rites, is said to be the noise made by the wizards in swallowing the boys and bringing them up again as young men. “The Ualaroi of the Upper Darling River say that the boy meets a ghost which kills him and brings him to life again as a man.”901 This resurrection appears to be represented at the initiatory rites by the following ceremony. An old man, disguised with stringy bark fibre, lies down in a grave, and is lightly covered up with sticks and earth, and as far as possible the natural appearance of the ground is restored, the excavated earth being carried away. The buried man holds a small bush in his hand; it appears to be growing in the soil, and other bushes are stuck in the soil to heighten the effect. The novices are then brought to the edge of the grave, and a song is sung, in which the only words used are the “class-name” of the buried man and the word for stringy bark fibre. Gradually, as the song continues, the bush held by the buried man begins to quiver and then to move more and more, and finally the man himself starts up from the grave.902 Similarly, Fijian lads at initiation were shown a row of apparently dead men, covered with blood, their bodies seemingly cut open, and their entrails protruding. But at a yell from the [pg 345] priest the pretended dead men sprang to their feet and ran to the river to cleanse themselves from the blood and entrails of pigs with which they had been besmeared.903 In the valley of the Congo initiatory rites of this sort are common. In some places they are called Ndembo. “In the practice of Ndembo the initiating doctors get some one to fall down in a pretended fit, and in that state he is carried away to an enclosed place outside the town. This is called ‘dying Ndembo.’ Others follow suit, generally boys and girls, but often young men and women.... They are supposed to
  • 42.
    have died. Butthe parents and friends supply food, and after a period varying, according to custom, from three months to three years, it is arranged that the doctor shall bring them to life again.... When the doctor's fee has been paid, and money (goods) saved for a feast, the Ndembo people are brought to life. At first they pretend to know no one and nothing; they do not even know how to masticate food, and friends have to perform that office for them. They want everything nice that any one uninitiated may have, and beat them if it is not granted, or even strangle and kill people. They do not get into trouble for this, because it is thought that they do not know better. Sometimes they carry on the pretence of talking gibberish, and behaving as if they had returned from the spirit- world. After this they are known by another name, peculiar to those who have ‘died Ndembo.’ ... We hear of the custom far along on the upper river, as well as in the cataract region.”904 The following account of [pg 346] the rites, as practised in this part of Africa, was given to Bastian by an interpreter. “In the land of Ambamba every one must die once, and when the fetish priest shakes his calabash against a village, all the men and lads whose hour is come fall into a state of lifeless torpidity, from which they generally awake after three days. But if the fetish loves a man he carries him away into the bush and buries him in the fetish house, often for many years. When he comes to life again, he begins to eat and drink as before, but his understanding is gone and the fetish man must teach him and direct him in every motion, like the smallest child. At first this can only be done with a stick, but gradually his senses return, so that it is possible to talk with him, and when his education is complete, the priest brings him back to his parents. They would seldom recognise their son but for the express assurances of the fetish priest, who moreover recalls previous events to their memory. He who has not gone through the ceremony of the new birth in Ambamba is universally looked down upon and is not admitted to the dances.” During the period of initiation the novice is sympathetically united to the fetish by which his life is henceforward determined.905 The novice, plunged in the magic sleep or death-like trance within the
  • 43.
    sacred hut, “beholdsa bird or other object with which his existence is thenceforward sympathetically bound up, just as the life of the young Indian is bound up with the animal which he sees in his dreams at puberty.”906 [pg 347] Rites of this sort were formerly observed in Quoja, on the west coast of Africa, to the north of the Congo. They are thus described by an old writer:—“They have another ceremony which they call Belli- Paaro, but it is not for everybody. For it is an incorporation in the assembly of the spirits, and confers the right of entering their groves, that is to say, of going and eating the offerings which the simple folk bring thither. The initiation or admission to the Belli-Paaro is celebrated every twenty or twenty-five years. The initiated recount marvels of the ceremony, saying that they are roasted, that they entirely change their habits and life, and that they receive a spirit quite different from that of other people and quite new lights. The badge of membership consists in some lines traced on the neck between the shoulders; the lines seem to be pricked with a needle. Those who have this mark pass for persons of spirit, and when they have attained a certain age they are allowed a voice in all public assemblies; whereas the uninitiated are regarded as profane, impure, and ignorant persons, who dare not express an opinion on any subject of importance. When the time for the ceremony has come, it is celebrated as follows: By order of the king a place is appointed in the forest, whither they bring the youths who have not been marked, not without much crying and weeping; for it is impressed upon the youths that in order to undergo this change it is necessary to suffer death. So they dispose of their property, as if it were all over with them. There are always some of the initiated beside the novices to instruct them. They teach them to dance a certain dance called killing, and to sing verses in praise of Belli. Above all, they are very careful not to let them die of hunger, [pg 348] because if they did so, it is much to be feared that the spiritual resurrection would profit them nothing. This manner of life lasts five or six years, and is comfortable enough, for there is a village in the
  • 44.
    forest, and theyamuse themselves with hunting and fishing. Other lads are brought thither from time to time, so that the last comers have not long to stay. No woman or uninitiated person is suffered to pass within four or five leagues of the sacred wood. When their instruction is completed, they are taken from the wood and shut up in small huts made for the purpose. Here they begin once more to hold communion with mankind and to talk with the women who bring them their food. It is amusing to see their affected simplicity. They pretend to know no one, and to be ignorant of all the customs of the country, such as the customs of washing themselves, rubbing themselves with oil, etc. When they enter these huts, their bodies are all covered with the feathers of birds, and they wear caps of bark which hang down before their faces. But after a time they are dressed in clothes and taken to a great open place, where all the people of the neighbourhood are assembled. Here the novices give the first proof of their capacity by dancing a dance which is called the dance of Belli. After the dance is over, the novices are taken to the houses of their parents by their instructors.”907 Among the Indians of Virginia, an initiatory ceremony, called Huskanaw, took place every sixteen or twenty years, or oftener, as the young men happened to grow up. The youths were kept in solitary confinement in the woods for several months, [pg 349] receiving no food but an infusion of some intoxicating roots, so that they went raving mad, and continued in this state eighteen or twenty days. “Upon this occasion it is pretended that these poor creatures drink so much of the water of Lethe that they perfectly lose the remembrance of all former things, even of their parents, their treasure, and their language. When the doctors find that they have drank sufficiently of the Wysoccan (so they call this mad potion), they gradually restore them to their senses again by lessening the intoxication of their diet; but before they are perfectly well they bring them back into their towns, while they are still wild and crazy through the violence of the medicine. After this they are very fearful of discovering anything of their former remembrance; for if such a thing should happen to any of them, they must immediately
  • 45.
    be Huskanaw'd again;and the second time the usage is so severe that seldom any one escapes with life. Thus they must pretend to have forgot the very use of their tongues, so as not to be able to speak, nor understand anything that is spoken, till they learn it again. Now, whether this be real or counterfeit, I don't know; but certain it is that they will not for some time take notice of any body nor any thing with which they were before acquainted, being still under the guard of their keepers, who constantly wait upon them everywhere till they have learnt all things perfectly over again. Thus they unlive their former lives, and commence men by forgetting that they ever have been boys.”908 Among some of the Indian tribes of North America there are certain religious associations which are only open to candidates who have gone through a pretence [pg 350] of being killed and brought to life again. Captain Carver witnessed the admission of a candidate to an association called “the friendly society of the Spirit” among the Naudowessies. The candidate knelt before the chief, who told him that “he himself was now agitated by the same spirit which he should in a few moments communicate to him; that it would strike him dead, but that he would instantly be restored again to life.... As he spoke this, he appeared to be greatly agitated, till at last his emotions became so violent that his countenance was distorted and his whole frame convulsed. At this juncture he threw something that appeared both in shape and colour like a small bean at the young man, which seemed to enter his mouth, and he instantly fell as motionless as if he had been shot.” For a time the man lay like dead, but under a shower of blows he showed signs of consciousness, and finally, discharging from his mouth the bean, or whatever it was the chief had thrown at him, he came to life.909 In other tribes the instrument by which the candidate is apparently slain is the medicine-bag. The bag is made of the skin of an animal (such as the otter, wild cat, serpent, bear, raccoon, wolf, owl, weasel), of which it roughly preserves the shape. Each member of the society has one of these bags, in which he keeps the odds and ends that make up his “medicine” or charms. “They believe that from the miscellaneous
  • 46.
    contents in thebelly of the skin bag or animal there issues a spirit or breath, which has the power, not only to knock down and kill a man, but also to set him up and restore him to life.” The mode of killing a man with one of these medicine-bags is to thrust it at him; [pg 351] he falls like dead, but a second thrust of the bag restores him to life.910 A ceremony witnessed by Jewitt during his captivity among the Indians of Nootka Sound doubtless belongs to this class of customs. The Indian king or chief “discharged a pistol close to his son's ear, who immediately fell down as if killed, upon which all the women of the house set up a most lamentable cry, tearing handfuls of hair from their heads, and exclaiming that the prince was dead; at the same time a great number of the inhabitants rushed into the house armed with their daggers, muskets, etc., inquiring the cause of their outcry. These were immediately followed by two others dressed in wolf skins, with masks over their faces representing the head of that animal. The latter came in on their hands and feet in the manner of a beast, and taking up the prince, carried him off upon their backs, retiring in the same manner as they entered.”911 In another place Jewitt mentions that the young prince—a lad of about eleven years of age—wore a mask in imitation of a wolf's head.912 Now, as the Indians of this part of America are divided into totem clans, of which the Wolf clan is one of the principal, and as the members of each clan are in the habit of wearing some portion of the totem animal about their person,913 it is probable that the prince belonged to the Wolf clan, and that the ceremony described by Jewitt represented the killing [pg 352] of the lad in order that he might be born anew as a wolf, much in the same way that the Basque hunter supposed himself to have been killed and to have come to life again as a bear. The Toukaway Indians of Texas, one of whose totems is the wolf, have a ceremony in which men, dressed in wolf skins, run about on all fours, howling and mimicking wolves. At last they scratch up a living tribesman, who has been buried on purpose, and putting a bow and arrows in his hands, bid him do as the wolves do—rob, kill, and murder.914 The ceremony probably forms part of an initiatory rite
  • 47.
    like the resurrectionfrom the grave of the old man in the Australian rites. The people of Rook, an island east of New Guinea, hold festivals at which one or two disguised men, their heads covered with wooden masks, go dancing through the village, followed by all the other men. They demand that the circumcised boys who have not yet been swallowed by Marsaba (the devil) shall be given up to them. The boys, trembling and shrieking, are delivered to them, and must creep between the legs of the disguised men. Then the procession moves through the village again, and announces that Marsaba has eaten up the boys, and will not disgorge them till he receives a present of pigs, taro, etc. So all the villagers, according to their means, contribute provisions, which are then consumed in the name of Marsaba.915 In New Britain all males are members [pg 353] of an association called the Duk-duk. The boys are admitted to it very young, but are not fully initiated till their fourteenth year, when they receive from the Tubuvan a terrible blow with a cane, which is supposed to kill them. The Tubuvan and the Duk-duk are two disguised men who represent cassowaries. They dance with a short hopping step in imitation of the cassowary. Each of them wears a huge hat like an extinguisher, woven of grass or palm-fibres; it is six feet high, and descends to the wearer's shoulders, completely concealing his head and face. From the neck to the knees the man's body is hidden by a crinoline made of the leaves of a certain tree fastened on hoops, one above the other. The Tubuvan is regarded as a female, the Duk-duk as a male. No woman may see these disguised men. The institution of the Duk-duk is common to the neighbouring islands of New Ireland and the Duke of York.916 Amongst the Galela and Tobelorese of Halmahera, an island to the west of New Guinea, boys go through a form of initiation, part of which seems to consist in a pretence of begetting them anew. When a number of boys have reached the proper age, their parents agree to celebrate the ceremony at their common expense, and they invite others to be present at it. A shed is erected, and two long tables are
  • 48.
    placed in it,with [pg 354] benches to match, one for the men and one for the women. When all the preparations have been made for a feast, a great many skins of the rayfish, and some pieces of a wood which imparts a red colour to water, are taken to the shed. A priest or elder causes a vessel to be placed in the sight of all the people, and then begins, with significant gestures, to rub a piece of the wood with the ray-skin. The powder so produced is put in the vessel, and at the same time the name of one of the boys is called out. The same proceeding is repeated for each boy. Then the vessels are filled with water, after which the feast begins. At the third cock-crow the priest smears the faces and bodies of the boys with the red water, which represents the blood shed at the perforation of the hymen. Towards daybreak the boys are taken to the wood, and must hide behind the largest trees. The men, armed with sword and shield, accompany them, dancing and singing. The priest knocks thrice on each of the trees behind which a boy is hiding. All day the boys stay in the wood, exposing themselves to the heat of the sun as much as possible. In the evening they bathe and return to the shed, where the women supply them with food.917 In the west of Ceram boys at puberty are admitted to the Kakian association.918 Modern writers [pg 355] have commonly regarded this association as primarily a political league instituted to resist foreign domination. In reality its objects are purely religious and social, though it is possible that the priests may have occasionally used their powerful influence for political ends. The society is in fact merely one of those widely-diffused primitive institutions, of which a chief object is the initiation of young men. In recent years the true nature of the association has been duly recognised by the distinguished Dutch ethnologist, J. G. F. Riedel. The Kakian house is an oblong wooden shed, situated under the darkest trees in the depth of the forest, and is built to admit so little light that it is impossible to see what goes on in it. Every village has such a house. Thither the boys who are to be initiated are conducted blindfolded, followed by their parents and relations. Each boy is led by the hand by two men, who act as his sponsors or guardians, looking after him
  • 49.
    during the periodof initiation. When all are assembled before the shed, the high priest calls aloud upon the devils. Immediately a hideous uproar is heard to proceed from the shed. It is made by men with bamboo trumpets, who have been secretly introduced into the building by a back door, but the women and children think it is made by the devils, and are much terrified. Then the priests enter the shed, followed by the boys, one at a time. As soon as each boy has disappeared within the precincts, a dull chopping sound is heard, a fearful cry rings out, and a sword or spear, dripping with blood, is thrust [pg 356] through the roof of the shed. This is a token that the boy's head has been cut off, and that the devil has carried him away to the other world, there to regenerate and transform him. So at sight of the bloody sword the mothers weep and wail, crying that the devil has murdered their children. In some places, it would seem, the boys are pushed through an opening made in the shape of a crocodile's jaws or a cassowary's beak, and it is then said that the devil has swallowed them. The boys remain in the shed for five or nine days. Sitting in the dark, they hear the blast of the bamboo trumpets, and from time to time the sound of musket shots and the clash of swords. Every day they bathe, and their faces and bodies are smeared with a yellow dye, to give them the appearance of having been swallowed by the devil. During his stay in the Kakian house each boy has one or two crosses tattooed with thorns on his breast or arm. When they are not sleeping, the lads must sit in a crouching posture without moving a muscle. As they sit in a row cross-legged, with their hands stretched out, the chief takes his trumpet, and placing the mouth of it on the hands of each lad, speaks through it in strange tones, imitating the voice of the spirits. He warns the lads, under pain of death, to observe the rules of the Kakian society, and never to reveal what has passed in the Kakian house. The novices are also told by the priests to behave well to their blood relations, and are taught the traditions and secrets of the tribe. Meantime the mothers and sisters of the lads have gone home to weep and mourn. But in a day or two the men who acted as
  • 50.
    guardians or sponsorsto the novices return to the village with the glad tidings that the devil, at the intercession of the priests, has restored [pg 357] the lads to life. The men who bring this news come in a fainting state and daubed with mud, like messengers freshly arrived from the nether world. Before leaving the Kakian house, each lad receives from the priest a stick adorned at both ends with cock's or cassowary's feathers. The sticks are supposed to have been given to the lads by the devil at the time when he restored them to life, and they serve as a token that the lads have been in the spirit-land. When they return to their homes they totter in their walk, and enter the house backward, as if they had forgotten how to walk properly; or they enter the house by the back door. If a plate of food is given to them, they hold it upside down. They remain dumb, indicating their wants by signs only. All this is to show that they are still under the influence of the devil or the spirits. Their sponsors have to teach them all the common acts of life, as if they were new-born children. Further, upon leaving the Kakian house the boys are strictly forbidden to eat of certain fruits until the next celebration of the rites has taken place. And for twenty or thirty days their hair may not be combed by their mothers or sisters. At the end of that time the high priest takes them to a lonely place in the forest, and cuts off a lock of hair from the crown of each of their heads. After these initiatory rites the lads are deemed men, and may marry; it would be a scandal if they married before. The simulation of death and resurrection or of a new birth at initiation appears to have lingered on, or at least to have left traces of itself, among peoples who have advanced far beyond the stage of savagery. Thus, after his investiture with the sacred thread—the symbol of his order—a Brahman is called “twice-born.” [pg 358] Manu says, “According to the injunction of the revealed texts the first birth of an Aryan is from his natural mother, the second happens on the tying of the girdle of Muñga grass, and the third on the initiation to the performance of a Srauta sacrifice.”919 A pretence of killing the candidate appears to have formed part of the initiation to the Mithraic mysteries.920
  • 51.
    Thus, if Iam right, wherever totemism is found, and wherever a pretence is made of killing and bringing to life again at initiation, there must exist or have existed not only a belief in the possibility of permanently depositing the soul in some external object—animal, plant, or what not—but an actual intention of so depositing it. If the question is put, why do men desire to deposit their life outside their bodies? the answer can only be that, like the giant in the fairy tale, they think it safer to do so than to carry it about with them, just as people deposit their money with a banker rather than carry it on their persons. We have seen that at critical periods the life or soul is sometimes temporarily deposited in a safe place till the danger is past. But institutions like totemism are not resorted to merely on special occasions of danger; they are systems into which every one, or at least every male, is obliged to be initiated at a certain period of life. Now the period of life at which initiation takes place is regularly puberty; and this fact suggests that the special danger which totemism and systems like it are intended to obviate is supposed not to arise till sexual maturity has been attained, in fact, that the danger [pg 359] apprehended is believed to attend the relation of the sexes to each other. It would be easy to prove by a long array of facts that the sexual relation is associated in the primitive mind with many supernatural perils; but the exact nature of the danger apprehended is still obscure. We may hope that a more exact acquaintance with savage modes of thought will in time disclose this central mystery of primitive society, and will thereby furnish the clue, not only to the social aspect of totemism (the prohibition of sexual union between persons of the same totem), but to the origin of the marriage system.
  • 53.
    § 5.—Conclusion. Thus theview that Balder's life was in the mistletoe is entirely in harmony with primitive modes of thought. It may indeed sound like a contradiction that, if his life was in the mistletoe, he should nevertheless have been killed by a blow from it. But when a person's life is conceived as embodied in a particular object, with the existence of which his own existence is inseparably bound up, and the destruction of which involves his own, the object in question may be regarded and spoken of indifferently as the person's life or as his death, as happens in the fairy tales. Hence if a man's death is in an object, it is perfectly natural that he should be killed by a blow from it. In the fairy tales Koshchei the Deathless is killed by a blow from the egg or the stone in which his life or death is;921 the ogres burst when a certain grain of sand—doubtless containing their life or death—is carried over their [pg 360] heads;922 the magician dies when the stone in which his life or death is contained is put under his pillow;923 and the Tartar hero is warned that he may be killed by the golden arrow or golden sword in which his soul has been stowed away.924 The idea that the life of the oak was in the mistletoe was probably suggested, as I have said, by the observation that in winter the mistletoe growing on the oak remains green, while the oak itself is leafless. But the position of the plant—growing, not from the ground, but from the trunk or branches of the tree—might confirm this idea. Primitive man might think that, like himself, the oak-spirit had sought to deposit his life in some safe place, and for this purpose had pitched on the mistletoe, which, being in a sense neither on earth nor in heaven, was as secure a place as could be found. At the beginning of this chapter we saw that primitive man
  • 54.
    seeks to preservethe life of his human divinities by keeping them in a sort of intermediate position between earth and heaven, as the place where they are least likely to be assailed by the dangers that encompass the life of man on earth. We can therefore [pg 361] understand why in modern folk-medicine the mistletoe is not allowed to touch the ground; if it touches the ground, its healing virtue is supposed to be gone.925 This may be a survival of the old superstition that the plant in which the life of the sacred tree was concentrated should not be exposed to the risk incurred by contact with the ground. In an Indian legend, which offers a parallel to the Balder myth, Indra promised the demon Namuci not to kill him by day or by night, nor with what was wet or what was dry. But he killed him in the morning twilight by sprinkling over him the foam of the sea.926 The foam of the sea is just such an object as a savage might choose to put his life in, because it occupies that sort of intermediate or nondescript position between earth and sky or sea and sky in which primitive man sees safety. It is therefore not surprising that the foam of the river should be the totem of a clan in India.927 Again, the view that the mistletoe owes its mystic character partly to the fact of its not growing on the ground is confirmed by a parallel superstition about the mountain-ash or rowan-tree. In Jutland a rowan that is found growing out of the top of another tree is esteemed “exceedingly effective against witchcraft: since it does not grow on the ground witches have no power over it; if it is to have its full effect it must be cut on Ascension Day.”928 Hence it is placed over doors to prevent the ingress of witches.929 Similarly the mistletoe in Germany is still [pg 362] universally considered a protection against witchcraft, and in Sweden, as we saw, the mistletoe which is gathered on Midsummer Eve is attached to the ceiling of the house, the horse stall, or the cow's crib, in the belief that this renders the Troll powerless to injure man or beast.930 The view that the mistletoe was not merely the instrument of Balder's death, but that it contained his life, is countenanced by the analogy of a Scottish superstition. Tradition ran that the fate of the family of Hay was bound up with the mistletoe of a certain oak.
  • 55.
    “While the mistletoebats on Errol's oak, And that oak stands fast, The Hays shall flourish, and their good gray hawk Shall not flinch before the blast. “But when the root of the oak decays, And the mistletoe dwines on its withered breast, The grass shall grow on the Earl's hearthstone, And the corbies craw in the falcon's nest.” “A large oak with the mistletoe growing on it was long pointed out as the tree referred to. A piece of the mistletoe cut by a Hay was believed to have magical virtues. ‘The oak is gone and the estate is lost to the family,’ as a local historian says.”931 The idea that the fate of a family, as distinct from the lives of its members, is bound up with a particular plant or tree, is no doubt comparatively modern. The older view probably was that the lives of all the Hays were in this particular mistletoe, just as in the Indian story the lives of all the ogres are in a lemon; to break a twig of the mistletoe would then have been to kill one [pg 363] of the Hays. Similarly in the island of Rum, whose bold mountains the voyager from Oban to Skye observes to seaward, it was thought that if one of the family of Lachlin shot a deer on the mountain of Finchra, he would die suddenly or contract a distemper which would soon prove fatal.932 Probably the life of the Lachlins was bound up with the deer on Finchra, as the life of the Hays was bound up with the mistletoe on Errol's oak. It is not a new opinion that the Golden Bough was the mistletoe.933 True, Virgil does not identify but only compares it with the mistletoe. But this may be only a poetical device to cast a mystic glamour over the humble plant. Or, more probably, his description was based on a popular superstition that at certain times the mistletoe blazed out into a supernatural golden glory. The poet tells how two doves, guiding Aeneas to the gloomy vale in whose depth grew the Golden
  • 56.
    Bough, alighted upona tree, “whence shone a flickering gleam of gold. As in the woods in winter cold the mistletoe—a plant not native to its tree—is green with fresh leaves and twines its yellow berries about the boles; such seemed upon the shady oak the leafy gold, so rustled in the gentle breeze the golden leaf.”934 Here Virgil definitely describes the Golden Bough as growing on an oak, and compares it with the mistletoe. The inference is almost inevitable that the Golden Bough was nothing but the mistletoe seen through the haze of poetry or of popular superstition. Now grounds have been shown for believing that [pg 364] the priest of the Arician grove—the King of the Wood—personified the tree on which grew the Golden Bough.935 Hence, if that tree was the oak, the King of the Wood must have been a personification of the oak- spirit. It is, therefore, easy to understand why, before he could be slain, it was necessary to break the Golden Bough. As an oak-spirit, his life or death was in the mistletoe on the oak, and so long as the mistletoe remained intact, he, like Balder, could not die. To slay him, therefore, it was necessary to break the mistletoe, and probably, as in the case of Balder, to throw it at him. And to complete the parallel, it is only necessary to suppose that the King of the Wood was formerly burned, dead or alive, at the midsummer fire festival which, as we have seen, was annually celebrated in the Arician grove.936 The perpetual fire which burned in the grove, like the perpetual fire under the oak at Romove, was probably fed with the sacred oak-wood; and thus it would be in a great fire of oak that the King of the Wood formerly met his end. At a later time, as I have suggested, his annual tenure of office was lengthened or shortened, as the case might be, by the rule which allowed him to live so long as he could prove his divine right by the strong hand. But he only escaped the fire to fall by the sword. Thus it seems that at a remote age in the heart of Italy, beside the sweet lake of Nemi, the same fiery tragedy was annually enacted which Italian merchants and soldiers were afterwards to witness among their rude kindred, the Celts of Gaul, and which, if the [pg
  • 57.
    365] Roman eagleshad ever swooped on Norway, might have been found repeated with little difference among the barbarous Aryans of the North. The rite was probably an essential feature in the primitive Aryan worship of the oak.937 It only remains to ask, Why was the mistletoe called the Golden Bough? The name was not simply a poet's fancy, nor even peculiarly Italian; for in Welsh also the mistletoe is known as “the tree of pure gold.”938 The whitish-yellow of the mistletoe berries is hardly enough to account for the name. For Virgil says that the Bough was altogether golden, stem as well as leaves,939 and the same is implied in the Welsh name, “the tree of pure gold.” A clue to the real meaning of the name is furnished by the mythical fern-seed or fern- bloom. We saw that fern-seed is popularly supposed to bloom like gold or fire on Midsummer Eve. Thus in Bohemia it is said that “on St. John's Day fern-seed blooms with golden blossoms that gleam like fire.”940 Now it is a property of this mythical fern-seed that whoever has it, or will ascend a mountain holding it in his hand on Midsummer Eve, will discover a vein of gold or will see the treasures of the earth shining with a bluish flame.941 And if you place fern-seed [pg 366] among money, the money will never decrease, however much of it you spend.942 Sometimes the fern-seed is supposed to bloom at Christmas, and whoever catches it will become very rich.943 Thus, on the principle of like by like, fern-seed is supposed to discover gold because it is itself golden; and for a similar reason it enriches its possessor with an unfailing supply of gold. But while the fern-seed is described as golden, it is equally described as glowing and fiery.944 Hence, when we consider that two great days for gathering the fabulous seed are Midsummer Eve and Christmas—that is, the two solstices (for Christmas is nothing but an old heathen celebration of the winter solstice)—we are led to regard the fiery aspect of the fern-seed as primary, and its golden aspect as secondary and derivative. Fern-seed, in fact, would seem to be an emanation of the sun's fire at the two turning-points of its course, the summer and
  • 58.
    winter solstices. Thisview is confirmed by a German story in which a hunter is said to have procured fern-seed by shooting at the sun on Midsummer Day at noon; three drops of blood fell down, which he caught in a white cloth, and these blood-drops were the fern- seed.945 Here the blood is clearly the blood of the sun, from which the fern-seed is thus directly derived. Thus it may be taken as certain that fern-seed is golden, because it is believed to be an emanation of the sun's golden fire. Now, like fern-seed, the mistletoe is gathered [pg 367] either at Midsummer or Christmas946 —that is, at the summer and winter solstices—and, like fern-seed, it is supposed to possess the power of revealing treasures in the earth. On Midsummer Eve people in Sweden make divining-rods of mistletoe or of four different kinds of wood, one of which must be mistletoe. The treasure-seeker places the rod on the ground after sundown, and when it rests directly over treasure, the rod begins to move as if it were alive.947 Now, if the mistletoe discovers gold, it must be in its character of the Golden Bough; and if it is gathered at the solstices, must not the Golden Bough, like the golden fern-seed, be an emanation of the sun's fire? The question cannot be answered with a simple affirmative. We have seen that the primitive Aryans probably kindled the midsummer bonfires as sun-charms, that is, with the intention of supplying the sun with fresh fire. But as this fire was always elicited by the friction of oak wood,948 it must have appeared to the primitive Aryan that the sun was periodically recruited from the fire which resided in the sacred oak. In other words, the oak must have seemed to him the original storehouse or reservoir of the fire which was from time to time drawn out to feed the sun. But the life of the oak was conceived to be in the mistletoe; therefore the mistletoe must have contained the seed or germ of the [pg 368] fire which was elicited by friction from the wood of the oak. Thus, instead of saying that the mistletoe was an emanation of the sun's fire, it would be more correct to say that the sun's fire was regarded as an emanation of the mistletoe. No wonder, then, that the mistletoe shone with a golden splendour, and was called the Golden Bough. Probably,
  • 59.
    Welcome to ourwebsite – the ideal destination for book lovers and knowledge seekers. With a mission to inspire endlessly, we offer a vast collection of books, ranging from classic literary works to specialized publications, self-development books, and children's literature. Each book is a new journey of discovery, expanding knowledge and enriching the soul of the reade Our website is not just a platform for buying books, but a bridge connecting readers to the timeless values of culture and wisdom. With an elegant, user-friendly interface and an intelligent search system, we are committed to providing a quick and convenient shopping experience. Additionally, our special promotions and home delivery services ensure that you save time and fully enjoy the joy of reading. Let us accompany you on the journey of exploring knowledge and personal growth! ebookname.com