Intermediate C Programming For The Pic Microcontroller Simplifying Embedded Programming 1st Ed Hubert Henry Ward Instant Download
Intermediate C Programming For The Pic Microcontroller Simplifying Embedded Programming 1st Ed Hubert Henry Ward Instant Download
https://ebookbell.com/product/intermediate-c-programming-for-the-
pic-microcontroller-simplifying-embedded-programming-1st-ed-
hubert-henry-ward-22417478
https://ebookbell.com/product/python-programming-illustrated-for-
beginners-intermediates-learn-by-doing-approachstep-by-step-ultimate-
guide-to-mastering-python-the-future-is-here-sullivan-22122814
https://ebookbell.com/product/the-ultimate-python-programming-guide-
for-beginner-to-intermediate-william-alvin-newton-48906050
https://ebookbell.com/product/python-programming-python-programming-
for-beginners-python-programming-for-intermediates-adam-
stewart-5726612
https://ebookbell.com/product/python-programming-for-beginners-basic-
language-from-absolute-beginners-to-intermediate-learn-easily-and-
fast-data-science-and-web-development-in-a-simple-and-practical-way-
stepbystep-mark-coding-11157304
An Intermediate Guide To Spss Programming Using Syntax For Data
Management 1st Edition Boslaugh
https://ebookbell.com/product/an-intermediate-guide-to-spss-
programming-using-syntax-for-data-management-1st-edition-
boslaugh-54492926
https://ebookbell.com/product/intermediate-c-programming-2nd-edition-
yunghsiang-lu-george-k-kuriakose-thiruvathukal-57676222
https://ebookbell.com/product/intermediate-c-programming-2nd-edition-
yunghsiang-lu-george-k-thiruvathukal-57793356
https://ebookbell.com/product/intermediate-c-programming-second-
edition-2nd-edition-yunghsiang-lu-george-k-thiruvathukal-58159524
https://ebookbell.com/product/intermediate-c-programming-yunghsiang-
lu-10984206
TECHNOLOGY IN AC TION™
Intermediate
C Programming
for the PIC
Microcontroller
Simplifying Embedded
Programming
—
Hubert Henry Ward
Intermediate
C Programming
for the PIC
Microcontroller
Simplifying Embedded
Programming
iii
Table of Contents
iv
Table of Contents
v
Table of Contents
Chapter 6: Interrupts������������������������������������������������������������������������225
What Are Interrupts?�����������������������������������������������������������������������������������������225
The Fetch and Execute Cycle����������������������������������������������������������������������������226
The Program Counter����������������������������������������������������������������������������������������226
The Sources of Interrupts���������������������������������������������������������������������������������230
The Process for a Simple Interrupt with No Priorities���������������������������������231
Setting Up the PIC to Respond to the Interrupts������������������������������������������232
The PIE1 Register����������������������������������������������������������������������������������������237
The Algorithm for the Interrupt Test Program����������������������������������������������239
Compiler Software Version Issue�����������������������������������������������������������������240
The Analysis of Listing 6-1��������������������������������������������������������������������������243
Using the Compare Function of the CCP Module����������������������������������������������251
The Algorithm for the Compare Function�����������������������������������������������������253
The Analysis Of Listing 6-2��������������������������������������������������������������������������256
Using Priority Enabled Interrupts����������������������������������������������������������������������260
The Algorithm for the High/Low Priority Program����������������������������������������260
Analysis of Listing 6-3���������������������������������������������������������������������������������265
Explanation of How the High/Low Priority Program Works��������������������������270
Summary����������������������������������������������������������������������������������������������������������272
vi
Table of Contents
Appendix 3: Keywords����������������������������������������������������������������������321
Appendix 7:���������������������������������������������������������������������������������������337
Index�������������������������������������������������������������������������������������������������345
vii
About the Author
Hubert Henry Ward has nearly 25 years of experience as a college lecturer
delivering the BTEC, and now Pearson's, Higher National Certificate and
Higher Diploma in Electrical and Electronic Engineering. Hubert has a
2.1 Honours Bachelor's Degree in Electrical and Electronic Engineering.
Hubert has also worked as a consultant in embedded programming. His
work has established his expertise in the assembler and C programming
languages, within the MPLABX IDE from Microchip, as well as designing
electronic circuits and PCBs using ECAD software. Hubert was also the UK
technical expert in Mechatronics for three years, training the UK team and
taking them to the Skills Olympics in Seoul 2001, resulting in one of the
best outcomes to date for the UK in Mechatronics.
ix
About the Technical Reviewer
Sai Yamanoor is an embedded systems engineer working for an industrial
gases company in Buffalo, NY. His interests, deeply rooted in DIY and
open source hardware, include developing gadgets that aid behavior
modification. He has published two books with his brother, and in his
spare time, he likes to build things that improve quality of life. You can find
his project portfolio at http://saiyamanoor.com.
xi
Introduction
This book looks at some useful aspects of the PIC microcontroller. It
explains how to write programs in C so that you can use the PIC micro to
control a variety of electronics and DC motors. After reading this book, you
will be well on your way to becoming an embedded programmer using the
C programming language.
• Using interrupts
xiii
Introduction
The Prerequisites
There are none really, but understanding the C programming language
will be useful. However, I will explain how each program works as we go
through them.
Also, if you understand the binary and hexadecimal number systems,
it will be an advantage but there is a section in the Appendix that will help
you with that.
However, to get the full use out of this book, you will need to install the
following software:
All of these programs are freely available from the Microchip web site.
xiv
Introduction
xv
Introduction
Before we move into the book for real, I think it will be useful to you if
I explained a bit about what MPLABX is. It is an industrial IDE created by
Microchip. The term IDE stands for integrated development environment.
It is actually a lot of programs collected together to create a programming
environment:
So this IDE is a very large collection of programs that make our job of
writing code much more efficient. Yet it’s free; well, I use the free version,
which is not as efficient as the paid version but it is more than good
enough for us.
I therefore hope that you not only learn how to program the PIC micro
but you also enjoy going through my book and that you produce some
useful projects along the way.
xvi
CHAPTER 1
If this is all true, you should create a header file for the LCD.
These are the three header files you will create in this book. There are
many more examples of when you should create a header file. The process
of creating and using header files makes your program writing more
efficient.
Header files can be made available for all of your projects, like global
header files as opposed to local header files. Local header files are
available only to the project they were created in.
Also, you can split projects up so that different programmers can write
different sections of the programs and save them as header files to be used
in all projects by all of the company’s programmers.
2
Chapter 1 Creating a Header File
The project window on the left-hand side may not be shown. If you
want it shown, you should select the word Window from the top menu
bar. Click the word Projects, with the orange boxes in front of it, and the
window should appear. You may have to move the window about to get it
in the position shown.
Now, assuming you are ready to create a project, you should either
click the word File, in the main menu bar, and select New project, or click
the orange box with the small green cross on the second menu bar. This is
the second symbol from the left-hand side of the second menu bar.
When you have selected the Create project option, you should see the
window shown in Figure 1-2.
3
Chapter 1 Creating a Header File
Most of the projects you will create are Microchip Embedded and
Standalone. Therefore, make sure these two options are highlighted and
then click the Next button. The Select Device window should now be
visible, as shown in Figure 1-3.
4
Chapter 1 Creating a Header File
In this window, you can choose which PIC you want to use. Select the
Advanced 8-bit MCUs (PIC18) in the small box alongside Family, as shown
in Figure 1-3. Then, in the Device window, select the PIC18F4525. The result
is shown in Figure 1-3. To make these options visible, you need to click the
small downward pointing arrow in the respective box. The different options
should then become visible. If the device window is highlighted in blue, you
could simply type in the PIC number you want, such as PIC18F4525. Your
selected device should appear in the window below.
If you are using a different PIC, select it here.
Once you are happy with your selection, click the Next button.
The next window to appear is the Select Tool window. This is shown
in Figure 1-4. With this window you can select the programming tool you
want to use to download the program to your prototype board. There are a
range of tools you can use. I mainly use the ICD3 CAN or the PICkit3 tool.
5
Chapter 1 Creating a Header File
Having selected the tool you want, click Next to move on to the next
window where you can select the compiler software you want to use,
assuming you have downloaded the appropriate compiler software (see
Figure 1-5).
6
Chapter 1 Creating a Header File
7
Chapter 1 Creating a Header File
In this window, you will specify the name of the project and where you
want to save it. The software will create a new directory on your computer
with the project name you create here. It is recommended that you don’t
use long-winded, complicated path names for the new folder so I normally
save all my projects on the root directory of my laptop.
I have suggested a project name for this new project as
advanceProject1. Note that I am using camelcase, where two words,
or more, are combined together. The first letter of the first word is in
lowercase and the first letters of any subsequent words are in uppercase. In
this way multiple words can be combined together to make one long word.
As you type the name for your project, you should see that the folder is
created on the root drive, or wherever you have specified it should be. The
folder name will have a .X added to it.
It will be in this new folder that all the files associated with the project
will be saved as well as some important subdirectories that are created.
8
Chapter 1 Creating a Header File
Once you are happy with the naming of the project, simply click the
Finish button and the project will be created. The window will now go back
to the main window, as shown in Figure 1-7.
You should see the project window at the left-hand side of your screen,
as shown in Figure 1-7. Note that you may need to move the window about
to get it the same as that shown in Figure 1-7.
Now that you have the new project created, you need to create a
header file that you will use in all of your projects in this book.
To create the header file, right-click the subdirectory in the project tree
named Header Files. When you do this, the flyout menu will appear, as
shown in Figure 1-8.
9
Chapter 1 Creating a Header File
Figure 1-8. The flyout menu for the new header file
From that flyout menu, select New. From the second flyout menu,
select xc8_header.h, as shown in Figure 1-8.
The window shown in Figure 1-9 will appear.
10
Chapter 1 Creating a Header File
Figure 1-9. The name and location for the new header file
All you need to do here is give the file a name. I have chosen the name
conFigInternalOscNoWDTNoLVP as it gives a good description of what I
want to do in this header file, which is set these three main parameters of
the configuration words. Note the configuration words specify how you
want to configure and so use the PIC.
The main concern is that PICs have a wide variety of primary oscillator
sources and you need to tell the PIC which one you will be using. The
oscillator is the device or circuit that provides a signal from which the
clock signal, the signal that synchronizes the operations of the PIC,
is derived. I prefer to use the internal oscillator block as the primary
oscillator source. This saves buying an oscillator crystal. It also saves two
inputs that would be used if I used an external oscillator. This is because I
would connect the external oscillator to the PIC via those two input pins,
normally RA6 and RA7.
11
Chapter 1 Creating a Header File
The second major item I change is to turn off the WDT, which is the
watch dog timer. This is a timer that will stop the micro if nothing has
happened for a set period of time. This is a facility that you don’t want in
these programs, so you must turn it off. Note that the WDT is mainly used
in continuous production lines. In that situation, the fact that nothing has
happened for a set time usually means something has gone wrong so it’s
best to turn everything off.
The third item to turn off is the low voltage programming (LVP)
function. The low voltage programming affects some of the bits on
PORTB. Therefore, to keep the bits on PORTB available for general I/O, I
normally turn off the LVP.
So this explains the header file’s cryptic name. You should always give
your header files a name that relates to how you want to use the file.
Once you have named the header file, click Finish and the newly
created header file will be inserted into the main editing window in
the software. However, Microchip automatically inserts an awful lot of
comments and instructions that, at your level of programming, you don’t
really need. Therefore, simply select all that stuff and delete it so that you
have an empty file ready for you to insert the code that you really want.
Now that you have a clean file, you can control what goes into it. The
first thing you should do is put some comments in along the following
lines:
• You should say what PIC you wrote it for and when you
wrote it.
12
Chapter 1 Creating a Header File
You should insert your own comments into the editor similar to those
shown in Figure 1-10.
You will notice that I changed the colour of my comments to black and
bold size 14. This is to try and make them more visible than the default
grey.
If you want to change the colour, you can do so by selecting the word
Options from the drop-down menu that appears when you select the
Tools choice on the main menu bar. You will get the window shown in
Figure 1-11.
13
Chapter 1 Creating a Header File
Click the tag for Fonts and Colours and then select what you want to
change. Once you are happy with your choice, click OK. I changed the
colour of the comments to black, as shown in Figure 1-11.
Now you need to create the configuration words for your header file.
As this is something you must do for all your projects, Microchip has
developed a simple process for writing to the configuration words. This
can be achieved using a special window in the MPLABX IDE. To open this
window, click the word Window on the main menu bar and then select
Target Memory Views from the drop-down menu that appears. Then select
Configuration Bits from the slide-out menu that appears. This process is
shown in Figure 1-12.
14
Chapter 1 Creating a Header File
Once you have selected the configuration bits, your main window will
change to that shown in Figure 1-13.
15
Chapter 1 Creating a Header File
Once you have changed these settings, you can generate the source
code and then paste this code into your program. To do so, click the
16
Chapter 1 Creating a Header File
Generate Source Code to Output tab shown at the bottom of the IDE. The
source code should appear in the output window on the screen, as shown
in Figure 1-14.
Use the mouse to select this code and the comments but do not select
the phrase #include <xc.h> because I want to discuss the importance
of this include file later in the book. So, once you have copied just the
configuration words and not the #include <xc.h>, paste the selection into
the header file you have in the open window.
I pasted these source instructions and comments into my open file
window starting at line 5 and ending at line 62. Yours may differ due to
what comments you have put in.
Your screen should look like that shown in Figure 1-15. Note that the
#include <xc.h> is not in the file.
17
Chapter 1 Creating a Header File
Figure 1-15. The configuration words inserted into the header file
You can now save this file in the usual way of saving a file because
you have all you need for this header file. This is done by clicking the File
option from the main menu bar and selecting Save from the flyout menu.
18
Chapter 1 Creating a Header File
Once you have selected the new main.c option, a new window will
open, which is where you will create the name for the source file. You
should name it sevenSegmentDisplay. The extension for the file name is c
for the C language. The window should look like the one in Figure 1-17.
19
Chapter 1 Creating a Header File
Once you are happy with the file name, click Finish and the screen
will now have a new window open in the editing screen. This will include
a lot of text that Microchip automatically inserts. Again, you don’t need it
so delete all this text so that you have a clean editing window, as shown in
Figure 1-18.
20
Chapter 1 Creating a Header File
The next thing you should do is add some comments to show that
you own this source file. Therefore, using the multiple line option for your
comments, you should insert some comments along the following lines:
You can amend the comments as you feel fit. The screen should now
look similar to that shown in Figure 1-19.
21
Chapter 1 Creating a Header File
Now you need to tell the compiler to include the header file you just
created. There are two ways you can add the header file. One is as a local
header file, which is not much good really. If you have created a local
header file, it will only be available to this local project. However, I will
show you how to include the header file in this way first.
Make sure the cursor is waiting at the start of the next empty line in the
source file you just created. Now start to write the phrase #include. You do
need the # sign. Indeed, as you write the # sign, a pop-up menu will appear
with some options for you to choose from. This is the IntelliSense part of the
compiler software. It is like predictive text on your phone. The software tries to
guess what you are doing, and the # sign has a specific meaning. You should
see the word “include” at the bottom of the pop-up menu. You can either
continue to write include or select the word from the pop-up menu. However,
if the pop-up menu does not appear, simply write the word “include.”
No matter which way you insert the word include, when you next press
the space bar, after inserting the word include, to move the cursor away
from the word include, you should see another pop-up menu appear, as
shown in Figure 1-20.
You should see the name of the header file you just created in the pop-up
menu. Select this file by clicking it to paste the file name into your source file.
Again, if the pop-up menu does not appear, you can write "conFigInternal
OscNoWDTNoLVP.h". Note that you must use the quotation marks. This is the
name of the header file you want to include in your program.
22
Chapter 1 Creating a Header File
C:\ProgramFiles(x86)\Microchip\xc8\v2.10\pic\include
You will have to find your directory. However, assuming you used
the default installation, then the path should be the same as mine stated
here. In earlier versions, it may be slightly different. You are looking for the
include directory in your compiler software. You may need to use the file
explorer to find the header file in the current project directory and copy
the file to the include directory as stated above.
Assuming you have been able to copy this header file into the correct
directory, this header file is now a global file and you can include it in any
of your projects. It’s a much better way to use the header file.
To include this global header file, delete the previous include line
of your program. Now insert the # and include statements as before but
23
Chapter 1 Creating a Header File
now when you hit the space bar to move the cursor away from the include
word, ignore the pop-up menu and type in the following symbol: <. The
IntelliSense will take over and insert the > symbol with the cursor flashing
inside the two symbols. Also, a pop-up menu will appear listing all of the
include files that are stored in the include directory of the xc8 compiler
software. If you now type the letter c in the space between the two < >
symbols, the fly-out menu will filter out all the files that don’t start with
the letter c. You should see the header file you have just copied into the
include directory, as shown in Figure 1-22.
If you click the header file you just copied, that file name should
appear between the < > symbols, as shown in Figure 1-23.
If you have difficulty getting the pop-up menus to appear or work, you
can simply write the complete instruction as stated here:
24
Chapter 1 Creating a Header File
#include <conFigInternaOscNoWDTNoLVP.h>
You do need the < > symbols. This approach can be used to include
any global header file: simply write the name of the header file you want to
include between the < > symbols.
Now you need to think about the very important header file that must
be included in all of your projects. The header file you need is the xc.h
file. To include it into your source file, you need to put the cursor onto the
next line in the file (i.e. line 5) by pressing the Enter key on your keyboard.
Now write the #include and press the space bar as before. Then, ignoring
the pop-up window, type the first < and then the type x between the two
symbols < > as before. The available header files will reduce to those
shown in Figure 1-24.
Again you should see the name of the header file you are looking for in
the pop-up window. Click the xc.h file to add it to the source file. The file
should now look like that shown in Figure 1-25.
25
Chapter 1 Creating a Header File
Assuming you want all these exact same settings for all of your projects,
you can create a header file for this setup. If you want something slightly
different, you must write to the SFR (special function register) after this file
has been used.
To create the header file, right-click the header files subdirectory in
the project tree. Then select New from the flyout menu and XC8_header.h
from the second flyout menu. Name the header file as PICSetUp and click
Finish to create the header file.
26
Chapter 1 Creating a Header File
This new file should be open in the editing window. Again, you should
delete all the stuff that MPLABX automatically inserts in the file since you
don’t need it and I really want your screens to look the same as mine.
Assuming that you now have an empty screen, you can write the
instructions for this header file. They are shown here as Listing 1-1. You
do not have to write the line numbers as shown here. These numbers are
there to enable me to refer to each instruction in my analysis of how the
instructions work.
1. void initialise ()
2. {
3. PORTA = 0;
4. PORTB = 0;
5. PORTC = 0;
6. PORTD = 0;
7. PORTE = 0;
8. TRISA = 0XFF;
9. TRISB = 0;
10. TRISC = 0;
11. TRISD = 0b11111111;
12. TRISE = 0;
13. ADCON0 = 0;
14. ADCON1 = 0b00001111;
15. OSCTUNE = 0;
16. OSCCON = 0b01110100;
17. T0CON = 0b11000111;
18. }
27
Chapter 1 Creating a Header File
A
nalysis of Listing 1-1
line 1 void initialise ()
To understand this instruction, you should appreciate that all C
programs run in a series of loops. There must be a main loop because this
is where the micro must go to get the first instruction of the program.
There are then a series of what are sometimes referred to as functions
or methods, but I prefer to call them subroutines, as they are small sections
of programs that the main loop can call as many times as the main program
needs to execute the instructions in the subroutine.
With this header file you are creating a subroutine. The subroutine
will only be called once from the main program and it will set up the SFRs
(special function registers) in the way you want to use them in the PIC.
All subroutines may or may not require the main program to pass
parameters up to the subroutine. Also, the subroutine may or may not pass
parameters back to the main program loop. All subroutines need a name
that describes the purpose of the subroutine.
In this case, this subroutine will not be passing any parameters back
to the main loop. This is signified by the use of the keyword void. Note as
you type this keyword void into the text window inside the IDE, you will
see it is case-sensitive and it must be in lowercase. As you finish writing
the word, the font colour changes to blue. IntelliSense uses colours to
recognize the significance of special words.
You must give the subroutine a name and in this case it is called
initialise, as it does initialize the PIC. Then, as you enter the first normal
opening bracket, IntelliSense automatically adds the normal closing bracket
and inserts the cursor between the two brackets. Here you can define what
type of variable the subroutine is expecting to be passed up to it when it is
called from the main program. If the subroutine does not want a variable
to be passed up to it, leave this space empty, as I have done here. Some
programmers insert the word “void” here but its just personal preference.
Line 2 {
28
Chapter 1 Creating a Header File
Line 3 PORTA = 0;
To fully appreciate this instruction, you should know that every PIC has
ports, which get their name from naval ports that take goods into and out
of the country. In the same way, the ports of the PIC take data into and out
of the PIC. Inputs can be simple switches, sensors, or transducers, whereas
outputs can be lamps, motors, or pumps.
What you are doing in the next five lines is making sure that anything
that might be connected to the ports of the PIC is not switched on. Note a
logic 0 means that the bits have 0v on them. The instruction PORTA = 0;
means all 8 bits on PORTA are at logic 0 or 0V.
One more thing before I describe the next instruction is the semicolon
symbol. It actually denotes the end of the current instruction. However,
with lines 1 and 2 there is no need for the semicolon because they are
statements for the compiler software, not instructions for the PIC.
Lines 4 to 7 simply turn off anything that might be connected to the
other ports of the PIC.
To understand this instruction, you must realize that with any port
data can go into the PIC or out of the PIC. Indeed, with any bit of the port
this can happen. With the PC18F4525 all ports have 8 bits, as this is an 8-bit
PIC, except for PORTE, which has 3 bits. Note that the bits are numbered
29
Chapter 1 Creating a Header File
b7, b6, b5, b4, b3, b2, b1, and b0, going from left to right. Bit0 is the LSB
(least significant bit) and bit7 is the MSB (most significant bit).
Well, you have to tell the PIC which way the data is to flow through the
bits of each port, in or out. To facilitate this, each port has another SFR to
set the direction of data through the bits of the port. This SFR is called a
TRIS, so TRISA, TRISB, etc.
Each bit of the TRIS maps directly onto the same numbered bit of the
port. If the bit in the TRIS is a logic 1, then the corresponding bit in the port
will be an input. If the bit in the TRIS is a logic 0, then the corresponding
bit in the port will be an output.
For example, if the data in TRISA is 00110101 then the bits in PORTA is
• B7 is an output.
• B6 is an output.
• B5 is an input.
• B4 is an input.
• B3 is an output.
• B2 is an input.
• B1 is an output.
• B0 is an input.
30
Chapter 1 Creating a Header File
Line 9 TRISB = 0;
Here, as you have not stated what radix, or number system, you are
using, the compiler assumes it is the default radix, which is decimal. This
means that this instruction is loading the TRISB with the value 0, which is
00000000 in binary. Therefore, all the bits in TRISB are forced to a logic 0,
which in turn means that all the bits in PORTB are set as outputs.
Line 10 TRISC = 0;
31
Chapter 1 Creating a Header File
The 0b in front of the number means the radix is binary and what
follows is a binary number. This makes all the bits in TRISD logic 1 and so
sets all bits in PORTD to inputs.
Line 12 TRISE = 0;
Line 13 ADCON0 = 0;
To appreciate what you are doing here, you must realize that there can
be two different types of inputs to the PIC. They are
The default setting is that all the inputs can be either digital or analog,
and there are 13 such inputs in the PIC 18F4525, which are set as analog.
This means you must do two things:
• Turn the ADC off since you are not using it.
32
Chapter 1 Creating a Header File
Not used Not used CHS3 CHS2 CHS1 CHS0 GO/DONE ADON
(continued)
33
Chapter 1 Creating a Header File
34
Chapter 1 Creating a Header File
Not used Not used VCFG1 VCFG0 PCFG3 PCFG2 PCFG1 PCFG0
35
Chapter 1 Creating a Header File
This sets the bits on the SFR ADCON1 to 00001111. This instruction uses
Table 1-2. From it you can see that as the first four bits of the ADCON1 SRF are
set to 1111, this makes all the inputs digital. This is what you want. When you
eventually need some analog inputs, you will have to make some changes.
Line 15 OSCTUNE = 0;
36
Exploring the Variety of Random
Documents with Different Content
amends for his first foolish act. He found a strong lance in the
hermitage, took it, and departed.
When Orilus and his lady had been received with honour at Arthur’s
Court, the king with all his knights set forth towards Munsalvaesch to
find the mighty man calling himself the Red Knight, who had sent so
many conquered pledges of his prowess; for he wished to make him
a knight of the Round Table. It was winter. Parzival—the Red Knight
—came riding from the opposite direction. As he drew near the
encampment of the king, his eye lighted on three drops of blood
showing clear red in the fresh-fallen snow; in mid air above, a wild
goose had been struck by a falcon. The knight paused in reverie—
red and white—the colours carried his thoughts to his heart’s queen,
Condwiramurs. There he sat, as a statue on his horse, with poised
spear; his thoughts had flown to her whose image now closed his
eyes to all else. A lad spied the great knight, and ran breathless to
Arthur, to tell of the stranger who seemed to challenge all the Round
Table. Segramors gained Arthur’s permission to accost him. Out he
rode with ready challenge; Parzival neither saw nor heard, till his
horse swerved at the knight’s approach, so that he saw the drops no
longer. Then his mighty lance fell in rest, Segramors was hurled to
the ground, and took himself back discomfited, while Parzival
returned to gaze on the drops of blood, lost in reverie as before.
Now Kay the quarrelsome rode out, and roused the hero with a rude
blow. The joust is run again, and Kay crawls back with broken leg
and arm. Again Parzival loses himself in reverie. And now courtly
Gawain, best of Arthur’s knights, rides forth, unarmed. Courteously
he addresses Parzival, who hears nothing, and sits moveless. Gawain
bethinks him it is love that binds the knight. Seeing that Parzival is
gazing on three drops of blood, he gently covers them with a silken
cloth. Parzival’s wits return; he moans: “Alas, lady wife of mine, what
comes between us? A cloud has hidden thee.” Then, astonished, he
sees Gawain—a knight without lance or shield—does he come to
mock? With noble courtesy Gawain disclosed himself and led the
way to Arthur’s Court, where fair ladies and the king greeted the
hero whom they had come to seek. A festival was ordained in his
honour. The fair company of knights and ladies are seated about the
Round Table; the feast is at its height, when suddenly upon a
gigantic mule, a scourge in her rough hand, comes riding the
seeress Cundrie, harsh and unlovely. Straight she addresses Arthur:
“Son of King Uterpendragon, you have shamed yourself and this
high company, receiving Parzival, whom you call the Red Knight.”
She turns on Parzival: “Disgrace fall on your proud form and
strength! Sir Parzival, tell me, how came it that you met that joyless
fisher, and did not help him? He showed you his pain, and you, false
guest, had no pity for him. Abhorred by all good men, marked for
hell by heaven’s Highest, you ban of happiness and curse of joy! No
leech can heal your sickened honour. Greater betrayal never shamed
a man so goodly. Your host gave you a sword; you saw them bear
the Grail, the silver dishes, and the bloody spear, and you,
dishonoured Parzival, were silent. You failed to win earth’s chiefest
prize; your father had not done so—are you his son? Yes, for
Herzeloide was as true as he. Woe’s me, that Herzeloide’s child has
so let honour slip!” Cundrie wrung her hands; her tears fell fast; she
turned her mule and cried: “Woe, woe to thee Munsalvaesch, mount
of pain; here is no aid for thee!” And bidding none farewell, she rode
away, leaving Parzival to his shame, the knights to their
astonishment, the ladies to their tears.
Cundrie was hardly out of sight, before another shame was put on
the Round Table. An armed knight rode in, and, accusing Gawain of
murdering his king and cousin, summoned him to mortal combat
within forty days before the King of Askalon. Arthur himself was
ready to do battle for Gawain, but that good knight accepted the
challenge with all courtesy.
Parzival’s lineage was first known to the Court from Cundrie’s calling
him by name and speaking of his mother. Now Clamide, once
Condwiramurs’s cruel wooer, begged the hero to intercede for him
with another fair one, the lady Cunneware. Parzival courteously
complied. A heathen queen then saluted him with the news that he
had a great heathen half-brother, Feirefiz, the son of Parzival’s father
by a heathen queen. Thanking her, Parzival spoke to the company:
“I cannot endure Cundrie’s reproach;—what knight here does not
look askance? I will seek no joy until I find the Grail, be the quest
short or long. The worthy Gurnemanz bade me refrain from
questions. Honoured knights, your favour is for me to win again, for
I have lost it. Me yet unshamed you took into your company; I
release you. Let sorrow be my comrade; for I forsook my happiness
on Munsalvaesch. Ah! helpless Anfortas! You had small help from
me.”
Knights and ladies were grieved to see the hero depart in such
sorrow, and many a knight’s service was offered him. The lady
Cunneware took his hand; Lord Gawain kissed him and said: “I know
thy way is full of strife; God grant to thee good fortune, and to me
the chance to serve thee.”
“Ah! what is God?” answered Parzival. “Were He strong He would not
have put such shame on me and you. I was His subject from the
hour I learned to ask His favour. Now I renounce His service. If He
hates me, I will bear it. Friend, in thine hour of strife let the love of a
woman pure and true strengthen thy hand. I know not when I shall
see thee again; may my good wishes towards thee be fulfilled.”
The hero’s arms are brought; his horse is saddled; his grievous toil
begins.
Why should long sorrow come to Parzival for not asking a question,
when his omission was caused neither by brutality nor ill will? when,
on the contrary, he would gladly have served his host? The relation
between his conduct and his fortune seems lame. Yet in life as well
as in literature, ignorance and error bring punishment. Moreover, to
mediaeval romance not only is there a background of sorcery and
magic, but active elements of magic survive in the tales.[725] And
nothing is more fraught with magic import and result than question
and answer. Wolfram did not treat as magical the effect upon his
hero’s lot of his failure to ask the question; but he retained the
palpably magic import of the act as affecting the sick Anfortas. It
was hard that the omission should have brought Parzival to sorrow
and despair; yet the fault was part of himself, and the man so
ignorant and unwise was sure to incur calamity, and also gain
sorrow’s lessons if he was capable of learning. So the sequence
becomes ethical: from error, calamity; from calamity, grief; and from
grief, wisdom. With Wolfram, Parzival’s fault was Parzival; failure to
ask the question was a symbol of his lack of wisdom. The poet was
of his time; and mediaeval thought tended to symbolism, and to
move, as it were, from symbol to symbol, and from symbolical
significance to related symbolical significance, and indeed often to
treat a symbol as if it were the fact which was symbolized.
END OF VOL. I
Aedh, i. 132
Aix-la-Chapelle:
Chapel at, i. 212 n.
School at, see Carolingian period—Palace school
Alaric, i. 112
Aldhelm, i. 185
Alexander the Great, Pseudo-Callisthenes’ Life of, ii. 224, 225, 229-
230;
Walter of Lille’s work on, ii. 230 n. 1
Almsgiving, i. 268
Alphanus, i. 253-4
Amadas, i. 565
Angels:
Aquinas’ discussion of, ii. 324-5, 435, 457 seqq., 469, 473-5
Dante’s views on, ii. 551
Emotionalizing of conception of, i. 348 n. 4
Hugo of St. Victor on, ii. 68, 69
Symbols, regarded as, ii. 457
Vincent’s Speculum as concerning, ii. 319
W itings ega ding s mma of ii 457
Writings regarding, summary of, ii. 457
Angilbert, i. 234-5
Angles, i. 140
Anglo-Saxons:
Britain conquered by, i. 141
Characteristics of, i. 142, 196
Christian missions by, i. 196, 197
Christian missions to, i. 172, 174, 180 seqq.
Customs of, i. 141
Poetry of, i. 142-4
Roman influence slight on, i. 32
Apollonius of Tyana, i. 44
Archimedes, i. 40
Architecture, Gothic:
Evolution of, i. 305; ii. 539
Great period of, i. 346
Arianism:
Teutonic acceptance of, i. 120, 192, 194
Visigothic abandonment of, i. 118 nn.
ebookbell.com