Академический Документы
Профессиональный Документы
Культура Документы
14.0
14.1
14.2
FIGURE 14-1:
CDAFVR<1:0>
FVREN
FVRRDY
2
X1
X2
X4
FVR BUFFER1
(To ADC Module)
X1
X2
X4
FVR BUFFER2
(To Comparators, DAC)
+
_
1.024V Fixed
Reference
Preliminary
DS41391B-page 135
PIC16F/LF1826/27
REGISTER 14-1:
R/W-0/0
R-q/q
R/W-0/0
R/W-0/0
R/W-0/0
R/W-0/0
R/W-0/0
R/W-0/0
FVREN
FVRRDY(1)
Reserved
Reserved
CDAFVR1
CDAFVR0
ADFVR1
ADFVR0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
u = Bit is unchanged
x = Bit is unknown
1 = Bit is set
0 = Bit is cleared
bit 7
bit 6
bit 5-4
bit 3-2
bit 1-0
Note 1:
2:
TABLE 14-1:
Name
FVRCON
Legend:
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Register
on page
FVREN
FVRRDY
Reserved
Reserved
CDAFVR1
CDAFVR0
ADFVR1
ADFVR0
136
DS41391B-page 136
Preliminary
PIC16F/LF1826/27
15.0
ANALOG-TO-DIGITAL
CONVERTER (ADC) MODULE
FIGURE 15-1:
VREF-
ADNREF = 0
VDD
VSS
ADPREF = 0X
ADPREF = 11
VREF+
AN0
00000
AN1
00001
AN2
00010
AN3
00011
AN4
00100
AN5
00101
AN6
00110
AN7
00111
AN8
01000
AN9
01001
AN10
01010
AN11
01011
DAC
11110
FVR Buffer1
11111
ADPREF = 10
ADC
10
GO/DONE
ADFM
0 = Left Justify
1 = Right Justify
16
ADON
VSS
ADRESH
ADRESL
CHS<4:0>
Note:
Preliminary
DS41391B-page 137
PIC16F/LF1826/27
15.1
15.1.4
ADC Configuration
Port configuration
Channel selection
ADC voltage reference selection
ADC conversion clock source
Interrupt control
Result formatting
15.1.1
15.1.2
The source of the conversion clock is software selectable via the ADCS bits of the ADCON1 register. There
are seven possible clock options:
PORT CONFIGURATION
FOSC/2
FOSC/4
FOSC/8
FOSC/16
FOSC/32
FOSC/64
FRC (dedicated internal oscillator)
CHANNEL SELECTION
CONVERSION CLOCK
15.1.3
DS41391B-page 138
Preliminary
PIC16F/LF1826/27
TABLE 15-1:
ADCS<2:0>
32 MHz
20 MHz
16 MHz
8 MHz
4 MHz
1 MHz
Fosc/2
000
62.5ns(2)
100 ns(2)
125 ns(2)
250 ns(2)
500 ns(2)
2.0 s
Fosc/4
100
125 ns
(2)
(2)
(2)
(2)
1.0 s
4.0 s
Fosc/8
001
0.5 s(2)
400 ns(2)
0.5 s(2)
1.0 s
2.0 s
8.0 s(3)
Fosc/16
101
800 ns
800 ns
1.0 s
2.0 s
4.0 s
16.0 s(3)
Fosc/32
010
1.0 s
1.6 s
2.0 s
4.0 s
8.0 s(3)
32.0 s(3)
s(3)
64.0 s(3)
Fosc/64
FRC
Legend:
Note 1:
2:
3:
4:
2.0 s
110
x11
1.0-6.0 s
200 ns
3.2 s
(1,4)
1.0-6.0 s
250 ns
4.0 s
(1,4)
1.0-6.0 s
500 ns
8.0
(1,4)
s(3)
1.0-6.0 s
(1,4)
16.0
1.0-6.0 s
(1,4)
1.0-6.0 s(1,4)
FIGURE 15-2:
TCY - TAD TAD1 TAD2 TAD3 TAD4 TAD5 TAD6 TAD7 TAD8 TAD9 TAD10 TAD11
b4
b1
b0
b6
b7
b2
b9
b8
b3
b5
Conversion starts
Holding capacitor is disconnected from analog input (typically 100 ns)
Set GO bit
On the following cycle:
ADRESH:ADRESL is loaded, GO bit is cleared,
ADIF bit is set, holding capacitor is connected to analog input.
Preliminary
DS41391B-page 139
PIC16F/LF1826/27
15.1.5
INTERRUPTS
15.1.6
RESULT FORMATTING
FIGURE 15-3:
(ADFM = 0)
ADRESL
MSB
LSB
bit 7
bit 0
bit 7
Unimplemented: Read as 0
MSB
bit 7
LSB
bit 0
Unimplemented: Read as 0
DS41391B-page 140
bit 0
bit 7
bit 0
10-bit A/D Result
Preliminary
PIC16F/LF1826/27
15.2
15.2.1
15.2.4
ADC Operation
STARTING A CONVERSION
15.2.2
COMPLETION OF A CONVERSION
15.2.3
TERMINATING A CONVERSION
15.2.5
TABLE 15-2:
Device
CCPx/ECCPx
PIC16F/LF1826
ECCP1
PIC16F/LF1827
CCP4
Preliminary
DS41391B-page 141
PIC16F/LF1826/27
15.2.6
EXAMPLE 15-1:
2.
3.
4.
5.
6.
7.
8.
Configure Port:
Disable pin output driver (Refer to the TRIS
register)
Configure pin as analog (Refer to the ANSEL
register)
Configure the ADC module:
Select ADC conversion clock
Configure voltage reference
Select ADC input channel
Turn on ADC module
Configure ADC interrupt (optional):
Clear ADC interrupt flag
Enable ADC interrupt
Enable peripheral interrupt
Enable global interrupt(1)
Wait the required acquisition time(2).
Start conversion by setting the GO/DONE bit.
Wait for ADC conversion to complete by one of
the following:
Polling the GO/DONE bit
Waiting for the ADC interrupt (interrupts
enabled)
Read ADC Result.
Clear the ADC interrupt flag (required if interrupt
is enabled).
A/D CONVERSION
DS41391B-page 142
Preliminary
PIC16F/LF1826/27
15.2.7
REGISTER 15-1:
U-0
R/W-0/0
R/W-0/0
R/W-0/0
R/W-0/0
R/W-0/0
R/W-0/0
R/W-0/0
CHS4
CHS3
CHS2
CHS1
CHS0
GO/DONE
ADON
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
u = Bit is unchanged
x = Bit is unknown
1 = Bit is set
0 = Bit is cleared
bit 7
Unimplemented: Read as 0
bit 6-2
bit 1
bit 0
Note 1:
2:
See Section 16.0 Digital-to-Analog Converter (DAC) Module for more information.
See Section 14.0 Fixed Voltage Reference (FVR) for more information.
Preliminary
DS41391B-page 143
PIC16F/LF1826/27
REGISTER 15-2:
R/W-0/0
R/W-0/0
R/W-0/0
R/W-0/0
U-0
R/W-0/0
R/W-0/0
R/W-0/0
ADFM
ADCS2
ADCS1
ADCS0
ADNREF
ADPREF1
ADPREF0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
u = Bit is unchanged
x = Bit is unknown
1 = Bit is set
0 = Bit is cleared
bit 7
bit 6-4
bit 3
Unimplemented: Read as 0
bit 2
bit 1-0
DS41391B-page 144
Preliminary
PIC16F/LF1826/27
REGISTER 15-3:
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
ADRES9
ADRES8
ADRES7
ADRES6
ADRES5
ADRES4
ADRES3
ADRES2
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
u = Bit is unchanged
x = Bit is unknown
1 = Bit is set
0 = Bit is cleared
bit 7-0
REGISTER 15-4:
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
ADRES1
ADRES0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
u = Bit is unchanged
x = Bit is unknown
1 = Bit is set
0 = Bit is cleared
bit 7-6
bit 5-0
Preliminary
DS41391B-page 145
PIC16F/LF1826/27
REGISTER 15-5:
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
ADRES9
ADRES8
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
u = Bit is unchanged
x = Bit is unknown
1 = Bit is set
0 = Bit is cleared
bit 7-2
bit 1-0
REGISTER 15-6:
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
R/W-x/u
ADRES7
ADRES6
ADRES5
ADRES4
ADRES3
ADRES2
ADRES1
ADRES0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
u = Bit is unchanged
x = Bit is unknown
1 = Bit is set
0 = Bit is cleared
bit 7-0
DS41391B-page 146
Preliminary
PIC16F/LF1826/27
15.3
EQUATION 15-1:
Assumptions:
T ACQ = Amplifier Settling Time + Hold Capacitor Charging Time + Temperature Coefficient
= T AMP + T C + T COFF
= 2s + T C + [ ( Temperature - 25C ) ( 0.05s/C ) ]
The value for TC can be approximated with the following equations:
1
= V CHOLD
V AP P LI ED 1 -------------------------n+1
(2
)1
TC
----------
RC
V AP P LI ED 1 e = V CHOLD
Tc
---------
1
RC
;combining [1] and [2]
V AP P LI ED 1 e = V A PP LIE D 1 -------------------------n+1
(2
)1
T C = C HOLD ( R IC + R SS + R S ) ln(1/511)
= 10pF ( 1k + 7k + 10k ) ln(0.001957)
= 1.12 s
Therefore:
T A CQ = 2s + 1.12s + [ ( 50C- 25C ) ( 0.05S /C ) ]
= 4.42s
Note 1: The reference voltage (VREF) has no effect on the equation, since it cancels itself out.
2: The charge holding capacitor (CHOLD) is not discharged after each conversion.
3: The maximum recommended impedance for analog sources is 10 k. This is required to meet the pin
leakage specification.
Preliminary
DS41391B-page 147