PIC16F87X
11.0
ANALOG-TO-DIGITAL
CONVERTER (A/D) MODULE
The A/D module has four registers. These registers
are:
•
•
•
•
A/D Result High Register (ADRESH)
A/D Result Low Register (ADRESL)
A/D Control Register0 (ADCON0)
A/D Control Register1 (ADCON1)
The Analog-to-Digital (A/D) Converter module has five
inputs for the 28-pin devices and eight for the other
devices.
The analog input charges a sample and hold capacitor.
The output of the sample and hold capacitor is the input
into the converter. The converter then generates a dig-
ital result of this analog level via successive approxima-
tion. The A/D conversion of the analog input signal
results in a corresponding 10-bit digital number. The
A/D module has high and low voltage reference input
that is software selectable to some combination of V
DD
,
V
SS
, RA2, or RA3.
The A/D converter has a unique feature of being able
to operate while the device is in SLEEP mode. To oper-
ate in SLEEP, the A/D clock must be derived from the
A/D’s internal RC oscillator.
The ADCON0 register, shown in Register 11-1, con-
trols the operation of the A/D module. The ADCON1
register, shown in Register 11-2, configures the func-
tions of the port pins. The port pins can be configured
as analog inputs (RA3 can also be the voltage refer-
ence), or as digital I/O.
Additional information on using the A/D module can be
found in the PICmicro™ Mid-Range MCU Family Ref-
erence Manual (DS33023).
REGISTER 11-1:
ADCON0 REGISTER (ADDRESS: 1Fh)
R/W-0
ADCS1
bit 7
R/W-0
ADCS0
R/W-0
CHS2
R/W-0
CHS1
R/W-0
CHS0
R/W-0
GO/DONE
U-0
—
R/W-0
ADON
bit 0
bit 7-6
ADCS1:ADCS0:
A/D Conversion Clock Select bits
00
= F
OSC
/2
01
= F
OSC
/8
10
= F
OSC
/32
11
= F
RC
(clock derived from the internal A/D module RC oscillator)
CHS2:CHS0:
Analog Channel Select bits
000
= channel 0, (RA0/AN0)
001
= channel 1, (RA1/AN1)
010
= channel 2, (RA2/AN2)
011
= channel 3, (RA3/AN3)
100
= channel 4, (RA5/AN4)
101
= channel 5, (RE0/AN5)
(1)
110
= channel 6, (RE1/AN6)
(1)
111
= channel 7, (RE2/AN7)
(1)
GO/DONE:
A/D Conversion Status bit
If ADON = 1:
1
= A/D conversion in progress (setting this bit starts the A/D conversion)
0
= A/D conversion not in progress (this bit is automatically cleared by hardware when the A/D
conversion is complete)
Unimplemented:
Read as '0'
ADON:
A/D On bit
1
= A/D converter module is operating
0
= A/D converter module is shut-off and consumes no operating current
Note 1:
These channels are not available on PIC16F873/876 devices.
Legend:
R = Readable bit
- n = Value at POR
W = Writable bit
’1’ = Bit is set
U = Unimplemented bit, read as ‘0’
’0’ = Bit is cleared
x = Bit is unknown
bit 5-3
bit 2
bit 1
bit 0
2001 Microchip Technology Inc.
DS30292C-page 111