Step 3.1: Configure Analog-to-Digital Converter (ADC) Peripheral Library (PLIB)
Configure ADC Peripheral
2
Select the ADC Peripheral Library and configure it to sample and convert the light sensor input. The ADC is configured in Software Trigger mode to convert the samples. The internal reference voltage is fed as a reference voltage.
a
Select Prescaler: Peripheral clock divided by 8 divides the ADC input clock with the configured pre-scaler value and provides more sampling time (CLKADC = 48 MHz/8 = 6 MHz).
b
Select Reference: Internal Reference Voltage.
c
Select Conversion Trigger: SW Trigger.
e
Select Positive Input: ADC AIN3 Pin (the light sensor is connected to AIN3 pin of ADC).
f
Select Result Resolution: 12-bit result (ADC conversion value range from 0 to 4096).
Configure ADC Pin
Step 3.2: Configure Supply Controller (SUPC)
In this step, under the SUPC VREF configuration, the reference voltage output is enabled, which is used by ADC as a reference voltage.