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

1

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

add_adc.png

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

adc_configuration_options.png

Configure ADC Pin

3

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

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

supc_configuration.png



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.