Professional Documents
Culture Documents
(Download PDF) Arduino Interrupts Norman Dunbar Full Chapter PDF
(Download PDF) Arduino Interrupts Norman Dunbar Full Chapter PDF
(Download PDF) Arduino Interrupts Norman Dunbar Full Chapter PDF
https://ebookmass.com/product/king-of-the-hill-norman-mailer-on-
the-fight-of-the-century-norman-mailer/
https://ebookmass.com/product/prelude-for-lost-souls-helene-
dunbar-2/
https://ebookmass.com/product/prelude-for-lost-souls-helene-
dunbar/
https://ebookmass.com/product/oxford-practice-grammar-basic-
norman-coe/
The Promise of Lost Things Helene Dunbar
https://ebookmass.com/product/the-promise-of-lost-things-helene-
dunbar/
https://ebookmass.com/product/we-are-lost-and-found-helene-
dunbar/
https://ebookmass.com/product/we-are-lost-and-found-helene-
dunbar-2/
https://ebookmass.com/product/we-are-lost-and-found-helene-
dunbar-3/
https://ebookmass.com/product/we-are-lost-and-found-helene-
dunbar-4/
Maker Innovations Series
Jump start your path to discovery with the Apress Maker Innovations
series! From the basics of electricity and components through to the
most advanced options in robotics and Machine Learning, you'll forge a
path to building ingenious hardware and controlling it with cutting-edge
software. All while gaining new skills and experience with common
toolsets you can take to new projects or even into a whole new career.
The Apress Maker Innovations series offers projects-based learning,
while keeping theory and best processes front and center. So you get
hands-on experience while also learning the terms of the trade and how
entrepreneurs, inventors, and engineers think through creating and
executing hardware projects. You can learn to design circuits, program
AI, create IoT systems for your home or even city, and so much more!
Whether you're a beginning hobbyist or a seasoned entrepreneur
working out of your basement or garage, you'll scale up your skillset to
become a hardware design and engineering pro. And often using low-
cost and open-source software such as the Raspberry Pi, Arduino, PIC
microcontroller, and Robot Operating System (ROS). Programmers and
software engineers have great opportunities to learn, too, as many
projects and control environments are based in popular languages and
operating systems, such as Python and Linux.
If you want to build a robot, set up a smart home, tackle assembling a
weather-ready meteorology system, or create a brand-new circuit using
breadboards and circuit design software, this series has all that and
more! Written by creative and seasoned Makers, every book in the series
tackles both tested and leading-edge approaches and technologies for
bringing your visions and projects to life.
More information about this series at https://link.springer.com/
bookseries/17311.
Norman Dunbar
Arduino Interrupts
Harness the Power of Interrupts in Your Arduino
and ATmega328 Code
Norman Dunbar
Rawdon, West Yorkshire, UK
This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in
any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.
The publisher, the authors, and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
Hopefully, you will note that the code formatting is in the same style as
the code in the Arduino IDE environment.
This is thanks to arduinoLanguage.tex, a small LATE X file,
which is available from my GitHub repository.2 Of course, this was not all
my own work; I forked the original repository owned by “Trihedral.”3 I
am extremely grateful to “Trihedral” for making the code available as it
saved me no end of work, not least trying to figure out the color codes! I
have slightly amended my version to highlight the ATmega328P’s
register and bit names in addition to the Arduino Language highlighting.
If the code in Listing 1 is not highlighted as it would normally appear
in the Arduino IDE, then I humbly apologize; the production processes
in converting my PDF files into a proper book appear to have
overwritten the Arduino style with their own in-house style. C’est la vie.
You are permitted to reuse the code listed in this book as you see fit
– it’s here to help you, so use it! And if you want to credit me, then
feel free to do so as well – but it’s not mandatory.
The code repository for this book is located at https://github.com/
Apress/arduino-interrupts.
3 Admonitions
If I want to draw your attention to something or emphasize some fact
from the main body of the text, I will use a note, as follows:
Note
This is a note that I want to bring to your attention.
If there is something that you really need to be aware of, you will see
this:
Warning
This is some text that I want to bring to your attention. It may help
prevent your Arduino from releasing the magic blue smoke that
makes it work, or it may explain the reason why your code fails to do
what was expected.
Tip
Never run with scissors!
Terminology
Terms like “master” and “slave” are deemed to be no longer acceptable,
and many organizations have been amending their documentation to
replace those terms with other, more acceptable ones.
In the data sheet for the ATmega328P,6 the existing “master” and
“slave” terms are still in place. In this book, I will avoid those terms,
unless I am directly quoting from the data sheet or using the name of a
register or bit within a register.
I will be replacing “slave” with “sensor” or “peripheral” and “master”
with “controller” as appropriate and as is currently the new standard.
Introduction
This book is intended to be a guide, for beginners and moderately
experienced Arduino makers, into the slightly scary world of Arduino
Interrupts. Actually, it’s not actually the Arduino, it’s the Arduino’s
microcontroller, the ATmega328P. However, I’ll be using one or two of
my Arduino boards as test beds throughout.
Interrupts do not feature much7 in the Arduino Language, but are an
integral part of the AVR hardware itself. They are what allows your
sketch, or application code, to apparently do two things at once.
Consider, for example, that your laser cutter has a powerful and
exceedingly destructive laser beam. You would like the beam to cut off
immediately when you hit the Big Red PANIC! Switch – it’s no good to
you, or anyone else, if the beam carries on until the end of the
programmed cut and then checks to see if the switch has been pressed.
That switch is almost 100% certain to be attached to an interrupt,
and that interrupt will “fire” as soon as the switch is hit, cutting off the
beam immediately.
There are times when polling a sensor is acceptable, but in doing so,
you waste the microcontroller’s time and resources when it should be
left to get on with whatever the main task is, and only process the sensor
input when the sensor has some to offer.
Do you sit in your lounge at home regularly checking the front door
to see if someone is there? Or do you wait for the doorbell to chime,
interrupting whatever you are doing at the time? That’s the difference
between polling and interrupts in a nutshell.
The main body of code continues as programmed, doing what it does
best, and without checking the “front door” all the time. When the
“doorbell” chimes, the program is interrupted, saves its place in the
code, goes off to see who is at the door, and then comes back to continue
from where it left off. There’s no specific place that it can be interrupted;
it can happen at any place in the code, and it will be handled correctly –
if programmed to do so.
In the forthcoming chapters, I will explain the vast majority of the
interrupts8 available on the microcontroller used in the Arduino Uno,
Nano, and my favorite, the Duemilanove, the Atmel (now Microchip)
ATmega328P. In each case, where relevant, I will explain what the
interrupt is for; how it works; how, or if, it can be used in an Arduino
sketch; and how it can be used in plain AVR C++ code. In addition, if I
feel like showing off, I will show it in AVR Assembly Language. All the
demonstration code will be available for download from the book’s
GitHub account.
Where appropriate, each demonstration will be accompanied by a
Fritzing9 project in which only the breadboard layout is of any relevance.
For those readers without a Fritzing installation (and why not?), there
will be a PNG image, exported from the project, to show the breadboard
layout.
Any source code or other supplementary material referenced by the
author in this book is available to readers on GitHub (github.com/
Apress). For more detailed information, please visit https://www.
apress.com/gp/services/source-code.
Acknowledgments
I would like to thank everyone at Apress and Springer who were
involved in the production of this book. Some names that spring to mind
are Miriam Haidara, my Commissioning Editor, who thought this would
be a good book; Sowmya Thodur who has had to suffer keeping me
organized and on the straight and narrow; Jessica Vakili who has had the
misfortune to have to work with me on two books now; James Markham,
my Development Editor; and especially to all the unsung heroes behind
the scenes who converted my files into something you can hold in your
hand and read in the bath!
Open source has played a big part in this book too. The book was
written using the LyX editor (www.lyx.org/).
Graphics for various circuit schematics and breadboard layouts are
courtesy of the Fritzing tool for circuit design (https://fritzing.org/).
Arduino code highlighting is facilitated by the Arduino Latex Listing
project run by “Trihedral” on GitHub (https://github.com/trihedral/
ArduinoLatexListing/).
Code for the book was developed using both the Arduino IDE
versions 1.8.6 and 2.1.0 (www.arduino.cc/) and PlatformIO, my
preferred development system (https://platformio.org/).
Finally, I must thank my Technical Reviewer, Farzin Asadi, who
kindly read and commented on my code and pointed out a, thankfully,
small number of errors and improvements.
Contents
1 Arduino Interrupts
1.1 Interrupt Concepts
1.2 Interrupt Processing
1.3 Interrupts While Processing Interrupts
1.4 Interrupts While Not Configured
1.5 Interrupt Coding – Points to Note
1.5.1 Do You Really Need Interrupts?
1.5.2 Delays and Serial Input/Output
1.5.3 Keep ISRs Short
1.5.4 Variables May Be Volatile
1.5.5 Interrupt Vectors Can Be Relocated by Fuse Settings
1.5.6 The Arduino Doesn’t Make Interrupts Easy
1.6 Key Takeaways
1.7 Coming Up
2 Reset Interrupt
2.1 Resetting the Board
2.2 Register Summary
2.2.1 MCU Status Register
2.3 Key Takeaways
2.4 Coming Up
3 External Interrupts INT0/INT1
3.1 Interrupts INT0 and INT1
3.2 Setting Up Arduino Interrupts
3.2.1 Interrupt Number
3.2.2 Interrupt Function
3.2.3 Interrupt Stimulus
3.2.4 Arduino Polling Example
3.2.5 Arduino Interrupt Example
3.3 Setting Up AVR Interrupts
3.3.1 Register Usage
3.3.2 Configuring the Interrupt
3.3.3 Enabling the Interrupt
3.3.4 Interrupt Service Routines
3.4 AVR Interrupt Example
3.4.1 Compiling AVR Code in the Arduino IDE
3.5 Interrupt Flags
3.6 Register Summary
3.6.1 External Interrupt Mask Register
3.6.2 External Interrupt Control Register A
3.6.3 External Interrupt Flag Register
3.7 Key Takeaways
3.8 Coming Up
4 Pin Change Interrupts
4.1 Changing Pins
4.2 Arduino and ATmega328P Pinout
4.3 Setting Up Arduino Interrupts
4.4 Setting Up AVR Interrupts
4.4.1 Choosing Pins, Setting Masks
4.4.2 Enabling Pin Change Interrupts
4.4.3 Pin Change Interrupt Setup Summary
4.4.4 Writing the ISR
4.5 The AVR Sketch – Single Pin
4.6 The AVR Application – Multiple Pins
4.7 Interrupt Flags
4.8 Register Summary
4.8.1 Pin Change Interrupt Control Register
4.8.2 Pin Change Mask Registers
4.8.3 Pin Change Interrupt Flag Register
4.9 Key Takeaways
4.10 Coming Up
5 Watchdog Interrupt
5.1 Watching the Board
5.2 Setting Up the Watchdog Timer
5.2.1 The Easy Method
5.2.2 The Watchdog Timer Control and Status Register
5.2.3 The Hard Method
5.2.4 Watchdog Timer Reset Loop
5.3 Watchdog Timer Interrupt Flag
5.4 Arduino Watchdog Timer Interrupt Sketch
5.5 AVR Watchdog Timer Interrupt Application
5.6 Watchdog Reset Sketch
5.7 Register Summary
5.7.1 Watchdog Timer Control and Status Register
5.7.2 MCU Control Register
5.8 Key Takeaways
5.9 Coming Up
6 Timer/Counter Interrupts
6.1 Timers and Counters
6.2 Timer/Counter Bits and Pieces
6.3 Overflow Interrupt
6.3.1 Configuring Timer/Counter 1
6.3.2 Arduino Overflow Interrupts
6.3.3 AVR Overflow Interrupts
6.4 Compare Match A/B Interrupt
6.4.1 Compare Match Pins
6.4.2 Timer/Counter Configuration
6.4.3 Arduino Compare Match Interrupts
6.4.4 AVR Match Interrupts
6.5 Input Capture Event Interrupt
6.5.1 Timer/Counter 1 Configuration
6.5.2 Arduino Input Capture Interrupts
6.5.3 AVR Input Capture Interrupts
6.6 Register Summary
6.6.1 Timer/Counter Interrupt Mask Registers
6.6.2 Timer/Counter Interrupt Flag Registers
6.7 Key Takeaways
6.8 Coming Up
7 SPI Interrupt
7.1 I SPI with My Little Eye
7.2 SPI Background
7.2.1 SPI Clock
7.2.2 SPI Frequency
7.2.3 Bit Ordering
7.2.4 Phase, Polarity, and SPI Mode
7.3 Data Transfers
7.4 Controller and Peripheral Modes
7.4.1 Controller Mode
7.4.2 Peripheral Mode
7.5 Write Collision Errors
7.6 Interrupts
7.6.1 Controller Interrupts
7.6.2 Peripheral Interrupts
7.7 Controller Mode—Interrupt LED Driver
7.7.1 The SN74HC595 Shift Register
7.7.2 The LED Driver Circuit
7.7.3 The LED Driver Code
7.8 Peripheral Mode—LED Driver
7.9 What About Plain AVR C++?
7.9.1 Compiling and Uploading
7.10 Register Summary
7.10.1 SPI Data Register
7.10.2 SPI Control Register
7.10.3 SPI Status Register
7.10.4 Data Direction B Register
7.11 Key Takeaways
7.12 Coming Up
8 USART Interrupts
8.1 The USART
8.2 USART Configuration
8.2.1 Register UCSR0A
8.2.2 Register UCSR0B
8.2.3 Register UCSR0C
8.2.4 Register UBRR0
8.2.5 Register UDR0
8.3 USART Transmitting
8.3.1 USART Data Register Empty
8.3.2 USART Transmit Complete
8.4 USART Receiving
8.4.1 USART Receive Complete
8.5 Using USART Interrupts on the Arduino
8.5.1 Using the printf() Function
8.5.2 The Arduino Sketch
8.6 Using USART Interrupts in AVR Code
8.6.1 Interrupt Handling
8.7 AVR USART Example
8.7.1 Did You See Something Slightly Weird?
8.8 Interrupt Flags
8.9 Register Summary
8.9.1 USART Baud Rate Register
8.9.2 USART I/O Data Register
8.9.3 USART Control and Status Register A
8.9.4 USART Control and Status Register B
8.9.5 USART Control and Status Register C
8.10 Key Takeaways
8.11 Coming Up
9 Analog-to-Digital Converter Interrupt
9.1 The ADC
9.2 Setting Up Arduino Interrupts
9.3 Setting Up AVR Interrupts
9.4 Interrupt Flags
9.5 Register Summary
9.5.1 ADC Control and Status Register A
9.6 Key Takeaways
9.7 Coming Up
10 EEPROM Ready Interrupt
10.1 The ATmega328P EEPROM
10.1.1 Reading from the EEPROM
10.1.2 Writing to the EEPROM
10.2 A Quick Arduino EEPROM Sketch
10.3 Setting Up the EEPROM Interrupt
10.3.1 EEPROM Structures
10.3.2 Reading EEPROM Data
10.3.3 Writing EEPROM Data
10.3.4 Updating EEPROM Data
10.3.5 Initializing the EEPROM Interrupt Functions
10.3.6 The EE_READY Interrupt ISR
10.3.7 The Arduino Sketch
10.3.8 The AVR Application
10.4 Initializing EEPROM Data at Compile Time
10.4.1 Initializing the EEPROM Using Avrdude
10.4.2 Initializing the EEPROM Using PlatformIO
10.4.3 Initializing the EEPROM Using a Sketch
10.5 Interrupt Flag
10.6 Is It All Worth It?
10.7 Register Summary
10.8 Key Takeaways
10.9 Coming Up
11 Analog Comparator Interrupt
11.1 Let’s Compare Voltages
11.2 Analog Comparator Setup
11.3 Setting Up Arduino Interrupts
11.4 Setting Up AVR Interrupts
11.5 The Analog Comparator Interrupt Flag
11.6 Arduino Analog Comparator and Input Capture Unit
11.7 AVR Analog Comparator and Input Capture Unit
11.8 Register Summary
11.9 Key Takeaways
11.10 Coming Up
12 TWI Interrupt
12.1 TWI Also Known As I2C
12.2 Determining Device Addresses
12.3 Chapter Terminology
12.4 TWI Communications Steps
12.4.1 Transferring Data
12.4.2 Acknowledgments
12.4.3 Reading Data
12.4.4 Writing Data
12.4.5 Reading and Writing
12.4.6 Multicontrollersand Arbitration
12.5 A Read-Only Polled Example
12.6 Using the TWI Interrupt
12.6.1 The Arduino Wire Library
12.7 Read-Only Using the TWI Interrupt
12.8 PlatformIO TWI Code
12.9 Fully Extending the Interrupt Code
12.10 Register Summary
12.10.1 TWI Bit Rate Register
12.10.2 TWI Status Register
12.10.3 TWI Control Register
12.10.4 TWI Data Register
12.10.5 TWI Address Register
12.10.6 TWI Address Mask Register
12.11 Key Takeaways
12.12 Coming Up
13 A Real-World Example
13.1 The LDR
13.1.1 Voltage Dividers
13.2 The Arduino Sketch
13.3 AVR C++ Conversion
13.4 ATtiny85 Conversion
13.5 Coming Up
A Circular Buffers
B Sleep Modes
C Debouncing Switches
D AVRTWIlib
Index
About the Author
Norman Dunbar
is a retired Oracle database administrator who lives with his wife,
Alison, and a cockapoo dog, Wesley, to keep him out of trouble.
4 https://github.c om/arduino/arduino-cli
5 https://platformio.org/
9 http://fritzing.org
OceanofPDF.com
© The Author(s), under exclusive license to APress Media, LLC, part of Springer
Nature 2024
N. Dunbar, Arduino Interrupts, Maker Innovations Series
https://doi.org/10.1007/978-1-4842-9714-8_1
1. Arduino Interrupts
Norman Dunbar1
(1) Rawdon, West Yorkshire, UK
Abstract
This Arduino interrupts chapter will introduce you to the concept of
interrupts on the Arduino. More specifically, the interrupts are actually
part of the ATmega328P used on many Arduino boards such as the Uno.
Here you will learn all about how the ATmega328P processes
interrupts and returns to your code afterwards.
Note
If you are interested, the JMP instruction uses the highest 10 bits of
the lowest word in memory for the opcode; the next 6 bits of the
same word are used for the high-order 6 bits of the destination
address with the second word of the instruction being the low-order
16 bits of the address. The address is therefore 22 bits in size and
allows for up to words of address space to be addressed. As the
ATmega328P only has 32 KB (16 K words) of Flash RAM, 22 bits is
suitably large enough to cover the entire address space.
Note
If you are writing in Assembly Language, it is your responsibility to
set up the Interrupt Vector Table correctly. You only need to define
the RESET interrupt – so that the device knows where to start
executing at power-on or after a reset – and any further interrupts
that your application code uses. Unused space in the interrupt vector
table can be used for application code. This means that if you are not
using any interrupts, the application code can begin at address 0 and
will start executing there on a reset or after a power-on.
If you are using avr-gcc to compile your C++ code, then that will
set up the entire Interrupt Vector Table automatically. Unused
vectors will be filled with a dummy interrupt handler which handles
any spurious interrupts detected by the device. The dummy handler
simply assumes a really bad error was detected – after all, the
detected interrupt was not coded for – and forces the device to reset.
The code that handles the interrupt, the Interrupt Service Routine (ISR),
should then
Save the Status Register and any other registers that it intends to use
on the stack
Carry out the required processing to actually handle the interrupt
Restore the working registers and the Status Register from the stack
Exit by executing a RETI instruction, RETurn from Interrupt
The global interrupt flag is set again by the hardware when the
RETI is executed. The PC is restored from the stack, and execution
continues from that address – the instruction immediately after the one
that was interrupted.
When an ISR returns to the main program, at least one (machine
code) instruction will be fully executed before any pending, or further,
interrupts are processed in priority order. A pending interrupt is one
which occurred while the ISR was in progress.
It takes a further four clock cycles to return from an ISR after
processing.
Normally, while the ISR is executing, further interrupts are not
processed. The current interrupt is usually permitted to run to
completion. However, all interrupts available to the ATmega328P have a
flag bit to indicate that it has occurred – whether the global interrupt
flag is set or not. While this bit records the fact that a particular
interrupt has occurred, it does not record how many times it occurred.
This is a fact worth remembering, and I will explain why later.
Note
According to the data sheet for the ATmega328P, the interrupting
stimulus can be detected on a pin, for example, and, if so, will set the
interrupt’s flag as appropriate. Only if the flag is set, and the
interrupt itself has been enabled, and the global interrupts are also
enabled, then the ISR for that interrupt will be executed, interrupting
the main code. In this case, the flag bit will be automatically cleared.
Note
You may be puzzled by the statement that a 1 is to be written to the
bit? Surely that should be a 0? No, I’m afraid not, and I’m as equally
puzzled as you are! The ATmega328P hardware requires these, and
many other, flag bits to be cleared by the writing of a 1 to the
appropriate bit.
Level interrupts do not necessarily set the interrupt flag but simply
continue to trigger as long as the interrupt condition is present. If the
interrupt triggering event ceases before the interrupt is actually
triggered, then the interrupt will not be triggered. The stimulus which
triggers these level interrupts must ensure that the triggering event
remains in place for at least five clock cycles. On the Arduino Uno again,
five clock cycles is a massive 0.3125 microseconds, so that’s how long
the interrupting stimulus has to remain in force so that the
ATmega328P recognizes it.
The data sheet for the ATmega328P warns that
This is not something you need to worry about unless you are
coding in Assembly Language. The code generated by the C++ compiler
(avr-g++ and/or avr-gcc) generates the correct code.
Tip
Switch debouncing is an important topic and is discussed in some
detail in Appendix C, “Debouncing Switches.”
Tip
A fuse bit is considered to be programmed when it is zero, not one.
Bear this in mind.
Note
Don’t forget, Flash RAM is word addressed. Address 0 is bytes 0 and
1. Address 1 is bytes 2 and 3 and so on. The 2 added in the Vector
Table Address calculation is two words. A word is 16 bits in this case.
Two words, or four bytes, are required because an interrupt vector is
always 32 bits, two words or four bytes.
1.7 Coming Up
In the next chapter, we will begin our investigation of the actual
interrupts present on the ATmega328P, by looking at what happens
when the device is reset.
Footnotes
1 Of course, this depends on the fuse settings; it may be at the start of the bootloader
address space.
2 By the init() function, called at startup.
3 Available from Apress and all good bookshops around the world!
4 When an ISR is executed, the code executing will save certain registers on the
stack before executing any of the ISR’s useful code. On completion, it has to restore
all those registers. Code generated by the gcc compiler, used by the Arduino IDE, etc.,
preserves the SREG plus every one of the 32 general-purpose registers on entry to an
ISR and restores them all on exit. That’s a lot of work before the useful code in the
ISR can get started. This happens regardless of whether or not the registers are used
by the ISR code.
OceanofPDF.com
© The Author(s), under exclusive license to APress Media, LLC, part of Springer
Nature 2024
N. Dunbar, Arduino Interrupts, Maker Innovations Series
https://doi.org/10.1007/978-1-4842-9714-8_2
2. Reset Interrupt
Norman Dunbar1
(1) Rawdon, West Yorkshire, UK
In this chapter, we begin our dive into the specific interrupts available
on the ATmega328P by taking a look at the Reset interrupt. This is the
interrupt which triggers when the board is powered on or reset in some
manner, so it’s a good place to start our investigations. You will learn
here how to determine why the board was reset but also how the
bootloader installed on your board might just hide those details from
you.
Author: H. P. Lovecraft
Language: English
By H. P. LOVECRAFT
In the next few weeks I heard of very little but Asenath from young
Derby. Others now remarked Edward's autumnal gallantry, though
they agreed that he did not look even nearly his actual age, or seem
at all inappropriate as an escort for his bizarre divinity. He was only a
trifle paunchy despite his indolence and self-indulgence, and his face
was absolutely without lines. Asenath, on the other hand, had the
premature crow's-feet which come from the exercise of an intense
will.
About this time Edward brought the girl to call on me, and I at once
saw that his interest was by no means one-sided. She eyed him
continually with an almost predatory air, and I perceived that their
intimacy was beyond untangling. Soon afterward I had a visit from
old Mr. Derby, whom I had always admired and respected. He had
heard the tales of his son's new friendship and had wormed the
whole truth out of "the boy". Edward meant to marry Asenath, and
had even been looking at houses in the suburbs. Knowing my
usually great influence with his son, the father wondered if I could
help to break the ill-advised affair off; but I regretfully expressed my
doubts. This time it was not a question of Edward's weak will but of
the woman's strong will. The perennial child had transferred his
dependence from the parental image to a new and stronger image,
and nothing could be done about it.
The wedding was performed a month later by a justice of the peace
according to the bride's request. Mr. Derby, at my advice, offered no
opposition, and he, my wife, my son and I attended the brief
ceremony—the other guests being wild young people from the
college. Asenath had bought the old Crowninshield place in the
country at the end of High Street, and they proposed to settle there
after a short trip to Innsmouth, whence three servants and some
books and household goods were to be brought. It was probably not
so much consideration for Edward and his father as a personal wish
to be near the college, its library, and its crowd of "sophisticates",
that made Asenath settle in Arkham instead of returning permanently
home.
When Edward called on me after the honeymoon I thought he looked
slightly changed. Asenath had made him get rid of the undeveloped
mustache, but there was more than that. He looked soberer and
more thoughtful, his habitual pout of childish rebelliousness being
exchanged for a look almost of genuine sadness. I was puzzled to
decide whether I liked or disliked the change. Certainly he seemed
for the moment more normally adult than ever before. Perhaps the
marriage was a good thing—might not the change of dependence
form a start toward actual neutralization, leading ultimately to
responsible independence? He came alone, for Asenath was very
busy. She had brought a vast store of books and apparatus from
Innsmouth (Derby shuddered as he spoke the name), and was
finishing the restoration of the Crowninshield house and grounds.
Her home in—that town—was a rather disgusting place, but certain
objects in it had taught him some surprizing things. He was
progressing fast in esoteric lore now that he had Asenath's
guidance. Some of the experiments she proposed were very daring
and radical—he did not feel at liberty to describe them—but he had
confidence in her powers and intentions. The three servants were
very queer—an incredibly aged couple who had been with old
Ephraim and referred occasionally to him and to Asenath's dead
mother in a cryptic way, and a swarthy young wench who had
marked anomalies of feature and seemed to exude a perpetual odor
of fish.
3
For the next two years I saw less and less of Derby. A fortnight
would sometimes slip by without the familiar three-and-two strokes at
the front door; and when he did call—or when, as happened with
increasing infrequency, I called on him—he was very little disposed
to converse on vital topics. He had become secretive about those
occult studies which he used to describe and discuss so minutely,
and preferred not to talk of his wife. She had aged tremendously
since her marriage, till now—oddly enough—she seemed the elder
of the two. Her face held the most concentratedly determined
expression I had ever seen, and her whole aspect seemed to gain a
vague, unplaceable repulsiveness. My wife and son noticed it as
much as I, and we all ceased gradually to call on her—for which,
Edward admitted in one of his boyishly tactless moments, she was
unmitigatedly grateful. Occasionally the Derbys would go on long
trips—ostensibly to Europe, though Edward sometimes hinted at
obscurer destinations.
It was after the first year that people began talking about the change
in Edward Derby. It was very casual talk, for the change was purely
psychological; but it brought up some interesting points. Now and
then, it seemed, Edward was observed to wear an expression and to
do things wholly incompatible with his usual flabby nature. For
example—although in the old days he could not drive a car, he was
now seen occasionally to dash into or out of the old Crowninshield
driveway with Asenath's powerful Packard, handling it like a master,
and meeting traffic entanglements with a skill and determination
utterly alien to his accustomed nature. In such cases he seemed
always to be just back from some trip or just starting on one—what
sort of trip, no one could guess, although he mostly favored the
Innsmouth road.
Oddly, the metamorphosis did not seem altogether pleasing. People
said he looked too much like his wife, or like old Ephraim Waite
himself, in these moments—or perhaps these moments seemed
unnatural because they were so rare. Sometimes, hours after
starting out in this way, he would return listlessly sprawled on the
rear seat of the car while an obviously hired chauffeur or mechanic
drove. Also, his preponderant aspect on the streets or during his
decreasing round of social contacts (including, I may say, his calls on
me) was the old-time indecisive one—its irresponsible childishness
even more marked than in the past. While Asenath's face aged,
Edward's—aside from those exceptional occasions—actually relaxed
into a kind of exaggerated immaturity, save when a trace of the new
sadness or understanding would flash across it. It was really very
puzzling. Meanwhile the Derbys almost dropped out of the gay
college circle—not through their own disgust, we heard, but because
something about their present studies shocked even the most
callous of the other decadents.
It was in the third year of the marriage that Edward began to hint
openly to me of a certain fear and dissatisfaction. He would let fall
remarks about things "going too far", and would talk darkly about the
need of "gaining his identity". At first I ignored such references, but in
time I began to question him guardedly, remembering what my
friend's daughter had said about Asenath's hypnotic influence over
the other girls at school—the cases where students had thought they
were in her body looking across the room at themselves. This
questioning seemed to make him at once alarmed and grateful, and
once he mumbled something about having a serious talk with me
later.
About this time old Mr. Derby died, for which I was afterward very
thankful. Edward was badly upset, though by no means
disorganized. He had seen astonishingly little of his parent since his
marriage, for Asenath had concentrated in herself all his vital sense
of family linkage. Some called him callous in his loss—especially
since those jaunty and confident moods with the car began to
increase. He now wished to move back into the old family mansion,
but Asenath insisted on staying in the Crowninshield house, to which
she had become well adjusted.
Not long afterward my wife heard a curious thing from a friend—one
of the few who had not dropped the Derbys. She had been out to the
end of High Street to call on the couple, and had seen a car shoot
briskly out of the drive with Edward's oddly confident and almost
sneering face above the wheel. Ringing the bell, she had been told
by the repulsive wench that Asenath was also out; but had chanced
to look up at the house in leaving. There, at one of Edward's library
windows, she had glimpsed a hastily withdrawn face—a face whose
expression of pain, defeat, and wistful hopelessness was poignant
beyond description. It was—incredibly enough in view of its usual
domineering cast—Asenath's; yet the caller had vowed that in that
instant the sad, muddled eyes of poor Edward were gazing out from
it.
Edward's calls now grew a trifle more frequent, and his hints
occasionally became concrete. What he said was not to be believed,
even in centuried and legend-haunted Arkham; but he threw out his
dark lore with a sincerity and convincingness which made one fear
for his sanity. He talked about terrible meetings in lonely places, of
cyclopean ruins in the heart of the Maine woods beneath which vast
staircases led down to abysses of nighted secrets, of complex
angles that led through invisible walls to other regions of space and
time, and of hideous exchanges of personality that permitted
explorations in remote and forbidden places, on other worlds, and in
different space-time continua.
He would now and then back up certain crazy hints by exhibiting
objects which utterly nonplussed me—elusively colored and
bafflingly textured objects like nothing ever heard of on earth, whose
insane curves and surfaces answered no conceivable purpose and
followed no conceivable geometry. These things, he said, came
"from outside"; and his wife knew how to get them. Sometimes—but
always in frightened and ambiguous whispers—he would suggest
things about old Ephraim Waite, whom he had seen occasionally at
the college library in the old days. These adumbrations were never
specific, but seemed to revolve around some especially horrible
doubt as to whether the old wizard were really dead—in a spiritual as
well as corporeal sense.
At times Derby would halt abruptly in his revelations, and I wondered
whether Asenath could possibly have divined his speech at a
distance and cut him off through some unknown sort of telepathic
mesmerism—some power of the kind she had displayed at school.
Certainly, she suspected that he told me things, for as the weeks
passed she tried to stop his visits with words and glances of a most
inexplicable potency. Only with difficulty could he get to see me, for
although he would pretend to be going somewhere else, some
invisible force would generally clog his motions or make him forget
his destination for the time being. His visits usually came when
Asenath was away—"away in her own body," as he once oddly put it.
She always found out later—the servants watched his goings and
comings—but evidently she thought it inexpedient to do anything
drastic.
4
Derby had been married more than three years on that August day
when I got that telegram from Maine. I had not seen him for two
months, but had heard he was away "on business". Asenath was
supposed to be with him, though watchful gossip declared there was
someone upstairs in the house behind the doubly curtained
windows. They had watched the purchases made by the servants.
And now the town marshal of Chesuncook had wired of the draggled
madman who stumbled out of the woods with delirious ravings and
screamed to me for protection. It was Edward—and he had been just
able to recall his own name and address.
Chesuncook is close to the wildest, deepest, and least explored
forest belt in Maine, and it took a whole day of feverish jolting
through fantastic and forbidding scenery to get there in a car. I found
Derby in a cell at the town farm, vacillating between frenzy and
apathy. He knew me at once, and began pouring out a meaningless,
half-incoherent torrent of words in my direction.
"Dan—for God's sake! The pit of the shoggoths! Down the six
thousand steps ... the abomination of abominations.... I never would
let her take me, and then I found myself there—Iä! Shub-Niggurath!
—The shape rose up from the altar, and there were five hundred that
howled—the Hooded Thing bleated 'Kamog! Kamog!'—that was old
Ephraim's secret name in the coven—I was there, where she
promised she wouldn't take me—A minute before I was locked in the
library, and then I was there where she had gone with my body—in
the place of utter blasphemy, the unholy pit where the black realm
begins and the watcher guards the gate—I saw a shoggoth—it
changed shape—I can't stand it—I'll kill her if she ever sends me
there again—I'll kill that entity—her, him, it—I'll kill it! I'll kill it with my
own hands!"
"The pit of the shoggoths! Down the six thousand steps ... the
abomination of abominations."
It took me an hour to quiet him, but he subsided at last. The next day
I got him decent clothes in the village, and set out with him for
Arkham. His fury of hysteria was spent, and he was inclined to be
silent, though he began muttering darkly to himself when the car
passed through Augusta—as if the sight of a city aroused unpleasant
memories. It was clear that he did not wish to go home; and
considering the fantastic delusions he seemed to have about his wife
—delusions undoubtedly springing from some actual hypnotic ordeal
to which he had been subjected—I thought it would be better if he
did not. I would, I resolved, put him up myself for a time, no matter
what unpleasantness it would make with Asenath. Later I would help
him get a divorce, for most assuredly there were mental factors
which made this marriage suicidal for him. When we struck open
country again Derby's muttering faded away, and I let him nod and
drowse on the seat beside me as I drove.
During our sunset dash through Portland the muttering commenced
again, more distinctly than before, and as I listened I caught a
stream of utterly insane drivel about Asenath. The extent to which
she had preyed on Edward's nerves was plain, for he had woven a
whole set of hallucinations around her. His present predicament, he
mumbled furtively, was only one of a long series. She was getting
hold of him, and he knew that some day she would never let go.
Even now she probably let him go only when she had to, because
she couldn't hold on long at a time. She constantly took his body and
went to nameless places for nameless rites, leaving him in her body
and locking him upstairs—but sometimes she couldn't hold on, and
he would find himself suddenly in his own body again in some far-off,
horrible and perhaps unknown place. Sometimes she'd get hold of
him again and sometimes she couldn't. Often he was left stranded
somewhere as I had found him; time and again he had to find his
way home from frightful distances, getting somebody to drive the car
after he found it.
The worst thing was that she was holding on to him longer and
longer at a time. She wanted to be a man—to be fully human—that
was why she got hold of him. She had sensed the mixture of fine-
wrought brain and weak will in him. Some day she would crowd him
out and disappear with his body—disappear to become a great
magician like her father and leave him marooned in that female shell
that wasn't even quite human. Yes, he knew about the Innsmouth
blood now. There had been traffic with things from the sea—it was
horrible.... And old Ephraim—he had known the secret, and when he
grew old did a hideous thing to keep alive—he wanted to live for ever
—Asenath would succeed—one successful demonstration had taken
place already.
As Derby muttered on I turned to look at him closely, verifying the
impression of change which an earlier scrutiny had given me.
Paradoxically, he seemed in better shape than usual—harder, more
normally developed, and without the trace of sickly flabbiness
caused by his indolent habits. It was as if he had been really active
and properly exercised for the first time in his coddled life, and I
judged that Asenath's force must have pushed him into unwonted
channels of motion and alertness. But just now his mind was in a
pitiable state; for he was mumbling wild extravagances about his
wife, about black magic, about old Ephraim, and about some
revelation which would convince even me. He repeated names
which I recognized from bygone browsings in forbidden volumes,
and at times made me shudder with a certain thread of mythological
consistency—of convincing coherence—which ran through his
maundering. Again and again he would pause, as if to gather
courage for some final and terrible disclosure.
"Dan, Dan, don't you remember him—the wild eyes and the unkempt
beard that never turned white? He glared at me once, and I never
forgot it. Now she glares that way. And I know why! He found it in the
Necronomicon—the formula. I don't dare tell you the page yet, but
when I do you can read and understand. Then you will know what
has engulfed me. On, on, on, on—body to body to body—he means
never to die. The life-glow—he knows how to break the link ... it can
flicker on a while even when the body is dead. I'll give you hints and
maybe you'll guess. Listen, Dan—do you know why my wife always
takes such pains with that silly back-hand writing? Have you ever
seen a manuscript of old Ephraim's? Do you want to know why I
shivered when I saw some hasty notes Asenath had jotted down?
"Asenath—is there such a person? Why did they half think there was
poison in old Ephraim's stomach? Why do the Gilmans whisper
about the way he shrieked—like a frightened child—when he went
mad and Asenath locked him up in the padded attic room where—
the other—had been? Was it old Ephraim's soul that was locked in?
Who locked in whom? Why had he been looking for months for
someone with a fine mind and a weak will? Why did he curse that his
daughter wasn't a son? Tell me, Daniel Upton—what devilish