ADC Peripheral Library

This library allows you to:

  • Initialize the ADC module:
    • Enable/disable 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 number of samples in 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, terminate conversion process
    • Configure channel pair, trigger source
    • Configure interrupt control and conversion order
  • Format the result buffer
    • Select how conversion results are stored in buffer
    • Select the result format and assign result sign
    • Select the 10-bit or 12-bit mode

Example Library Functions

Description Associated Functions
• Voltage reference source
• Enable/disable ADC
ADC conversion clock PLIB_ADC_ConversionClockSet (MY_ADC_INSTANCE, 80000000, 320000000)
• Input channel selection
• MUX A, B inputs,
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 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 driver ADC Module index numbers macro defined in drv_adc.h. These provide ADC driver 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 >
© 2016 Microchip Technology, Inc.
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.