3.1 MPLAB Code Configurator SDADC Configurations
The default configurations made in the MPLAB Code Configurator for the SDADC peripheral are as follows, and it is shown in the following figure.
- Over Sampling Ratio = 64
- Internal Bandgap Reference = 4.096V
- Interrupts Enabled
The above default configurations can be changed in the MPLAB Code Configurator, by
following these steps:
- In MPLAB X IDE, navigate to the Tools > Embedded > MPLAB Code Configurator v5.
- To change the Over Sampling
Ratio, click and expand SDADC and then select the desired value from the
Over Sampling Ratio drop-down list as shown in the following figure.
Figure 3-2. OSR Drop-Down List in MPLAB Code Configurator - In the Project Graph, to change the Interval Voltage Reference value, click and expand SUPC.
- Select the desired voltage
reference value from the Select Reference Voltage Level drop-down list as
shown in the following figure.
Figure 3-3. Reference Voltage Level Drop-Down List in MPLAB Code Configurator - Click and expand SDADC,
and then clear Enable Result Ready Interrupt. Note: The interrupt can be disabled to work with polling method.
Figure 3-4. SDADC Result Ready Interrupt Disabled in MPLAB Code Configurator - In the
plib_sdadc.c
file generated for polling mode, thebool SDADC_ConversionResultIsReady( void )
function will be added. This API returns a Boolean value as a status to confirm if the results are ready. - In the
main.c
file, check for this status and proceed to read when the results are ready. Refer to the polling mode project, where this has been implemented. - Save the configurations and generate the code by selecting Resource Management [MCC] > Project Resources > Generate Code.
- Update the
plib
files with appropriate changes taken into consideration.