38.3.1 Configuring the Analog Port Pins
The ANSELx registers for the I/O ports associated with the analog inputs are used to configure the corresponding pin as an analog or a digital pin. A pin is configured as an analog input when the corresponding ANSELx bit = ‘1
’. When the ANSELx bit = ‘0
’, the pin is set to digital control. The ANSELx registers are set when the device comes out of Reset, causing the ADC input pins to be configured as analog inputs by default.
The TRISx registers control the digital function of the port pins. The port pins that are required as analog inputs must have their corresponding bit set in the specific TRISx register, configuring the pin as an input. If the I/O pin associated with an ADC input is configured as an output by clearing the TRISx bit, the port’s digital output level (VOH or VOL) is converted. After a device Reset, all of the TRISx bits are set. For more information on port pin configuration, see I/O Ports and Peripheral Pin Select (PPS) from Related Links.
0
’ when the PORT latch is read. Analog levels on any pin that is defined as a digital input but not configured as an analog input, may cause the input buffer to consume the current that exceeds the device specification.