English
Language : 

PIC18F25K20T-ISS Datasheet, PDF (136/456 Pages) Microchip Technology – 28/40/44-Pin Flash Microcontrollers with nanoWatt XLP Technology
PIC18F2XK20/4XK20
10.7 Port Analog Control
Some port pins are multiplexed with analog functions
such as the Analog-to-Digital Converter and compara-
tors. When these I/O pins are to be used as analog
inputs it is necessary to disable the digital input buffer
to avoid excessive current caused by improper biasing
of the digital input. Individual control of the digital input
buffers on pins which share analog functions is pro-
vided by the ANSEL and ANSELH registers. Setting an
ANSx bit high will disable the associated digital input
buffer and cause all reads of that pin to return ‘0’ while
allowing analog functions of that pin to operate
correctly.
The state of the ANSx bits has no affect on digital
output functions. A pin with the associated TRISx bit
clear and ANSx bit set will still operate as a digital
output but the input mode will be analog. This can
cause unexpected behavior when performing read-
modify-write operations on the affected port.
REGISTER 10-2: ANSEL: ANALOG SELECT REGISTER 1
R/W-1
ANS7(1)
bit 7
R/W-1
ANS6(1)
R/W-1
ANS5(1)
R/W-1
ANS4
R/W-1
ANS3
R/W-1
ANS2
R/W-1
ANS1
R/W-1
ANS0
bit 0
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 7
ANS7: RE2 Analog Select Control bit(1)
1 = Digital input buffer of RE2 is disabled
0 = Digital input buffer of RE2 is enabled
bit 6
ANS6: RE1 Analog Select Control bit(1)
1 = Digital input buffer of RE1 is disabled
0 = Digital input buffer of RE1 is enabled
bit 5
ANS5: RE0 Analog Select Control bit(1)
1 = Digital input buffer of RE0 is disabled
0 = Digital input buffer of RE0 is enabled
bit 4
ANS4: RA5 Analog Select Control bit
1 = Digital input buffer of RA5 is disabled
0 = Digital input buffer of RA5 is enabled
bit 3
ANS3: RA3 Analog Select Control bit
1 = Digital input buffer of RA3 is disabled
0 = Digital input buffer of RA3 is enabled
bit 2
ANS2: RA2 Analog Select Control bit
1 = Digital input buffer of RA2 is disabled
0 = Digital input buffer of RA2 is enabled
bit 1
ANS1: RA1 Analog Select Control bit
1 = Digital input buffer of RA1 is disabled
0 = Digital input buffer of RA1 is enabled
bit 0
ANS0: RA0 Analog Select Control bit
1 = Digital input buffer of RA0 is disabled
0 = Digital input buffer of RA0 is enabled
Note 1: These bits are not implemented on PIC18F2XK20 devices.
DS41303G-page 136
 2010 Microchip Technology Inc.