ADC Peripheral Library (PLIB) for Harmony v2

This library allows you to:

  • Initialize the ADC module:
    • Enable/disable the ADC module
    • Select voltage reference sources
    • Select input channel and configure the MUX inputs
    • Select scan mode; positive and negative analog input channel
    • Select conversion clock
    • Set the number of the S&H channels to be used
  • Control the ADC sampling process:
    • Enable/disable sampling
    • Select manual or auto-sampling
    • Select conversion trigger and sampling time
    • Select the number of readings per interrupt
    • Select the number of samples in the DMA buffer for each ADC module and select how the DMA will access the ADC buffers
  • Control the ADC conversion process:
    • Select conversion trigger and sampling time
    • Start and terminate conversion process
    • Configure channel pair and trigger source
    • Configure interrupt control and conversion order
  • Format the result buffer:
    • Select how conversion results are stored in the buffer
    • Select the result format and assign the result sign
    • Select the mode: 10-bit or 2-bit

Example Library Functions

Description Associated Functions
Voltage reference source; enable/disable ADC PLIB_ADC_VoltageReferenceSelect (MY_ADC_INSTANCE, ADC_REFERENCE_VREFPLUS_TO_AVSS)
ADC conversion clock PLIB_ADC_ConversionClockSet (MY_ADC_INSTANCE, 80000000, 320000000)
Input channel selection; MUX A and B inputs PLIB_ADC_InputSelectPositive (MY_ADC_INSTANCE, ADC_INPUT_POSITIVE_AN2)
Determine how sampling will occur PLIB_ADC_SampleAcquisitionTimeSet (MY_ADC_INSTANCE, 2)
Manual or Auto-Sampling PLIB_ADC_SampleAutoStartEnable (MY_ADC_INSTANCE)
PLIB_ADC_SampleAutoStartDisable (MY_ADC_INSTANCE)
Conversion trigger, sampling time PLIB_ADC_ConversionStart (MY_ADC_INSTANCE)
Conversion results buffer PLIB_ADC_ResultBufferModeSelect (MY_ADC_INSTANCE,ADC_BUFFER_MODE_TWO_8WORD_BUFFERS)
Result sign format PLIB_ADC_ResultFormatSelect (MY_ADC_INSTANCE, ADC_RESULT_FORMAT)
Number of readings per interrupt PLIB_ADC_SamplesPerInterruptSelect (MY_ADC_INSTANCE, ADC_16SAMPLES_PER_INTERRUPT)
Number of samples in the DMA buffer for each ADC; how the DMA will access the ADC buffers PLIB_ADC_DMAEnable (MY_ADC_INSTANCE)
10-bit or 12-bit mode PLIB_ADC_ResultSizeSelect (MY_ADC_INSTANCE, ADC_RESULT_SIZE_10_BITS)
Misc. ADC functions:
• Asynchronous sampling selection
• Conversion order selection
• Global software trigger control
PLIB_ADC_AsynchronousDedicatedSamplingEnable (MY_ADC_INSTANCE) PLIB_ADC_AsynchronousDedicatedSamplingDisable (MY_ADC_INSTANCE) PLIB_ADC_GlobalSoftwareTriggerSet (MY_ADC_INSTANCE)

NOTE: MY_ADC_INSTANCE is the ADC instance selected for use by the application developer. E.g.,
int main ( )

DRV_ADC_INDEX is the ADC module's index number macro, defined in the DRV_ADC header file. These provide the ADC index definitions. E.g.,
#define DRV_ADC_INDEX_0 0

Important notes on using this library:

  • The MPLAB® Harmony PLIB Overview provides more details and background on PLIB usage
  • Peripheral Libraries are only supported for internal (on board) microcontroller peripherals. External peripherals are always connected to the microcontroller through one or more internal peripheral interfaces and therefore, do not require peripheral library support.

 Learn More

Harmony ADC Tutorial
Learn more >
Example Code and Projects
Learn more >
Entire ADC PLIB Interface
Learn more >
ADC Hardware Description
Learn more >
© 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.