Migrating ASF SAM C21 Application to MPLAB® Harmony v3 PIC32CM MC: Step 3

Last modified by Microchip on 2023/11/09 09:07


Configure the Analog-to-Digital Converter (ADC) Peripheral Library (PLIB)

Under the Available Components tab, expand Peripherals > ADC. Select and double click on ADC0 to add the ADC module to the project graph.

Available Components and Project Graph pane​​​

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.

  • 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).
  • Select Reference: Internal Reference Voltage.
  • Select Conversion Trigger: SW Trigger.
  • Select Positive Input: ADC AIN3 Pin (the light sensor is connected to AIN3 pin of ADC).
  • Select Result Resolution: 12-bit result (ADC conversion value range from 0 to 4096).

adc configuration options​​​

Configure the ADC Pin.  In the MPLAB® Harmony Configurator (MHC), select the Pin Settings tab and then scroll-down to PORT pin PB09 in Pin ID column and configure this pin as ADC0_AIN3.

adc pin settings window

This completes the configuration of the ADC PLIB. The ADC is configured to start the conversion on a software event trigger.

Back to Top

Configure Supply Controller (SUPC)

Under the SUPC VREF configuration, check the Enable Voltage Reference Output box, which is used by ADC as a reference voltage.

SUPC Configuration Options pane


Back to Top