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

Step 3.1: Configure Analog-to-Digital Converter (ADC) Peripheral Library (PLIB)

Configure ADC Peripheral


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



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).


Configure 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.


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

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.

Configure SUPC


Next Step >

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.