41.2.6 ADC Conversion Procedure (Basic Mode)
This is an example procedure for using the ADC to perform an Analog-to-Digital Conversion:
- Configure Port:
- Disable pin output driver (refer to the TRISx register)
- Configure pin as analog (refer to the ANSELx register)
- Configure the ADC module:
- Configure ADC interrupt (optional):
- Clear ADC interrupt flag
- Enable ADC interrupt
- Enable global interrupt (GIE bit)(1)
- If ADACQ !=
0
, software must wait the required acquisition time(2). - Start conversion by setting the GO bit.
- Wait for ADC conversion to complete by
one of the following:
- Polling the GO bit
- Waiting for the ADC interrupt (if interrupt is enabled)
- Read ADC Result.
- Clear the ADC interrupt flag (if interrupt is enabled).
Note:
- With global interrupts disabled (GIE
=
0
), the device will wake from Sleep, but will not enter an Interrupt Service Routine. - Refer to the ADC Acquisition Requirements section for more details.