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
Figure 3-1. SDADC Configurations in MPLAB Code Configurator
The above default configurations can be changed in the MPLAB Code Configurator, by following these steps:
  1. In MPLAB X IDE, navigate to the Tools > Embedded > MPLAB Code Configurator v5.
  2. 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
  3. In the Project Graph, to change the Interval Voltage Reference value, click and expand SUPC.
  4. 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
  5. 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
  6. In the plib_sdadc.c file generated for polling mode, the bool SDADC_ConversionResultIsReady( void ) function will be added. This API returns a Boolean value as a status to confirm if the results are ready.
  7. 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.
  8. Save the configurations and generate the code by selecting Resource Management [MCC] > Project Resources > Generate Code.
  9. Update the plib files with appropriate changes taken into consideration.