REAL TIME ECG & BODY TEMPERATURE
MONITORING DEVICE
MINI PROJECT REPORT
Submitted by
DILEEP DINESH
ELDHO JOSE
LADVINE D ALMEIDA
NIDHISH ROY
VIVEK K HARIDAS
In partial fulfillment for the award of
degree of
BACHELOR OF TECHNOLOGY
IN
ELECTRONICS AND BIOMEDICAL
ENGINEERING
MODEL ENGINEERING COLLEGE
Thrikkakara
Cochin University of Science and Technology
GOVERNMENT MODEL ENGINEERING COLLEGE
THRIKKAKARA
KOCHI
DEPARTMENT OF ELECTRONICS AND
BIOMEDICAL ENGINEERING
Cochin University of Science and Technology
BONAFIDE CERTIFICATE
This is to certify that the Mini Project entitled
………………………………………………………………….
Submitted by ………………………………………………………………………………………… ………………………………………………………………………………………… ………………………………………………………………………………………… …………………………………………………………………………………………
is a bonafide work done by him/her under our supervision
Dr.Jessy John Mrs.Vijayalakshmi k Ms.Nisha Krishnan
HEAD OF THE CO-ORDINATOR GUIDE
DEPARTMENT
ACKNOWLEDGEMENT
At this moment of accomplishment, we are presenting our work with great
pride and pleasure, we would like to express our sincere gratitude to all those who
helped us in the successful completion of our venture. First of all, we would like to
thank our Principal Prof. Dr.TK MANI who provided us with all facilities and
amenities for the development of our project.
We would like to thank Dr. Jessy John, Head of Department of Electronics and
Biomedical Engineering for helping us in the successful accomplishment of our
project.
We are exceedingly grateful to our project coordinator, Mrs. Vijayalakshmi K,
Asst. Professor, Dept. of Electronics and Biomedical Engineering for her timely and
valuable suggestions.
We would also like to thank our project guide Ms. Nisha Krishnan, Faculty staff
who gave us constant guidance and support throughout this journey of turbulence.
We also sincerely thank Mrs. Bella, Medical electronics lab-in-charge and Mrs.
Geethu and Mrs.Vidhya, Lab Technicians, Department of Electronics and
Biomedical for their constant support and encouragement for our project.
Above all we thank God almighty for constantly motivating us with His love, and
giving us courage at each stride to step forward with confidence and self – belief.
I
ABSTRACT
Our project aims at ECG Acquisition and temperature monitoring in medical field.
An ECG is a test that records the activity of the heart over time. Each portion
of the ECG waveform can hint whether the patient is in good health or else. ECG
signal are usually very small(approximately1mV) and therefore prone to interferences
The problem within the ECG among the existing processes for patients ECG
monitoring requires a great deal of effort to collect and analyze information
introducing a latency that prevents real-time analysis and use by a common person.
We propose a solution to automate this process by acquiring the ECG and
temperature, analyzing the information based on PR, QRS,ST intervals and amplitude
and providing different information to person based on it such as health status,
measurements etc. on a LCD screen.
The device is aimed at a common person to get current heart
condition and temperature .Moreover, the device is portable.
II
TABLE OF CONTENTS
SL NO TOPIC PAGE NO
1. INTRODUCTION 1
2. LITERATURE REVIEW 2
3. RELATEDTHEORIES
3.1 CARDIAC CONDUCTION PROCESS 3
3.2 ECG 4
3.3 WAVEFORM 5
3.4 ECG LEADS 6
3.4.1 ECG STANDARD LIMB LEADS 7
3.4.2 EINTHOVANS TRIANGLE 8
3.5 CARDIAC ARRHYTHMIAS 9
3.6 DURATION AND DISEASES
ASSOCIATED WITH ECG 10
3.7 BODY TEMPERATURE 11
4. DESIGN OF THE WORK
4.1 BLOCK DIAGRAM OF CIRCUIT 12
4.2 BLOCK LEVEL TREATMENT 13
III
4.2.1 ECG ACQUISITION BLOCK 13
4.2.2 TEMPERATURE SENSING 13
4.3 CIRCUIT LEVEL DESCRIPTION
4.3.1 INSTRUMENTATION AMPLIFIER 14
4.3.2 LOW PASS FILTER 17
4.3.3 HIGH PASS FILTER 18
4.3.4 RL DRIVE CIRCUIT 20
4.3.5 MICROCONTROLLER 20
4.4 FLOWCHARTS AND CIRCUITS 22
5. IMPLEMENTATION
5.1 SYSTEM REQUIREMENTS 26
5.2 HARDWARE REQUIREMENTS 26
5.3 SOFTWARE REQUIREMENTS 26
5.4 FULL CIRCUIT DIAGRAM 27
6. RESULT AND CONCLUSION 28
7. FUTURE WORKS 29
APPENDIX A PROGRAMS 30
REFERENCES 53
APPENDIX B DATA SHEETS 54
III
LIST OF FIGURES
SL NO: TOPIC PAGE NO
Fig 3.1 ECG Waveform 4
Fig 3.2 ECG Waveform Showing
Various Segments 5
Fig 3.3 Waveform Of Standard
Limb Leads 7
Fig3.4 Standard Limb Leads 7
Of ECG
Fig 3.5 Einthoven’s Triangle 8
Fig 4.1 Full Block Diagram 12
Fig 4.2 ECG Acquisition Block 13
Fig 4.3 Temperature Sensing Block 13
Fig 4.4 ECG Acquisition Block 14
Fig 4.5 Instrumentation Amplifier 15
Fig 4.6 Graphics LCD Circuit 23
Fig 4.7 Temperature Sensing Circuit 25
III
LIST OF ABBREVATIONS ECG- Electrocardiogram Rl-Right Leg LCD- Liquid Crystal Display GLCD- Graphical Liquid Crystal Display
III
CHAPTER 1
Introduction
An ECG (electrocardiogram) is a test that measures the electrical activity of the
heart. The heart is a muscular organ that beats in rhythm to pump the blood through the
body. The signals that make the heart's muscle fibers contract come from the Sino atrial
node, which is the natural pacemaker of the heart. In an ECG test, the electrical impulses
made while the heart is beating are recorded and usually shown on a piece of paper. This
is known as an electrocardiogram, and records any problems with the heart's rhythm, and
the conduction of the heart beat through the heart which may be affected by underlying
heart disease.ECG signals are usually small, approximately 1mV and therefore, it is
prone to corruption by various noises; power line interference, electrode contact noise,
motion artifacts. Also, it is necessary to design a good filter system that can filter out the
noises from the ECG signal in order to get better result. Therefore, measuring an ECG
signal is not an easy task to achieve.
The ECG signals are captured by the electrode sensors, and then it is amplified by
the instrumentation amplifier and precision amplifier. The gain achieved by cascading the
amplifiers must be equal or greater than1000 in order to achieve the desired signal output.
However, the noises may still interfere with the signal. Therefore, it is necessary to
design a band-pass filter (BPF) circuit where the low-pass circuit (LPF) will eliminate the
high-frequency noises and the high-pass circuit (HPF) will eliminate the direct current
(DC) noise components.
An operational amplifier will be used to invert the common noise voltage and
drive it back to the right leg of the patient which is considered the ground, in order to
cancel the interference.
1
CHAPTER 2
Literature Review
Initial research was conducted to determine the types of vital signs of heart and
arrhythmias and also body temperature that are routinely measured during a visit to a
doctor. As part of the project, it is necessary to find, design and build suitable electrodes
and temperature sensors. Then, the market demand for this type of device was determined
and research on similar monitoring devices that are currently sold was performed.
Major disadvantages with these devices are that they are not very easy to use,
somewhat intrusive, and, of course, very expensive. The main problem facing on GLCD
plotting and analysis ECG signal without MAT lab.
To measure the electrocardiogram (ECG), this project uses three Unipolar leads,
placed in Einthoven’s triangle configuration. Lead I, Lead II, and Lead III are used. This
method works accurately for the scope of this project as it is geared towards older
individuals who are less active.
Next, different types of temperature sensors were compared. It was determined
that the most effective way of measuring body temperature is by using a LM35. The
advantages and disadvantages of the temperature sensor is provided in block level
description of temperature sensing circuit.
2
CHAPTER 3
Related Theories
The heart is a four-chambered organ consisting of right and left halves. Two of
the chambers, the left and right atria, are entry-points into the heart, while the other two
chambers, the left and right ventricles, are responsible for contractions that send the blood through the circulation. The circulation is split into
the pulmonary and systemic circulation. The role of the right ventricle is to pump deoxygenated blood to the lungs through the pulmonary trunk and pulmonary arteries.
The role of the left ventricle is to pump newly oxygenated blood to the body through the
aorta.
3.1 Four Steps Of Cardiac Conduction: Step 1: Pacemaker Impulse Generation:
The sinoatrial (SA) node (also referred to as the pacemaker of the heart) contracts
generating nerve impulses that travel throughout the heart wall. This causes both atria to
contract. The SA node is located in the upper wall of the right atrium. It is composed of
nodal tissue that has characteristics of both muscle and nervous tissue. Step 2: AV node Impulse Conduction: The atrioventricular (AV) node lies on the right
side of the partition that divides the atria, near the bottom of the right atrium. When the
impulses from the SA node reach the AV node they are delayed for about a tenth of a
second. This delay allows the atria to contract and empty their contents first. Step 3: AV Bundle Impulse Conduction: The impulses are then sent down the
atrioventricular bundle. This bundle of fibres branches off into two bundles and the
impulses are carried down the centre of the heart to the left and right ventricles. Step 4: Purkinje fibres impulse conduction: At the base of the heart the
atrioventricular bundles starts to divide further into purkinje fibers. When the impulse
reaches these fibers they trigger the muscle fibers in the ventricles to contract.
3
3.2 ECG
The electrocardiogram (ECG) is a diagnostic tool that measures and records the
electrical activity of the heart in detail. Being able to interpretate these details allows
diagnosis of a wide range of heart problems. The ECG records the electrical activity and
depicts it as a series of graph-like tracings, or waves. The shapes and frequencies of these
tracings reveal abnormalities in the heart's anatomy or function.
Fig 3.1 ECG waveform
The EKG can provide important information about the patient's heart rhythm, a
previous heart attack, increased thickness of heart muscle, signs of decreased oxygen
delivery to the heart, and problems with conduction of the electrical current from one
portion of the heart to another.
There are no risks. No electricity is sent through the body, so there is no risk of
shock. The accuracy of the ECG depends on the condition being tested. A heart problem
may not always show up on the ECG. Some heart conditions never produce any specific
ECG changes.
4
3.3 Waveforms:
The ECG records the electrical activity that results when the heart muscle cells in the atria and ventricles contract.
Atrial contractions show up as the P wave.
Ventricular contractions show as a series known as the QRS complex.
The third and last common wave in an ECG is the T wave. This is the electrical
activity produced when the ventricles are recharging for the next contraction
(repolarizing).
Interestingly, the letters P, Q, R, S, and T are not abbreviations for any actual
words but were chosen many years ago for their position in the middle of the
alphabet.
The electrical activity results in P, QRS, and T waves that are of different sizes
and shapes. When viewed from different leads, these waves can show a wide
range of abnormalities of both the electrical conduction system and the muscle
tissue of the hearts 4 pumping chambers.
Fig 3.2 ECG waveform showing various segments
P Wave: represents atrial depolarization -the time necessary for an electrical impulse
from the sinoatrial (SA) node to spread throughout the atrial musculature.
Under normal conditions, electrical activity is spontaneously generated by the SA
node, the physiological pacemaker. This electrical impulse is propagated throughout the
5
right atrium, and through Bachmann's bundle to the left atrium, stimulating the
myocardium of both atria to contract. The conduction of the electrical impulse throughout
the left and right atria is seen on the ECG as the P wave.
Location: Precedes QRS complex. Amplitude: Should not exceed 2 to 2.5 mm in
height.
Duration: 0.06 to 0.11 seconds. P-R Interval: represents the time it takes an impulse to travel from the atria through the AV node, bundle of His, and bundle branches to the Purkinje fibres.
Location: Extends from the beginning of the P wave to the beginning of the QRS
complex.
Duration: 0.12 to 0.20 seconds. QRS Complex: represents ventricular depolarisation. The QRS complex consists of 3 waves: the Q wave, the R wave, and the S wave.
The Q wave is always located at the beginning of the QRS complex. It may or
may not always be present.
The R wave is always the first positive deflection.
The S wave, the negative deflection, follows the R wave 2.
Amplitude: Normal values vary with age and sex Duration: No longer than 0.10 seconds Q-T Interval: represents the time necessary for ventricular depolarization and repolarisation.
Location: Extends from the beginning of the QRS complex to the end of the T
wave (includes the QRS complex, S-T segment, and the T wave) Duration: Varies according to age, sex, and heart rate. T Wave: represents the repolarisation of the ventricles. On rare occasions, a U wave can
be seen following the T wave. The U wave reflects the repolarisation of the His-Purkinje
fibres.
Location: Follows the S wave and the S-T segment. 3.4 ECG leads:
The three types of ECG leads are :
6
Limb Leads (Bipolar)
Augmented Limb Leads (Unipolar)
Chest Leads (Unipolar)
Some of the ECG leads are bipolar leads(e.g., standard limb leads) that utilize a single
positive and a single negative electrode between which electrical potentials are measured.
Unipolar leads (augmented leads and chest leads) have a single positive recording
electrode and utilize a combination of the other electrodes to serve as a composite
negative electrode. Normally, when an ECG is recorded, all leads are recorded
simultaneously, giving rise to what is called a 12-lead ECG.
Fig 3.3 waveform of standard limb leads 3.4.1 Electrocardiogram Standard Limb Leads (Bipolar): There are three of these leads, I, II and III. Lead I: is between the right arm and left arm electrodes, the left arm being positive. Lead
II: is between the right arm and left leg electrodes, the left leg being positive. Lead III: is
between the left arm and left leg electrodes, the left leg again being positive.
Fig 3.4 standard limb leads of ECG
7
Lead I has the positive electrode on the left arm, and the negative electrode on the right
arm, and therefore measures the potential difference between the two arms. In this and
the other two limb leads, an electrode on the right leg serves as a reference electrode for
recording purposes. Lead II configuration, the positive electrode is on the left leg and the negative electrode
is on the right arm. Lead III has the positive electrode on the left leg and the negative electrode on the left
arm. These three bipolar limb leads roughly form an equilateral triangle (with the heart at
the centre) that is called Einthoven's triangle in honour of Willem Einthoven who
developed the electrocardiogram in 1901. Whether the limb leads are attached to the end
of the limb (wrists and ankles) or at the origin of the limb (shoulder or upper thigh)
makes no difference in the recording because the limb can simply be viewed as a long
wire conductor originating from a point on the trunk of the body. 3.4.2Einthovan’s Triangle
Fig 3.5 Einthoven triangle
8
An equilateral triangle whose vertices lie at the left and right shoulders and the
pubic region and whose center corresponds to the vector sum of all electric activity
occurring in the heart at any given moment, allowing for the determination of the
electrical axis. Einthoven's triangle is approximated by the triangle formed by the axes of
the bipolar electrocardiographic (ECG) limb leads I, II, and III. The centre of the triangle
offers a reference point for the Unipolar ECG leads. 3.5 Cardiac Arrhythmias: Arrhythmia is a irregular rhythm of heart. Bradycardia:
A slow rhythm, (less than 60 beats/min), is labelled Bradycardia. This may be
caused by a slowed signal from the sinus node (termed sinus Bradycardia), a pause in the
normal activity of the sinus node (termed sinus arrest), or by blocking of the electrical
impulse on its way from the atria to the ventricles (termed AV block or heart block).
Heart block comes in varying degrees and severity. It may be caused by reversible
poisoning of the AV node (with drugs that impair conduction) or by irreversible damage
to the node. Bradycardias may also be present in the normally functioning heart of
endurance athletes or other well-conditioned persons. Tachycardia:
In adults and children over 15, resting heart rate faster than 100 beats/minute is
labelled tachycardia. Tachycardia may result in palpitation, however, tachycardia is not
necessarily an arrhythmia. Increased heart rate is a normal response to physical exercise
or emotional stress. This is mediated by the sympathetic nervous system on the sinus
node, and is called sinus tachycardia. Other things that increase sympathetic nervous
system activity in the heart include ingested or injected substances such as caffeine or
amphetamines, and an overactive thyroid gland (hyperthyroidism).
Tachycardia that is not sinus tachycardia usually results from the addition of
abnormal impulses to the normal cardiac cycle. Abnormal impulses can begin by one of
three mechanisms: automaticity, re-entry or triggered activity. A specialised form of re-
entry problem is termed fibrillation.
9
3.6 Duration And Diseases Associated With Ecg
PR Interval
(Measured from beginning of P to beginning of QRS in the frontal plane)
Normal: 0.12 - 0.20s Short PR: < 0.12s Preexcitation syndromes:
WPW (Wolff-Parkinson-White) Syndrome: An accessory pathway
(called the "Kent" bundle) connects the right atrium to the right
ventricle (see diagram below) LGL (Lown-Ganong-Levine): An AV nodal bypass track into the His bundle
exists, and this permits early activation of the ventricles without a delta-wave
because the ventricular activation sequence is normal. Prolonged PR: >0.20s First degree AV block (PR interval usually constant)
Intra-atrial conduction delay (uncommon)
Slowed conduction in AV node (most common site)
Slowed conduction in His bundle (rare)
Slowed conduction in bundle branch (when contra lateral bundle is
blocked) Second degree AV block (PR interval may be normal or prolonged; some P waves
do not conduct)
Type I (Wenckebach): Increasing PR until nonconductor P wave occurs
Type II (Mobitz): Fixed PR intervals plus nonconductor P waves AV dissociation: Some PR's may appear prolonged, but the P waves and QRS
complexes are dissociated (i.e., not married, but strangers passing in the night). QRS Duration (Duration of QRS complex in frontal plane): Normal: 0.06 - 0.10s Prolonged QRS Duration (>0.10s):
10
QRS duration 0.10 - 0.12s
Incomplete right or left bundle branch block
Nonspecific intraventricular conduction delay (IVCD)
Some cases of left anterior or posterior fascicular block
QRS duration > 0.12s
Complete RBBB or LBBB
Nonspecific IVCD
Ectopic rhythms originating in the ventricles (e.g., ventricular
tachycardia, pacemaker rhythm) QT Interval (Measured from beginning of QRS to end of T wave in the frontal
plane) Normal: heart rate dependent Long QT Syndrome - "LQTS" (based on upper limits for heart rate; QT> 0.47 sec
for males and > 0.48 sec in females.
3.8 Body Temperature
Different parts of the body have different body temperatures. Rectal and vaginal measurements, or measurements taken directly inside the body cavity,
are typically slightly higher than oral measurements, and oral measurements are
somewhat higher than skin temperature. The commonly accepted average core body
temperature (taken internally) is 37.5 °C (99.5 °F). The typical oral (under the tongue)
measurement is slightly cooler, at 36.8° ± 0.4°C (98.2° ± 0.7°F), Although some people
think of these numbers as representing the normal temperature, a wide range of
temperatures has been found in healthy people.
The normal human body temperature can fluctuate about one degree (F)
throughout the day, with lower temperatures in the morning and higher temperatures in
the late afternoon and evening. The accepted range of "normal" temperature is from 97F
(36.1C) to 99F (37.2C).
11
CHAPTER 4
Design Of The Work
4.1 Block Diagram Of Circuit
It consists of mainly two blocks: ECG acquisition block &
temperature sensing block.
ECG ACQUISITION BLOCK
GLCD
TEMPERATURE SENSING BLOCK
Fig 4.1Block diagram
12
4.2 Block Level Treatment 4.2.1 ECG Acquisition Block
Fig 4.2 ECG acquisition block
This stage is used to acquire the ECG signal from the body using electrodes. It
consist of an instrumentation amplifier stage used to provide an initial gain to the signal
& is made using IC LM324. it is followed by a band pass filter which is used to remove
50hz power line interference & other unwanted noise from the signal. This stage is
followed by a differential amplifier stage made from IC LM324 which provides the final
amplification required for the signal. This signal is given to PIC & is then displayed using
a graphical display. 4.2.2 Temperature Sensing Block
Fig 4.3Temperature sensing block
The LM35 series are precision integrated-circuit temperature sensors, whose
output voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus
has an advantage over linear temperature sensors calibrated in ° Kelvin, as the user is not
required to subtract a large constant voltage from its output to obtain convenient
13
Centigrade scaling. The LM35 does not require any external calibration or trimming to
provide typical accuracies of ±¼°C at room temperature and ±¾°C over a full -55 to
+150°C temperature range. Low cost is assured by trimming and calibration at the wafer
level. The LM35's low output impedance, linear output, and precise inherent calibration
make interfacing to readout or control circuitry especially easy. It can be used with single
power supplies, or with plus and minus supplies. As it draws only 60 µA from its supply,
it has very low self-heating, less than 0.1°C in still air. The LM35 is rated to operate over
a -55° to +150°C temperature range, while the LM35C is rated for a -40° to +110°C
range (-10° with improved accuracy). The LM35 series is available packaged in hermetic
TO-46 transistor packages, while the LM35C, LM35CA, and LM35D are also available
in the plastic TO-92 transistor package. The LM35D is also available in an 8-lead surface
mount small outline package and a plastic TO-220 package.
4.3 Circuit Level Description
Fig 4.4 ECG acquisition circuit
4.3.1 Instrumentation Amplifier
As suggested before, it is
the amplifier circuit without having
necessary with the previous
beneficial to be able to adjust the gain of
to change more than one resistor value, as is design of differential amplifier. The so-
14
called instrumentation builds on the last version of differential amplifier to give us that
capability:
Fig 4.5 Instrumentation amplifier
This intimidating circuit is constructed from a buffered differential amplifier stage
with three new resistors linking the two buffer circuits together. Consider all resistors to
be of equal value except for Rgain. The negative feedback of the upper-left op-amp
causes the voltage at point 1 (top of Rgain) to be equal to V1. Likewise, the voltage at
point 2 (bottom of Rgain) is held to a value equal to V2. This establishes a voltage drop
across Rgain equal to the voltage difference between V1 and V2. That voltage drop causes
a current through Rgain, and since the feedback loops of the two input op-amps draw no
current, that same amount of current through Rgain must be going through the two "R"
resistors above and below it. This produces a voltage drop between points 3 and 4 equal
to:
15
The regular differential amplifier on the right-hand side of the circuit then takes
this voltage drop between points 3 and 4, and amplifies it by a gain of 1 (assuming again
that all "R" resistors are of equal value). Though this looks like a cumbersome way to
build a differential amplifier, it has the distinct advantages of possessing extremely high
input impedances on the V1 and V2 inputs (because they connect straight into the
noninverting inputs of their respective op-amps), and adjustable gain that can be set by a
single resistor. Manipulating the above formula a bit, we have a general expression for
overall voltage gain in the instrumentation amplifier:
(4.2)
Though it may not be obvious by looking at the schematic, we can change the
differential gain of the instrumentation amplifier simply by changing the value of one
resistor: Rgain. Yes, we could still change the overall gain by changing the values of
some of the other resistors, but this would necessitate balanced resistor value changes for
the circuit to remain symmetrical. Please note that the lowest gain possible with the
above circuit is obtained with Rgain completely open (infinite resistance), and that gain
value is 1.Now use instrumentation amplifier with LM324.the advantage is that working
on single supply such as 5V.
Design Instrumentation Amplifier Stage
Total Gain= 110
Gain of first stage, A1= 11
Gain of second stage, A2= 10
Atotal= (1+2R4/R5)(-Rf/R1)
Let R4= 100k therefore R5= 20k
Let R1= 100k we get Rf= 1M
16
4.3.1. a Features of Lm324 LM324 is a low power quad operational amplifier, it has these features: 1. Internally frequency compensated for unity gain 2. Large DC voltage gain 100 dB 3. Wide bandwidth (unity gain) 1 MHz (temperature compensated) 4. Wide power supply range: Single supply 3V to 32V . 5. Very low supply current drain (700 µA)-essentially independent of supply voltage 6. Low input biasing current 45 nA (temperature compensated) 7. Low input offset voltage 2 mV and offset current: 5 nA 8. Input common-mode voltage range includes ground 9. Differential input voltage range equal to the power supply voltage 10. Large output voltage swing 0V to V+ – 1.5) 4.3.2 Lowpass Filter
A low pass filter is an electronic circuit that passes low frequency
signals but attenuates (reduces the amplitude of) signals with frequencies higher than the cutoff frequency. The actual amount of attenuation for each frequency varies from
filter to filter. It is sometimes called a high-cut filter, or treble cut filter when used in
audio applications. Normally we using second order low pass filter for eliminating noise
from the ECG signal. second order Butterworth design follows the circuit design. As with
low-pass filters, high-pass filters have a rated cutoff frequency, above which the output
voltage increases above 70.7% of the input voltage. Just as in the case of the capacitive low-pass filter circuit, the capacitive high-pass filter's cutoff frequency can be foun with
the same formula.
fcut off = 1/2 RC (4.3)
Design
SECOND ORDER LOW PASS FILTER\
1) F= 1/(2πRC)
Let f= 25 HZ, C= 0.1 µF
17
R=1/(2πfC)= 1(2*3.14*25*0.1*10-6
)= 63.69k= 68k
Let gain= 2
1+Rf/R1= 2
Rf/R1= 1
Let Rf= R1= 100k
Therefore cut off frequency become 23.4 HZ
2) F= 1/(2πRC)
Let f= 25 HZ, C= 1 µF
R=1/(2πfC)= 1(2*3.14*25*1*10-6
)= 6.3 kΩ==6.8 kΩ
AMPLIFIER
Rf/R1= 10
Let R1= 100k
Rf= 1MΩ
4.3.3 High Pass Filter
The High Pass Filter is the exact opposite to the low pass filter. This filter has no
output voltage from DC (0Hz), up to a specified cut-off frequency (ƒc) point. This lower
cut-off frequency point is 70.7% or -3dB (dB = -20log Vout/Vin) of the voltage gain
allowed to pass. The frequency range "below" this cut-off point is generally known as
the Stop Band while the frequency range "above" this cut-off point is generally known as
the Pass Band. The cut-off frequency or -3dB point, can be found using the formula, ƒc =
1/(2πRC). The phase angle of the output signal at ƒc is +45o. Generally, the high pass
filter is less distorting than its equivalent low pass filter. Here using second order
highpass filter with LM358.Because of the better operating capabilities of IC and
elimination of DC drift from ECG signal due to noise, motion artifacts etc.
18
Design
SECOND ORDER HIGH PASS FILTER
F= 1/2π (R2R3C2C3)1/2
Let C2= C3= 47µF
F= .5 HZ
R2= R3= R
0.5= ½*3.14*(R2*(47*10
-6)2)1/2
R= 6.761 kΩ= 6.8kΩ
Features Of Lm358 LM358 is a low power dual operational amplifier, it has 12 features as:
Available in 8-Bump micro SMD chip sized package, (See AN-1112)
Internally frequency compensated for unity gain
Large dc voltage gain: 100 dB
Wide bandwidth (unity gain): 1 MHz (temperature compensated)
Wide power supply range:
Single supply: 3V to 32V
or dual supplies: ±1.5V to ±16V
Very low supply current drain (500 µA)-essentially independent of supply voltage
Low input offset voltage: 2 mV
Input common-mode voltage range includes ground
Differential input voltage range equal to the power supply voltage
Large output voltage swing
19
4.3.4 RL Drive Circuit
A Driven Right Leg Circuit or ―DRL‖ circuit is an electric circuit that is often
added to biological signal amplifiers to reduce Common noise. Biological signal
amplifiers such as EKG (Electrocardiogram) EEG (Electroencephalogram) or EMG
circuits measure very small electrical signals emitted by the body, often as small as
several micro-volts (millionths of a volt). Unfortunately, the patient's body can also act
as an antenna which picks up electromagnetic interference, especially 50/60 Hz noise
from electrical power lines. This interference can obscure the biological signals, making
them very hard to measure. Right Leg Driver circuitry is used to eliminate interference
noise by actively canceling the interference. Electrocardiography (ECG) is the science of
converting the ionic depolarization of the heart to a measurable electrical signal for
analysis. One of the most common challenges in the design of the analog electronics
interface to the electrodes/patient is in the optimization of the right leg drive (RLD) for
common mode performance and stability.
4.3.5 Microcontroller
Microcontroller are used in automatically controlled products and devices, such as
automobile engine control systems, implantable medical devices, remote controls, office
machines, appliances, power tools, toys and other embedded systems. By reducing the
size and cost compared to a design that uses a separate microprocessor, memory, and
input/output devices, microcontrollers make it economical to digitally control even more
devices and processes. Mixed signal microcontrollers are common, integrating analog
components needed to control non-digital electronic systems. Mostly using
microcontroller for interfacing signal to display system by PIC.
4.3.5. a Features • High performance RISC CPU • Only 35 single word instructions to learn • All single cycle instructions except for program branches which are two cycle • Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle
20
• Up to 8K x 14 words of FLASH Program Memory, Up to 368 x 8 bytes of Data Memory (RAM),Up to 256 x 8 bytes of EEPROM Data Memory
Peripheral Features: • Timer0: 8-bit timer/counter with 8-bit prescaler • Timer1: 16-bit timer/counter with prescaler can be incremented during SLEEP via
external crystal/clock. • Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler • Two Capture, Compare, PWM modules - Capture is 16-bit, max. resolution is 12.5 ns - Compare is 16-bit, max. resolution is 200 ns - PWM max. Resolution is 10-bit Timer Features: • 8-bit timer/counter • Readable and writable • 8-bit software programmable prescaler • Internal or external clock select • Interrupt on overflow from FFh to 00h • Edge select for external clock The PIC architectures have these advantages: Small instruction set to learn
RISC architecture
Built in oscillator with selectable speeds
Easy entry level, in circuit programming plus in circuit debugging PIC it units
available from Microchip.com for less than $50
Inexpensive microcontrollers Wide range of interfaces including I²C, SPI, USB, USART, A/D, programmable comparators, PWM, LIN, CAN, PSP, and Ethernet
21
4.4 Flow Chart Of Graphical Display
start
Graphical lcd either writes or
erases the point from the screen and
thereby plotting the points
PIC acquires the analog
values (ECG) and converts
them into digital values.
If x COR > 63 chip 2 is selected
using chip select, else chip 1 is
selected.
Y COR is divided into 8 pages of
1 bytes each. Command words are
produced by performing
operations of b=y/8 & d=y%8.
Reading and writing is done through
separate functions implemented in
the program.
Writing is done by reading the
present data, writing the new data is
done by ORing with the previous data
Erasing is performed by providing a zero
instead of one. The whole ECG is
displayed real time.
22
4.5 Graphical LCD:
Character based LCD’s are great for presenting the user with textual information.
However there are times you need a bit morefreedom when presenting data. In this
application note I will presenta interface between the Dios chips and a Crystal fonts
128x64Graphic LCD.
Fig 4.6 Graphical LCD connection
23
4.6 Flow chart of temperature sensing:
start
LM35 acquires Body temperature
and provides precision output volts
PIC accepts this volts in
RA0/AN0 and provides ASCII out
―BODY TEMP=‖
Code pattern from PIC (1) is
analyzed and given displayed as
arrhythmia and heart block.
The next page wil display ―RISK LEVEL=‖
24
Fig 4.7 Temperature sensing circuit
This circuit uses LM35 to detect the body temperature. This is then displayed on the LCD display through PIC.
25
CHAPTER 5
Implementation 5.1 System Requirements:
3 disposable surface electrodes
It is battery powered
Switches are provided for changing the lcd display 5.2 Hardware Requirements:
Supply is provided by 9v battery.
Lead wire should be insulated.
Filters are provided for removing the artefacts.
Floating ground is provided to remove baseline wandering.
Power supply is also regulated to 5v using 7805 so as to provide it for PIC &
display system 5.3 Software Requirements:
2 PIC’s are used.
PIC 1 contains the program for ECG display & also contains arrhythmia detection
logic.
ECG display program is used to plot real time ECG signal on GLCD.
Arrhythmia detection logic uses timer to calculate the time period of R-R interval
& QRS complex which is used to detect arrhythmia & syndrome related to
variation in QRS complex respectively.
LM 35 measure voltage corresponding to the body temperature which is send to
PIC 2 where it converts this voltage signals to corresponding readings in degree
Celsius.
26
27
CHAPTER 6
Results & Conclusion
In short, we were successfully able acquire ECG signal and display the body
temperature. ECG signal was displayed using graphical LCD and body temperature
was displayed using another alpha numeric LCD display.
In short, our solution delivers an integrated Device that automates the process
from data collecting (EKG and temperature) to Data monitoring and RESULT display.
There are several practical advantages in this implementation, such as: it provides
always-on, real-time data collecting; it eliminates manual collecting work and signal
analysis. This project contributes to scientific and social fields. On the scientific field, the
project generates new knowledge and applications for ECG monitoring. These areas are
being extensively explored by the academic community and the developments from this
project will address some of the outstanding questions. In addition, there is a contribution
to the social field, as the proposed system helps to improve the quality of medical
assistance delivery, especially in needy communities. It is difficult to gather medical staff
always for patient monitoring especially coma patients discharged from a hospital. In
addition, expert medical staff has restricted time and cannot monitor patients or collect
additional data from patients at bedside.
28
CHAPTER 8
Future Works
As future works, we intend to validate the proposal in a real world setup to assess
the benefits of cloud computing and updating the data on a web server real-time using
GSM services. In addition, we propose several services enhancements of security and
management with interaction of thirty-party infrastructure service provider.
29
Appendix A
Programs A) Graphical Lcd Display Program
#include<pic.h>
#include "delay.h"
#include "glcd.h"
#define GLCD_CS1 RC5 // Chip Selection 1
#define GLCD_CS2 RC4 // Chip Selection 2
#define GLCD_DI RD7 // Data or Instruction input
#define GLCD_RW RD6 // Read/Write
#define GLCD_E RD5 // Enable
#define GLCD_RST RD3 // Reset
#define GLCD_BUS PORTB
#define GLCD_LEFT 1
#define GLCD_RIGHT 0
#define ON 1
#define OFF 0
void glcd_init(char mode)
GLCD_RST=1; // Instruction input
30
GLCD_E=0;
GLCD_CS1=0;
GLCD_CS2=0;
GLCD_DI=0; // Set for instruction
glcd_writeByte(GLCD_LEFT, 0xC0); // Specify first RAM line at the top
glcd_writeByte(GLCD_RIGHT, 0xC0); // of the screen
glcd_writeByte(GLCD_LEFT, 0x40); // Set the column address to 0
glcd_writeByte(GLCD_RIGHT, 0x40);
glcd_writeByte(GLCD_LEFT, 0xB8); // Set the page address to 0
glcd_writeByte(GLCD_RIGHT, 0xB8);
if(mode == ON)
glcd_writeByte(GLCD_LEFT, 0x3F); // Turn the display on
glcd_writeByte(GLCD_RIGHT, 0x3F);
else
glcd_writeByte(GLCD_LEFT, 0x3E); // Turn the display off
glcd_writeByte(GLCD_RIGHT, 0x3E);
glcd_fillScreen(1); // Clear the display */
31
/*********************************************************************** *****/
void glcd_fillScreen(char color)
char i, j;
// Loop through the vertical
pages for(i = 0; i < 8; ++i)
GLCD_DI=0; // Set for instruction
glcd_writeByte(GLCD_LEFT, 0x40); // Set horizontal address to 0
glcd_writeByte(GLCD_RIGHT, 0x40);
glcd_writeByte(GLCD_LEFT, (i | 0xb8));// Set page
address glcd_writeByte(GLCD_RIGHT, (i | 0xb8));
GLCD_DI=1; // Set for data
// Loop through the horizontal
sections for(j = 0; j < 64; ++j)
glcd_writeByte(GLCD_LEFT, (0xFF*color)); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, (0xFF*color)); // Turn pixels on or off
32
/*********************************************************************** *****/
extern void glcd_pixel(char x,char y,char color)
char data=0;
char side = GLCD_LEFT; // Stores which chip to use on the LCD
x=127-x;
y=63-y;
if(x > 63) // Check for first or second display area
x -= 64;
side = GLCD_RIGHT;
GLCD_DI=0; // Set for instruction
data=(0x01<<(y%8));
glcd_writeByte(side, (0x40|x)); // Set the horizontal address
glcd_writeByte(side, (0xB8|(y/8))); // Set the vertical page address
GLCD_DI=1; // Set for data
glcd_readByte(side); // Need two reads to get data
data |= glcd_readByte(side); // at new address
33
if(color)data|=(0x01<<(y%8)); // Clear the MSB. Part of an instruction
code
else data&=~(0x01<<(y%8)); // Set bit 6. Also part of an instruction code
GLCD_DI=0; // Set for instruction
glcd_writeByte(side, (0x40|x)); // Set the horizontal address
GLCD_DI=1; // Set for data
glcd_writeByte(side, data); // Write the pixel data
/*********************************************************************** *****/
void glcd_writeByte(char side, char data)
if(side) // Choose which side to write to
GLCD_CS1=1;
Else
GLCD_CS2=1;
GLCD_BUS=0;
GLCD_RW=0; // Set for writing
34
PORTB=data; // Put the data on the port
NOP();
NOP();
NOP();
NOP();
NOP();
RD5=1; // Pulse the enable pin
NOP();
NOP();
NOP();
NOP();
RD5=0;
GLCD_CS1=0; // Reset the chip select lines
GLCD_CS2=0;
/*********************************************************************** *****/
char glcd_readByte(char side)
char data; // Stores the data read from the LCD
35
TRISB=0xFF;
GLCD_RW=1; // Set for reading
if(side) // Choose which side to write to
GLCD_CS1=1;
GLCD_CS2=0;
else
GLCD_CS1=0;
GLCD_CS2=1;
NOP();
NOP();
NOP();
NOP();
RD5=1; // Pulse the enable pin
NOP();
NOP();
NOP();
NOP();
NOP();
36
data = PORTB; // Get the data from the display's output register
RD5=0;
GLCD_CS1=0; // Reset the chip select lines
GLCD_CS2=0;
TRISB=0;
return data; // Return the read dat
#include<pic.h>
#include "delay.h"
#include "glcd.h"
#define GLCD_CS1 RC5 // Chip Selection 1
#define GLCD_CS2 RC4 // Chip Selection 2
#define GLCD_DI RE0 // Data or Instruction input
#define GLCD_RW RE1 // Read/Write
#define GLCD_E RE2 // Enable
#define GLCD_RST RD3 // Reset
#define GLCD_BUS PORTB
#define GLCD_LEFT 1
#define GLCD_RIGHT 0
#define ON 1
37
#define OFF 0 void glcd_init(char mode)
GLCD_RST=1; // Instruction input
GLCD_E=0;
GLCD_CS1=0;
GLCD_CS2=0;
GLCD_DI=0; // Set for instruction
glcd_writeByte(GLCD_LEFT, 0xC0); // Specify first RAM line at the top
glcd_writeByte(GLCD_RIGHT, 0xC0); // of the screen
glcd_writeByte(GLCD_LEFT, 0x40); // Set the column address to 0
glcd_writeByte(GLCD_RIGHT, 0x40);
glcd_writeByte(GLCD_LEFT, 0xB8); // Set the page address to 0
glcd_writeByte(GLCD_RIGHT, 0xB8);
if(mode == ON)
38
glcd_writeByte(GLCD_LEFT, 0x3F); // Turn the display on
glcd_writeByte(GLCD_RIGHT, 0x3F);
else
glcd_writeByte(GLCD_LEFT, 0x3E); // Turn the display off
glcd_writeByte(GLCD_RIGHT, 0x3E);
glcd_fillScreen(1); // Clear the display */
void glcd_fillScreen(char color)
char i, j;
// Loop through the vertical
pages for(i = 0; i < 8; ++i)
GLCD_DI=0; // Set for instruction
glcd_writeByte(GLCD_LEFT, 0x40); // Set horizontal address to 0
39
glcd_writeByte(GLCD_RIGHT, 0x40);
glcd_writeByte(GLCD_LEFT, (i | 0xb8));// Set page
address glcd_writeByte(GLCD_RIGHT, (i | 0xb8));
GLCD_DI=1; // Set for data
// Loop through the horizontal
sections for(j = 0; j < 64; ++j)
glcd_writeByte(GLCD_LEFT, (0xFF*color)); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, (0xFF*color)); // Turn pixels on or off
extern void glcd_pixel(char x,char y,char color)
char data=0;
char side = GLCD_LEFT; // Stores which chip to use on the LCD
if(x > 63) // Check for first or second display area
x -= 64;
side = GLCD_RIGHT;
40
GLCD_DI=0; // Set for instruction
data=(0x01<<(y%8));
glcd_writeByte(side, (0x40|x)); // Set the horizontal address
glcd_writeByte(side, (0xB8|(y/8))); // Set the vertical page address
GLCD_DI=1; // Set for data
glcd_readByte(side); // Need two reads to get data
data |= glcd_readByte(side); // at new address
if(color)data|=(0x01<<(y%8)); // Clear the MSB. Part of an instruction code
else data&=~(0x01<<(y%8)); // Set bit 6. Also part of an instruction code
GLCD_DI=0; // Set for instruction
glcd_writeByte(side, (0x40|x)); // Set the horizontal address
GLCD_DI=1; // Set for data
glcd_writeByte(side, data); // Write the pixel data
void glcd_block(char x,char y,char color)
41
char data=0;
char side = GLCD_LEFT; // Stores which chip to use on the LCD
if(x > 63) // Check for first or second display area
x -= 64;
side = GLCD_RIGHT;
GLCD_DI=0; // Set for instruction
data=(0x01<<(y%8));
glcd_writeByte(side, (0x40|x)); // Set the horizontal address
glcd_writeByte(side, (0xB8|(y/8))); // Set the vertical page address
//IO1SET =GLCD_DI; // Set for data
// glcd_readByte(side); // Need two reads to get data
// data |= glcd_readByte(side); // at new address
if(color)data=0xff; // Clear the MSB. Part of an instruction code
else data = 0; // Set bit 6. Also part of an instruction code
//IO1CLR =GLCD_DI; // Set for instruction
glcd_writeByte(side, (0x40|x)); // Set the horizontal address
42
GLCD_DI=1; // Set for data
glcd_writeByte(side, data); // Write the pixel data
void glcd_writeByte(char side, char data)
if(side) // Choose which side to write to
GLCD_CS1=1;
else
GLCD_CS2=1;
GLCD_BUS=0;
GLCD_RW=0; // Set for writing
GLCD_BUS=data; // Put the data on the port
NOP();
NOP();
NOP();
43
NOP();
NOP();
NOP();
NOP();
NOP();
GLCD_E=1; // Pulse the enable pin
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
GLCD_E=0;
GLCD_CS1=0; // Reset the chip select lines
GLCD_CS2=0;
44
char glcd_readByte(char side)
char data; // Stores the data read from the LCD
TRISB=0xFF;
GLCD_RW=1; // Set for reading
if(side) // Choose which side to write to
GLCD_CS1=1;
GLCD_CS2=0;
else
GLCD_CS1=0;
GLCD_CS2=1;
NOP();
NOP();
NOP();
45
NOP();
NOP();
NOP();
NOP();
NOP();
GLCD_E=1; // Pulse the enable pin
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
data = GLCD_BUS; // Get the data from the display's output register
GLCD_E=0;
GLCD_CS1=0; // Reset the chip select lines
GLCD_CS2=0;
TRISB=0;
46
return data; // Return the read data
B) Temperature Sensing Program #include<pic.h> Void
command(char); void
data(char);
void lcd_print(char*);
void delay(long);
void main()
Int c,a[8],b;
TRISC0=0;
TRISC1=0;
TRISC5=0; //TRIS=0 MEANS OUTPUT PORT AND VICEVERSA
TRISD=0; //B,C,D ARE PORTS
TRISA0=1; //for adc input
47
TRISB0=1; TRISB4=1; TRISB5=1; TRISB6=1; TRISB2=1;
int count=0;
delay(25);
command(0x30);
delay(15);
command(0x30); //LCD INITIALIZATION
delay(5);
command(0x30);
delay(1);
command(0X38);
command(0x0C);
command(0x06); //LCD CHARACTER MAPPING
command(0x01);
command(0x01);delay(6);command(0x83);delay(2);
lcd_print("SMART CARDIOLOGIST");
delay(500);
command(0x01);
delay(10);
loop:
ADCON0=0x81;
ADCON1=0xC0; //PRESET ADC CONFIG
48
while(!RB0)
if(RB2)goto credits;
command(0x01);delay(1);
lcd_print("BODY TEMPERTATURE =");
GO=1; //Initialize the ADC
while(GO);
b=ADRESH;
b=b<<8;
b=b|ADRESL;
b=((b/2)-1);
for(int i=0;i<2;i++)
a[i]=b%10;
b=b/10;
for(int i=1;i>=0;i--)
data(a[i]+'0');
delay(50);
49
command(0x01);delay(50);if(RB2)goto credits;
if((RB4==0)&&(RB5==0)&&(RB6==0))c=0;lcd_print("1st degree arrhythmia
detected");
if((RB4==0)&&(RB5==0)&&(RB6==1))c=1;lcd_print("2nd degree arrhythmia
detected");
if((RB4==0)&&(RB5==1)&&(RB6==0))c=2;lcd_print("3rd degree arrhythmia
detected"); while(!RB0);
if(RB2)goto credits;
Command (0x01);delay(50);
If(c==0)command(0x83);lcd_print("RISK LEVEL: LOW");
If(c==1)command(0x83);lcd_print("RISK LEVEL: MEDIUM");
If(c==2)command(0x83);lcd_print("RISK LEVEL:
CRITICAL"); delay(1000);
Goto loop;
Credits:
Command (0x07);delay(3);
lcd_print("developed by dileep nidhish eldho vivek and ladvine ");delay(100);
Goto loop;
50
/*********************************************************************** ****/
Void command (char a)
RC0=0;
RC1=0;
PORTD=a;
RC5=1;
delay(1);
RC5=0;
/*********************************************************************** *****/
void data(char m)
RC0=1;
RC1=0;
PORTD=m;
RC5=1;
delay(1);
RC5=0;
51
/*********************************************************************** *****/
Void lcd_print(char* n)
While (*n!='\0')
Data (*n);
n++;
/*********************************************************************** *****/
Void delay(long g)
int i,j;
for(i=0;i<=g;i++)
for(j=0;j<255;j++);
52
REFERENCE
wikipedia.org › Health science › Medicine › Emergency medicine
wikipedia.org/wiki/Cardiac_arrhythmia wikipedia.org/wiki/Human_body_temperature firstaid.webmd.com/body-temperature\ http://203.217.146.76/projects/MAIN/BME/M2-DOC-
ecg%20acquisition%20and%20arrythmia%20detection.pdf http://www.ti.com/lit/ds/symlink/lm35.pdf http://www.ti.com/lit/ds/symlink/lm124-n.pdf
Guyton AC: An author’s philosophy of physiology textbook
writing. Adv Physiol Ed 19: s1–s5, 1998.
53
Appendix B
PIC16F87X
Data Sheet
28/40-Pin 8-Bit CMOS FLASH
Microcontrollers
2001 Microchip Technology Inc. DS30292C
―All rights reserved. Copyright © 2001, Microchip Technology Incorporated, USA. Information contained in this publication
regarding device applications and the like is intended through
suggestion only and may be superseded by updates. No rep-
resentation or warranty is given and no liability is assumed by
Microchip Technology Incorporated with respect to the accu-racy
or use of such information, or infringement of patents or other
intellectual property rights arising from such use or oth-erwise.
Use of Microchip‟s products as critical components in life
support systems is not authorized except with express written
approval by Microchip. No licenses are conveyed, implicitly or
otherwise, under any intellectual property rights. The Microchip
logo and name are registered trademarks of Microchip
Technology Inc. in the U.S.A. and other countries. All rights
reserved. All other trademarks mentioned herein are the property
of their respective companies. No licenses are conveyed,
implicitly or otherwise, under any intellectual prop-erty rights.”
Trademarks The Microchip name, logo, PIC, PICmicro, PICMASTER, PIC-
START, PRO MATE, KEELOQ, SEEVAL, MPLAB and The
Embedded Control Solutions Company are registered trade-
marks of Microchip Technology Incorporated in the U.S.A. and
other countries. Total Endurance, ICSP, In-Circuit Serial Programming, Filter-Lab,
MXDEV, microID, FlexROM, fuzzyLAB, MPASM, MPLINK,
MPLIB, PICDEM, ICEPIC, Migratable Memory, FanSense,
ECONOMONITOR and SelectMode are trade-marks of Microchip
Technology Incorporated in the U.S.A. Serialized Quick Term Programming (SQTP) is a service mark of Microchip Technology Incorporated in the U.S.A. All other trademarks mentioned herein are property of their respective companies. © 2001, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved. Microchip received QS-9000 quality system certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona in July 1999. The Company’s quality system processes and procedures are QS-9000 compliant for its PICmicro® 8-bit MCUs, KEELOQ
® code hopping devices, Serial EEPROMs and microperipheral products. In addition, Microchip’s quality system for the design and manufacture of development systems is ISO 9001 certified.
DS30292C - page ii 2001 Microchip Technology Inc.
PIC16F87X
28/40-Pin 8-Bit CMOS FLASH Microcontrollers
Devices Included in this Data Sheet: • PIC16F873 • PIC16F876 • PIC16F874 • PIC16F877 Microcontroller Core Features: • High performance RISC CPU • Only 35 single word instructions to learn • All single cycle instructions except for
program branches which are two cycle • Operating speed: DC - 20 MHz clock input
DC - 200 ns instruction cycle • Up to 8K x 14 words of FLASH Program Memory,
Up to 368 x 8 bytes of Data Memory (RAM) Up to 256 x 8 bytes of EEPROM Data Memory
• Pinout compatible to the PIC16C73B/74B/76/77 • Interrupt capability (up to 14 sources) • Eight level deep hardware stack • Direct, indirect and relative addressing modes • Power-on Reset (POR) • Power-up Timer (PWRT) and
Oscillator Start-up Timer (OST) • Watchdog Timer (WDT) with its own on-chip RC
oscillator for reliable operation • Programmable code protection • Power saving SLEEP mode • Selectable oscillator options • Low power, high speed CMOS FLASH/EEPROM
technology • Fully static design • In-Circuit Serial Programming (ICSP) via two
pins • Single 5V In-Circuit Serial Programming capability • In-Circuit Debugging via two pins • Processor read/write access to program memory • Wide operating voltage range: 2.0V to 5.5V • High Sink/Source Current: 25 mA • Commercial, Industrial and Extended
temperature ranges • Low-power consumption:
-< 0.6 mA typical @ 3V, 4 MHz - 20 µA typical @ 3V, 32 kHz - <1µA typical standby current
Pin Diagram
PDIP
MCLR/VPP 1 40 RB7/PGD
RA0/AN0 2 39 RB6/PGC
RA1/AN1 3 38 RB5
RA2/AN2/VREF- 4 37 RB4
RA3/AN3/VREF+ 5 36 RB3/PGM
RA4/T0CKI 6 35 RB2
RA5/AN4/SS 7
PIC
16
F8
77/8
74
34 RB1
RE0/RD/AN5 8 33 RB0/INT
RE1/WR/AN6 9 32 VDD
RE2/CS/AN7 10 31 VSS
VDD 11 30 RD7/PSP7
VSS 12 29 RD6/PSP6
OSC1/CLKIN 13 28 RD5/PSP5
OSC2/CLKOUT 14 27 RD4/PSP4
RC0/T1OSO/T1CKI 15 26 RC7/RX/DT
RC1/T1OSI/CCP2 16 25 RC6/TX/CK
RC2/CCP1 17 24 RC5/SDO
RC3/SCK/SCL 18 23 RC4/SDI/SDA
RD0/PSP0 19 22 RD3/PSP3
RD1/PSP1 20 21 RD2/PSP2
Peripheral Features: • Timer0: 8-bit timer/counter with 8-bit prescaler • Timer1: 16-bit timer/counter with prescaler,
can be incremented during SLEEP via external crystal/clock
• Timer2: 8-bit timer/counter with 8-bit period
register, prescaler and postscaler • Two Capture, Compare, PWM modules
- Capture is 16-bit, max. resolution is 12.5 ns - Compare is 16-bit, max. resolution is 200 ns - PWM max. resolution is 10-bit
• 10-bit multi-channel Analog-to-Digital converter • Synchronous Serial Port (SSP) with SPI (Master
mode) and I2
C (Master/Slave) • Universal Synchronous Asynchronous Receiver
Transmitter (USART/SCI) with 9-bit address detection
• Parallel Slave Port (PSP) 8-bits wide, with external
RD, WR and CS controls (40/44-pin only) • Brown-out detection circuitry for
Brown-out Reset (BOR)
2001 Microchip Technology Inc. DS30292C-page 1
PIC16F87X
Pin Diagrams
PDIP, SOIC
MCLR/VPP 1 RA0/AN0 2 RA1/AN1 3
RA2/AN2/VREF- 4 RA3/AN3/VREF+ 5
RA4/T0CKI 6 RA5/AN4/SS 7
VSS 8 OSC1/CLKIN 9
OSC2/CLKOUT 10 RC0/T1OSO/T1CKI 11
RC1/T1OSI/CCP2 12 RC2/CCP1 13
RC3/SCK/SCL 14
PIC
16F
876/8
73
28 RB7/PGD 27 RB6/PGC 26 RB5 25 RB4 24 RB3/PGM 23 RB2 22 RB1 21 RB0/INT 20 VDD 19 VSS 18 RC7/RX/DT 17 RC6/TX/CK 16 RC5/SDO 15 RC4/SDI/SDA
PLCC
RA4/T0CKI
RA5/AN4/SS RE0/RD/AN5
RE1/WR/AN6 RE2/CS/AN7
VDD VSS
OSC1/CLKIN OSC2/CLKOUT
RC0/T1OSO/T1CK1 NC
+ -
R EF
RE
F
P P
R A 3 / A N 3 / V R A 2 / A N 2 / V R A 1 / A N 1 R A 0 / A N 0 M C L R / V N C R B 7 / P G D R B 6 / P G C R B 5 R B 4 N C
6 5 4 3 2 1
4443
41
7
8
9
10
11 PIC16F877
12
PIC16F874
13
14
15
16
17 6
1 8
202
223
24 22 7
39 RB3/PGM 38 RB2 37 RB1 36 RB0/INT 35 VDD 34
VSS 33 RD7/PSP7 32 RD6/PSP6 31 RD5/PSP5 30 RD4/PSP4 29 RC7/RX/DT
RC6/TX/
CKRC5/S
DORC4/
SDI/SDA
RD3/PSP
3RD2/PS
P2
RD0/PSP0RC3/SCK/SCL CP2
QFP RD1/PSP1
RC2/CCP1
RC1/T1OSI/C
NC
4443424140
38373635
RC7/RX/DT 1 33
RD4/PSP4 2 32
RD5/PSP5 3 31
RD6/PSP6 4 30
RD7/PSP7 5 PIC16F877 29
VSS 6
28 PIC16F874
VDD 7 27
RB0/INT 8 26
RB1 9 25
RB2 10 24
RB3/PGM 11 8 23
1 2
1 4 16
11920
2 2
NCNC
RB4RB5
PP
- +
RB6/PGC
RB7/PG
D RA0/AN0
RA1/AN1
REF
R E F
MCLR/
V
RA2/AN2/
V
RA3/AN3/
V
DS30292C-page 2
RC2/CC
P1
RD0/PS
P0
RD1/PSP1
RD2/PSP2
RD3/PSP
3
RC4/SDI/SDA
RC5/SDO N C
RC6/TX/C
K
RC1/T1OSI/CCP
2
RC3/SCK/S
CL
NC RC0/T1OSO/T1CKI OSC2/CLKOUT OSC1/CLKIN VSS VDD RE2/AN7/CS RE1/AN6/WR RE0/AN5/RD RA5/AN4/SS RA4/T0CKI
2001 Microchip Technology Inc.
PIC16F87X
Key Features
PICmicro™ Mid-Range Reference PIC16F873 PIC16F874 PIC16F876 PIC16F877
Manual (DS33023)
Operating Frequency DC - 20 MHz DC - 20 MHz DC - 20 MHz DC - 20 MHz
RESETS (and Delays) POR, BOR POR, BOR POR, BOR POR, BOR
(PWRT, OST) (PWRT, OST) (PWRT, OST) (PWRT, OST)
FLASH Program Memory 4K
4K 8K 8K
(14-bit words)
Data Memory (bytes) 192 192 368 368
EEPROM Data Memory 128 128 256 256
Interrupts 13 14 13 14
I/O Ports Ports A,B,C Ports A,B,C,D,E Ports A,B,C Ports A,B,C,D,E
Timers 3 3 3 3
Capture/Compare/PWM Modules 2 2 2 2
Serial Communications MSSP, USART MSSP, USART MSSP, USART MSSP, USART
Parallel Communications — PSP — PSP
10-bit Analog-to-Digital Module 5 input channels 8 input channels 5 input channels 8 input channels
Instruction Set 35 instructions 35 instructions 35 instructions 35 instructions
2001 Microchip Technology Inc. DS30292C-page 3
PIC16F87X Table of Contents
1.0 Device Overview .................................................................................................................................................. 5 2.0 Memory Organization ......................................................................................................................................... 11 3.0 I/O Ports............................................................................................................................................................. 29 4.0 Data EEPROM and FLASH Program Memory.................................................................................................... 41 5.0 Timer0 Module ................................................................................................................................................... 47 6.0 Timer1 Module ................................................................................................................................................... 51 7.0 Timer2 Module ................................................................................................................................................... 55 8.0 Capture/Compare/PWM Modules ....................................................................................................................... 57 9.0 Master Synchronous Serial Port (MSSP) Module................................................................................................ 65 10.0 Addressable Universal Synchronous Asynchronous Receiver Transmitter (USART) ......................................... 95 11.0 Analog-to-Digital Converter (A/D) Module ......................................................................................................... 111 12.0 Special Features of the CPU............................................................................................................................. 119 13.0 Instruction Set Summary................................................................................................................................... 135 14.0 Development Support ....................................................................................................................................... 143 15.0 Electrical Characteristics................................................................................................................................... 149 16.0 DC and AC Characteristics Graphs and Tables................................................................................................. 177 17.0 Packaging Information ...................................................................................................................................... 189 Appendix A: Revision History..................................................................................................................................... 197 Appendix B: Device Differences ................................................................................................................................ 197 Appendix C: Conversion Considerations.................................................................................................................... 198 Index ......................................................................................................................................................................... 199 On-Line Support ........................................................................................................................................................ 207 Reader Response ..................................................................................................................................................... 208 PIC16F87X Product Identification System ................................................................................................................. 209
TO OUR VALUED CUSTOMERS
It is our intention to provide our valued customers with the best documentation possible to ensure successful use of your Microchip
products. To this end, we will continue to improve our publications to better suit your needs. Our publications will be refined and enhanced
as new volumes and updates are introduced.
If you have any questions or comments regarding this publication, please contact the Marketing Communications Department via E-mail at
[email protected] or fax the Reader Response Form in the back of this data sheet to (480) 792-4150. We welcome your
feedback.
Most Current Data Sheet
To obtain the most up-to-date version of this data sheet, please register at our Worldwide Web site at:
http://www.microchip.com
You can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page. The last character of the literature number is the version number, (e.g., DS30000A is version A of document DS30000).
Errata
An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the revision of silicon and revision of document to which it applies. To determine if an errata sheet exists for a particular device, please check with one of the following: • http://www.microchip.com/ Microchip‟s Worldwide Web site; http://www.microchip.com • Your local Microchip sales office (see last page) • The Microchip Corporate Literature Center; U.S. FAX: (480) 792-7277 When contacting a sales office or the literature center, please specify which device, revision of silicon and data sheet (include literature number) you are using.
Customer Notification System
Register on our web site at www.microchip.com/cn to receive the most current information on all of our products.
DS30292C-page 4 2001 Microchip Technology Inc.
PIC16F87X
FIGURE 1-2: PIC16F874 AND PIC16F877 BLOCK DIAGRAM
Device Program Data Memory
Data
FLASH
EEPROM
PIC16F874 4K 192 Bytes 128 Bytes
PIC16F877 8K 368 Bytes 256 Bytes
13 Data Bus 8
Program Counter
FLASH
Program
Memory RAM
8 Level Stack
File
(13-bit)
Registers
Program 14
RAM Addr(1)
Bus 9
Instruction reg Addr MUX
Direct Addr 7 Indirect
8 Addr
FSR reg
STATUS reg
8
Power-up 3 MUX
Timer
Instruction Oscillator
Decode & Start-up Timer ALU
Control
Power-on
8
Reset
Timing Watchdog W reg
Generation
Timer
OSC1/CLKIN Brown-out
OSC2/CLKOUT Reset
In-Circuit
Debugger
Low-Voltage
Programming Parallel Slave Port
MCLR VDD, VSS
Timer0 Timer1 Timer 10-bit A/D
2
Data EEPROM
CCP1,2 Synchronous USART
Serial Port
Note 1: Higher order bits are from the STATUS register.
DS30292C-page 6
PORTA
RA0/AN0 RA1/AN1
RA2/AN2/VREF-
RA3/AN3/VREF+
RA4/T0CKI RA5/AN4/SS
PORTB
RB0/INT RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD
PORTC
RC0/T1OSO/T1CKI RC1/T1OSI/CCP2
RC2/CCP1
RC3/SCK/SCL
RC4/SDI/SDA
RC5/SDO
RC6/TX/CK
RC7/RX/DT PORTD
RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RD4/PSP4 RD5/PSP5 RD6/PSP6 RD7/PSP7
PORTE
RE0/AN5/RD
RE1/AN6/WR
RE2/AN7/CS
2001 Microchip Technology Inc.
PIC16F87X
TABLE 1-2: PIC16F874 AND PIC16F877 PINOUT DESCRIPTION
Pin Name DIP PLCC QFP I/O/P Buffer Description
Pin# Pin# Pin# Type Type
OSC1/CLKIN 13 14 30 I ST/CMOS(4)
Oscillator crystal input/external clock source input.
OSC2/CLKOUT 14 15 31 O — Oscillator crystal output. Connects to crystal or resonator
in crystal oscillator mode. In RC mode, OSC2 pin outputs
CLKOUT which has 1/4 the frequency of OSC1, and
denotes the instruction cycle rate.
MCLR/VPP 1 2 18 I/P ST Master Clear (Reset) input or programming voltage input.
This pin is an active low RESET to the device.
PORTA is a bi-directional I/O port.
RA0/AN0 2 3 19 I/O TTL RA0 can also be analog input0.
RA1/AN1 3 4 20 I/O TTL RA1 can also be analog input1.
RA2/AN2/VREF- 4 5 21 I/O TTL RA2 can also be analog input2 or negative
analog reference voltage.
RA3/AN3/VREF+ 5 6 22 I/O TTL RA3 can also be analog input3 or positive
analog reference voltage.
RA4/T0CKI 6 7 23 I/O ST RA4 can also be the clock input to the Timer0 timer/
counter. Output is open drain type.
RA5/SS/AN4 7 8 24 I/O TTL RA5 can also be analog input4 or the slave select for
the synchronous serial port.
PORTB is a bi-directional I/O port. PORTB can be soft-
ware programmed for internal weak pull-up on all inputs.
RB0/INT 33 36 8 I/O TTL/ST(1)
RB0 can also be the external interrupt pin.
RB1 34 37 9 I/O TTL
RB2 35 38 10 I/O TTL
RB3/PGM 36 39 11 I/O TTL RB3 can also be the low voltage programming input.
RB4 37 41 14 I/O TTL Interrupt-on-change pin.
RB5 38 42 15 I/O TTL Interrupt-on-change pin.
RB6/PGC 39 43 16 I/O TTL/ST(2)
Interrupt-on-change pin or In-Circuit Debugger pin.
Serial programming clock.
RB7/PGD 40 44 17 I/O TTL/ST(2)
Interrupt-on-change pin or In-Circuit Debugger pin.
Serial programming data.
Legend: I = input O = output I/O = input/output P = power — = Not used TTL = TTL input ST = Schmitt Trigger input Note 1: This buffer is a Schmitt Trigger input when configured as an external interrupt.
2: This buffer is a Schmitt Trigger input when used in Serial Programming mode.
3: This buffer is a Schmitt Trigger input when configured as general purpose I/O and a TTL input when used in the Parallel Slave Port mode (for interfacing to a microprocessor bus).
4: This buffer is a Schmitt Trigger input when configured in RC oscillator mode and a CMOS input otherwise.
DS30292C-page 8 2001 Microchip Technology Inc.
PIC16F87X TABLE 1-2: PIC16F874 AND PIC16F877 PINOUT DESCRIPTION (CONTINUED)
Pin Name DIP PLCC QFP I/O/P Buffer Description
Pin# Pin# Pin# Type Type
PORTC is a bi-directional I/O port.
RC0/T1OSO/T1CKI 15 16 32 I/O ST RC0 can also be the Timer1 oscillator output or a
Timer1 clock input.
RC1/T1OSI/CCP2 16 18 35 I/O ST RC1 can also be the Timer1 oscillator input or
Capture2 input/Compare2 output/PWM2 output.
RC2/CCP1 17 19 36 I/O ST RC2 can also be the Capture1 input/Compare1
output/PWM1 output.
RC3/SCK/SCL 18 20 37 I/O ST RC3 can also be the synchronous serial clock input/
output for both SPI and I2
C modes.
RC4/SDI/SDA 23 25 42 I/O ST RC4 can also be the SPI Data In (SPI mode) or
data I/O (I2
C mode).
RC5/SDO 24 26 43 I/O ST RC5 can also be the SPI Data Out (SPI mode).
RC6/TX/CK 25 27 44 I/O ST RC6 can also be the USART Asynchronous Transmit
or Synchronous Clock.
RC7/RX/DT 26 29 1 I/O ST RC7 can also be the USART Asynchronous Receive
or Synchronous Data.
PORTD is a bi-directional I/O port or parallel slave port
when interfacing to a microprocessor bus.
RD0/PSP0 19 21 38 I/O ST/TTL(3)
RD1/PSP1 20 22 39 I/O ST/TTL(3)
RD2/PSP2 21 23 40 I/O ST/TTL(3)
RD3/PSP3 22 24 41 I/O ST/TTL(3)
RD4/PSP4 27 30 2 I/O ST/TTL(3)
RD5/PSP5 28 31 3 I/O ST/TTL(3)
RD6/PSP6 29 32 4 I/O ST/TTL(3)
RD7/PSP7 30 33 5 I/O ST/TTL(3)
PORTE is a bi-directional I/O port.
RE0/RD/AN5 8 9 25 I/O ST/TTL(3)
RE0 can also be read control for the parallel slave
port, or analog input5.
RE1/WR/AN6 9 10 26 I/O ST/TTL(3)
RE1 can also be write control for the parallel slave
port, or analog input6.
RE2/CS/AN7 10 11 27 I/O ST/TTL(3)
RE2 can also be select control for the parallel slave
port, or analog input7.
VSS 12,31 13,34 6,29 P — Ground reference for logic and I/O pins.
VDD 11,32 12,35 7,28 P — Positive supply for logic and I/O pins.
NC — 1,17,28, 12,13, — These pins are not internally connected. These pins
40 33,34 should be left unconnected.
Legend: I = input O = output I/O = input/output P = power — = Not used TTL = TTL input ST = Schmitt Trigger input Note 1: This buffer is a Schmitt Trigger input when configured as an external interrupt.
2: This buffer is a Schmitt Trigger input when used in Serial Programming mode.
3: This buffer is a Schmitt Trigger input when configured as general purpose I/O and a TTL input when used in the Parallel Slave Port mode (for interfacing to a microprocessor bus).
4: This buffer is a Schmitt Trigger input when configured in RC oscillator mode and a CMOS input otherwise.
2001 Microchip Technology Inc. DS30292C-page 9
2.0 MEMORY ORGANIZATION 2.1 Program Memory Organization
There are three memory blocks in each of the
PIC16F87X MCUs. The Program Memory and Data
Memory have separate buses so that concurrent
access can occur and is detailed in this section. The
EEPROM data memory block is detailed in Section
4.0. Additional information on device memory may be
found in the PICmicro Mid-Range Reference Manual,
(DS33023).
FIGURE 2-1: PIC16F877/876 PROGRAM
MEMORY MAP AND
STACK
PC<12:0>
CALL, RETURN 13
RETFIE, RETLW
Stack Level 1
Stack Level 2
Stack Level 8
RESET Vector 0000h
Interrupt Vector 0004h
0005h
Page 0
07FFh
0800h
Page 1
On-Chip
0FFFh Program
1000h
Memory
Page 2
17FFh
1800h
Page 3
1FFFh
The PIC16F87X devices have a 13-bit program
counter capable of addressing an 8K x 14 program
memory space. The PIC16F877/876 devices have 8K
x 14 words of FLASH program memory, and the
PIC16F873/874 devices have 4K x 14. Accessing a
location above the physically implemented address
will cause a wraparound. The RESET vector is at 0000h and the interrupt vector is at 0004h.
FIGURE 2-2: PIC16F874/873 PROGRAM
MEMORY MAP AND
STACK
PC<12:0>
CALL, RETURN 13
RETFIE, RETLW
Stack Level 1
Stack Level 2
Stack Level 8
RESET Vector 0000h
Interrupt Vector 0004h
0005h
Page 0
On-Chip 07FFh
Program
0800h
Memory
Page 1
0FFFh
1000h
1FFFh
2001 Microchip Technology Inc. DS30292C-page 11
PIC16F87X
2.2.2 SPECIAL FUNCTION REGISTERS The Special Function Registers are registers used by
the CPU and peripheral modules for controlling the desired operation of the device. These registers are implemented as static RAM. A list of these registers is
given in Table 2-1.
The Special Function Registers can be classified into two sets: core (CPU) and peripheral. Those registers
associated with the core functions are described in
detail in this section. Those related to the operation of the peripheral features are described in detail in the
peripheral features section.
TABLE 2-1: SPECIAL FUNCTION REGISTER SUMMARY Value on: Details
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 POR, on BOR page:
Bank 0
00h(3) INDF Addressing this location uses contents of FSR to address data memory (not a physical register) 0000 0000 27
01h TMR0 Timer0 Module Register xxxx xxxx 47 02h
(3) PCL Program Counter (PC) Least Significant Byte 0000 0000 26 03h
(3) STATUS IRP RP1 RP0 TO PD Z DC C 0001 1xxx 18 04h(3) FSR Indirect Data Memory Address Pointer xxxx xxxx 27 05h PORTA — — PORTA Data Latch when written: PORTA pins when read --0x 0000 29 06h PORTB PORTB Data Latch when written: PORTB pins when read xxxx xxxx 31 07h PORTC PORTC Data Latch when written: PORTC pins when read xxxx xxxx 33 08h
(4) PORTD PORTD Data Latch when written: PORTD pins when read xxxx xxxx 35 09h
(4) PORTE — — — — — RE2 RE1 RE0 ---- -xxx 36 0Ah(1,3) PCLATH — — — Write Buffer for the upper 5 bits of the Program Counter ---0 0000 26 0Bh
(3) INTCON GIE PEIE T0IE INTE RBIE T0IF INTF RBIF 0000 000x 20 0Ch PIR1 PSPIF
(3) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 22 0Dh PIR2 — (5) — EEIF BCLIF — — CCP2IF -r-0 0--0 24 0Eh TMR1L Holding register for the Least Significant Byte of the 16-bit TMR1 Register xxxx xxxx 52 0Fh TMR1H Holding register for the Most Significant Byte of the 16-bit TMR1 Register xxxx xxxx 52 10h T1CON — — T1CKPS1 T1CKPS0 T1OSCEN T1SYNC TMR1CS TMR1ON --00 0000 51 11h TMR2 Timer2 Module Register 0000 0000 55 12h T2CON — TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 -000 0000 55 13h SSPBUF Synchronous Serial Port Receive Buffer/Transmit Register xxxx xxxx 70, 73 14h SSPCON WCOL SSPOV SSPEN CKP SSPM3 SSPM2 SSPM1 SSPM0 0000 0000 67 15h CCPR1L Capture/Compare/PWM Register1 (LSB) xxxx xxxx 57 16h CCPR1H Capture/Compare/PWM Register1 (MSB) xxxx xxxx 57 17h CCP1CON — — CCP1X CCP1Y CCP1M3 CCP1M2 CCP1M1 CCP1M0 --00 0000 58 18h RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 96 19h TXREG USART Transmit Data Register 0000 0000 99 1Ah RCREG USART Receive Data Register 0000 0000 101 1Bh CCPR2L Capture/Compare/PWM Register2 (LSB) xxxx xxxx 57 1Ch CCPR2H Capture/Compare/PWM Register2 (MSB) xxxx xxxx 57 1Dh CCP2CON — — CCP2X CCP2Y CCP2M3 CCP2M2 CCP2M1 CCP2M0 --00 0000 58 1Eh ADRESH A/D Result Register High Byte xxxx xxxx 116 1Fh ADCON0 ADCS1 ADCS0 CHS2 CHS1 CHS0 GO/DONE — ADON 0000 00-0 111 Legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as '0', r = reserved.
Shaded locations are unimplemented, read as „0‟. Note 1: The upper byte of the program counter is not directly accessible. PCLATH is a holding register for the PC<12:8> whose
contents are transferred to the upper byte of the program counter. 2: Bits PSPIE and PSPIF are reserved on PIC16F873/876 devices; always maintain these bits clear. 3: These registers can be addressed from any bank. 4: PORTD, PORTE, TRISD, and TRISE are not physically implemented on PIC16F873/876 devices; read as „0‟. 5: PIR2<6> and PIE2<6> are reserved on these devices; always maintain these bits clear.
2001 Microchip Technology Inc. DS30292C-page 15