ADC Peripheral Library Interface

Detailed descriptions for this library can be found in the MPLAB® Harmony Documentation ( located in the <harmony install directory>/doc folder)

Interface Header File

The interface to the ADC library is defined in the plib_adc.h header file, which is included by the peripheral.h peripheral library header file. Any C language source (.c) file that uses the ADC library must include peripheral.h.

ADC Library Interface

The library interface routines are divided into various sub-sections, which address the overall operation of the ADC Peripheral Library. Below is a summary of the library interface and its descriptions.

Library Interface Section Description
General Configuration • Voltage reference selection (positive/negative)
• Channel group selection
• Positive/negative channel selection
• Add/remove channels for scan
• Enabling/disabling the ADC module
• Enabling/disabling the calibration
• Stop in Idle enable/disable
• Internal reference channel enable/disable
MUX Selection and Channel Scan • Channel 0 positive/negative input selection for MUX A/MUX B
• Channels 1, 2, 3 positive/negative input selection for MUX A/MUX B
• MUX A scan enable/disable
Sample and Hold Control Logic • Sampling start/stop, status
• Enabling/disabling of sample auto start
• Acquisition/auto-sample time selection
• Sample max/min value
• Sample mode control for Alternate Input mode, Simultaneous, Sequential, etc.
• Sample per interrupt selection
Conversion Control Logic • Conversion start/status
• Conversion clock selection set/get
• Conversion clock source selection
• Conversion trigger source selection
• Conversion stop sequence enable/disable
Output Configuration • Result size selection
• Result format selection
• Result buffer fill status
• Result buffer mode select
• Getting the result sign
• Result 8-bit, 10-bit, or 12-bit
• Result based on the buffer index
DMA Transactions • DMA enable/disable
• DMA address increment rate selection
• Buffer build mode selection
• Buffers per analog input selection
Channel Pairs Control • Pair sample status get/clear function
• Interrupt request control
• Conversion start/status function
• Conversion trigger source selection
Miscellaneous • Early interrupt control through interrupt generation after first or second conversion
• Global software trigger control
• Asynchronous dedicated sampling control
• User's the ADC Interrupt Service Routine (ISR) jump table address setting
• Conversion order selection based on even/odd input
Feature Existence Functions These functions determine whether or not a particular feature is supported by the device.

ADC General Configuration

Function Name Description
PLIB_ADC_Enable ADC module is enabled (turned ON)
PLIB_ADC_Disable ADC module is disabled (turned OFF)
PLIB_ADC_StopInIdleDisable Continue ADC module operation when the device is in Idle mode
PLIB_ADC_StopInIdleEnable Discontinue ADC module operation when device enters Idle mode
PLIB_ADC_VoltageReferenceSelect Voltage reference configuration
PLIB_ADC_CalibrationEnable Calibration is performed on the next ADC conversion
PLIB_ADC_CalibrationDisable Normal ADC module operation (no calibration is performed)
PLIB_ADC_InputSelectPositive Positive analog input channel selection
PLIB_ADC_InputSelectNegative Analog negative channel selection
PLIB_ADC_InputScanMaskAdd Select ADC analog channel for input scan
PLIB_ADC_InputScanMaskRemove Omits ADC analog channel for input scan
PLIB_ADC_InputScanMaskAddExtended Select extended ADC analog channel for input scan
PLIB_ADC_InputScanMaskRemoveExtended Omits extended ADC analog channel for input scan
PLIB_ADC_InternalReferenceChannelEnable Internal reference input is enabled
PLIB_ADC_InternalReferenceChannelDisable Internal reference input is disabled
PLIB_ADC_ChannelGroupSelect Selects channels to be utilized

DMA Transactions

Function Name Description
PLIB_ADC_DMAAddressIncrementSelect Selects the increment rate for the DMA address
PLIB_ADC_DMABufferModeSelect DMA Buffer Build mode
PLIB_ADC_DMADisable Disables the ADC Direct Memory Access (DMA)
PLIB_ADC_DMAEnable Enables the ADC Direct Memory Access (DMA)
PLIB_ADC_DMAInputBufferSelect Selects the number of DMA buffer locations per analog input

Conversion Control Logic

Function Name Description
PLIB_ADC_ConversionStart Starts ADC module manual conversion process
PLIB_ADC_ConversionHasCompleted Provides the conversion completion status of the ADC
PLIB_ADC_ConversionTriggerSourceSelect Selects the conversion trigger source
PLIB_ADC_ConversionStopSequenceEnable Stop conversion sequence (when the first ADC module interrupt is _ generated)
PLIB_ADC_ConversionStopSequenceDisable Normal conversion sequence
PLIB_ADC_ConversionClockSet Sets the ADC module conversion clock
PLIB_ADC_ConversionClockGet Obtains the conversion clock
PLIB_ADC_ConversionClockSourceSelect Selects the ADC module conversion clock source
PLIB_ADC_ConversionTriggerGroupSelect Selects the conversion trigger source group
PLIB_ADC_ConversionOrderSelect Selects the conversion order

Sample and Hold Control Logic

Function Name Description
PLIB_ADC_SampleAutoStartDisable Sampling auto-start is disabled
PLIB_ADC_SampleAutoStartEnable Sampling auto-start is enabled
PLIB_ADC_SampleMaxGet Provides the maximum sample value
PLIB_ADC_SampleMinGet Provides the minimum sample value
PLIB_ADC_SamplesPerInterruptSelect Interrupts at the completion of conversion for each nth sample
PLIB_ADC_SamplingIsActive Provides the ADC sampling status
PLIB_ADC_SamplingModeSelect Enable the selected sampling mode
PLIB_ADC_SamplingStart Sampling is enabled
PLIB_ADC_SamplingStop Holding is enabled
PLIB_ADC_SampleAcquisitionTimeSet Sets the ADC acquisition/auto-sample time in TADs

Channel Pairs Control

Function Name Description
PLIB_ADC_PairConversionIsPending Informs whether conversion is pending or complete
PLIB_ADC_PairConversionStart Start conversion of the requested ADC pair
PLIB_ADC_PairInterruptAfterFirstConversion ADC pair conversion interrupt is generated after the first conversion
PLIB_ADC_PairInterruptAfterSecondConversion ADC pair conversion interrupt is generated after the second conversion
PLIB_ADC_PairInterruptRequestDisable Disable IRQ generation for the ADC pair
PLIB_ADC_PairInterruptRequestEnable Enable IRQ generation for the ADC pair
PLIB_ADC_PairSampleIsAvailable Provides status of the ADC pair sample availability in the buffer
PLIB_ADC_PairSampleStatusClear Clears the ADC pair ready status flag
PLIB_ADC_PairTriggerSourceSelect Selects trigger source for the requested ADC pair

Output Configuration

Function Name Description
PLIB_ADC_ResultBufferModeSelect Selects the result buffer mode
PLIB_ADC_ResultBufferStatusGet Provides the buffer fill
PLIB_ADC_ResultFormatSelect Selects the result format
PLIB_ADC_ResultGet Obtains the ADC sample/result value
PLIB_ADC_ResultGetByIndex Provides the ADC conversion result based on the buffer index
PLIB_ADC_ResultSignGet Obtains the ADC result sign
PLIB_ADC_ResultSizeSelect Selects the ADC module mode/result size

Mux Selection and Channel Scan

Function Name Description
PLIB_ADC_MuxAInputScanDisable Do not scan input selections for CH0+ of MUX A
PLIB_ADC_MuxAInputScanEnable Scan input selections for CH0+ of MUX A
PLIB_ADC_MuxChannel0InputNegativeSelect Channel 0 negative input select for multiplexer
PLIB_ADC_MuxChannel0InputPositiveSelect Channel 0 positive input select for multiplexer setting
PLIB_ADC_MuxChannel123InputNegativeSelect Channel 1, 2, and 3 negative input select
PLIB_ADC_MuxChannel123InputPositiveSelect Channel 1, 2, and 3 positive input select

Miscellaneous

Function Name Description
PLIB_ADC_AsynchronousDedicatedSamplingDisable Disables asynchronous dedicated S&H sampling
PLIB_ADC_AsynchronousDedicatedSamplingEnable Enables asynchronous dedicated S&H sampling
PLIB_ADC_GlobalSoftwareTriggerSet Global software trigger enable/set control
PLIB_ADC_IsrJumpTableBaseAddressGet Gets the base address of the user's ADC Interrupt Service Routine (ISR) jump table
PLIB_ADC_IsrJumpTableBaseAddressSet Sets the base address of the user's ADC Interrupt Service Routine (ISR) jump table

Feature Existence Functions

Function Name Description
PLIB_ADC_ExistsAsynchronousDedicatedSampling Identifies whether the AsynchronousDedicatedSampling feature exists on the ADC module
PLIB_ADC_ExistsCalibrationControl Identifies whether the CalibrationControl feature exists on the ADC module
PLIB_ADC_ExistsChannelGroup Identifies whether the ChannelGroup feature exists on the ADC module
PLIB_ADC_ExistsConversionClock Identifies whether the ConversionClock feature exists on the ADC module
PLIB_ADC_ExistsConversionClockSource Identifies whether the ConversionClockSource feature exists on the
ADC module
PLIB_ADC_ExistsConversionControl Identifies whether the ConversionControl feature exists on the ADC module
PLIB_ADC_ExistsConversionOrder Identifies whether the ConversionOrder feature exists on the ADC module
PLIB_ADC_ExistsConversionStatus Identifies whether the ConversionStatus feature exists on the ADC module
PLIB_ADC_ExistsConversionStopSequenceControl Identifies whether the ConversionStopSequenceControl feature exists on the ADC module
PLIB_ADC_ExistsConversionTriggerGroup Identifies whether the ConversionTriggerGroup feature exists on the ADC module
PLIB_ADC_ExistsConversionTriggerSource Identifies whether the ConversionTriggerSource feature exists on the ADC module
PLIB_ADC_ExistsDMAAddressIncrement Identifies whether the DMAAddressIncrement feature exists on the ADC _ module
PLIB_ADC_ExistsDMABufferMode Identifies whether the DMABufferMode feature exists on the ADC module
PLIB_ADC_ExistsDMABuffersPerAnalogInput Identifies whether the DMABuffersPerInput feature exists on the ADC _ module
PLIB_ADC_ExistsDMAControl Identifies whether the DMAControl feature exists on the ADC module
PLIB_ADC_ExistsEnableControl Identifies whether the EnableControl feature exists on the ADC module
PLIB_ADC_ExistsGlobalSoftwareTrigger Identifies whether the GlobalSoftwareTrigger feature exists on the ADC
module
PLIB_ADC_ExistsInputSelect Identifies whether the InputSelect feature exists on the ADC module
PLIB_ADC_ExistsInternalReferenceChannelControl Identifies whether the InternalReferenceChannelControl feature exists on the ADC module
PLIB_ADC_ExistsISRJumpTableBaseAddress Identifies whether the ISRJumpTableBaseAddress feature exists on the ADC module
PLIB_ADC_ExistsMuxChannel0NegativeInput Identifies whether the MuxChannel0NegativeInput feature exists on the ADC module
PLIB_ADC_ExistsMuxChannel0PositiveInput Identifies whether the MuxChannel0PositiveInput feature exists on the ADC module
PLIB_ADC_ExistsMuxChannel123NegativeInput Identifies whether the MuxChannel123NegativeInput feature exists on the ADC module
PLIB_ADC_ExistsMuxChannel123PositiveInput Identifies whether the MuxChannel123PositiveInput feature exists on the ADC module
PLIB_ADC_ExistsMuxInputScanControl Identifies whether the MuxInputScanControl feature exists on the ADC module
PLIB_ADC_ExistsMuxInputScan Select Identifies whether the MuxInputScanSelect feature exists on the ADC module
PLIB_ADC_ExistsPairConversionControl Identifies whether the PairConversionControl feature exists on the ADCmodule
PLIB_ADC_ExistsPairInterruptOnConversion Identifies whether the PairInterruptOnConversion feature exists on the ADC module
PLIB_ADC_ExistsPairInterruptRequest Identifies whether the PairInterruptRequest feature exists on the ADC module
PLIB_ADC_ExistsPairSampleStatus Identifies whether the PairSampleStatus feature exists on the ADC module
PLIB_ADC_ExistsPairTriggerSource Identifies whether the PairTriggerSource feature exists on the ADC module
PLIB_ADC_ExistsResultBufferFillStatus Identifies whether the ResultBufferFillStatus feature exists on the ADC module
PLIB_ADC_ExistsResultBufferMode Identifies whether the ResultBufferMode feature exists on the ADC module
PLIB_ADC_ExistsResultFormat Identifies whether the ResultFormat feature exists on the ADC module
PLIB_ADC_ExistsResultGet Identifies whether the ResultGet feature exists on the ADC module
PLIB_ADC_ExistsResultGetByIndex Identifies whether the ResultGetByIndex feature exists on the ADC module
PLIB_ADC_ExistsResultSign Identifies whether the ResultSign feature exists on the ADC module
PLIB_ADC_ExistsResultSize Identifies whether the ResultSize feature exists on the ADC module
PLIB_ADC_ExistsSampleResolution Identifies whether the SampleResolution feature exists on the ADC module
PLIB_ADC_ExistsSamplesPerInterruptSelect Identifies whether the SamplesPerInterruptSelect feature exists on the ADC module
PLIB_ADC_ExistsSamplingAcquisitionTime Identifies whether the SamplingAcquisitionTime feature exists on the ADC module
PLIB_ADC_ExistsSamplingAutoStart Identifies whether the SamplingAutoStart feature exists on the ADC module
PLIB_ADC_ExistsSamplingControl Identifies whether the SamplingControl feature exists on the ADC module
PLIB_ADC_ExistsSamplingModeControl Identifies whether the SamplingModeControl feature exists on the ADC module
PLIB_ADC_ExistsSamplingStatus Identifies whether the SamplingStatus feature exists on the ADC module
PLIB_ADC_ExistsStopInIdleControl Identifies whether the StopInIdle feature exists on the ADC module
PLIB_ADC_ExistsVoltageReference Identifies whether the VoltageReference feature exists on the ADC module
PLIB_ADC_ExistsMuxInputScanSelectExtended Identifies whether the MuxInputScanSelectExtended feature exists on the ADC module

Data Types & Constants

Function Name Description
ADC_MODULE_ID Identifies the supported ADC modules supported
ADC_VOLTAGE_REFERENCE Data type defining the different ADC Voltage Reference by which the ADC can be configured
ADC_INPUTS_NEGATIVE Data type defining the different ADC Negative Input Enumeration
ADC_SAMPLES_PER_INTERRUPT Data type defining the Samples Per Interrupt Enumeration
ADC_CHANNEL_GROUP Data type defines the ADC Channel Group
ADC_CLOCK_SOURCE Data type defines the ADC Clock Source Select
ADC_CONVERSION_TRIGGER_SOURCE Data type defines the ADC Conversion Trigger Source
ADC_RESULT_SIZE Data type defines the ADC Result Size
ADC_BUFFER_MODE Data type defines the ADC Buffer Mode
ADC_RESULT_BUF_STATUS Data type defines the ADC Result Buffer Status
ADC_MUX Data type defining the different ADC MUX Enumeration
ADC_SAMPLING_MODE Data type defines the ADC Sampling Mode Select
ADC_INPUTS_SCAN Data type defines the ADC Scan inputs
ADC_REFERENCE_INPUT Data type defines the ADC Reference Input Enumeration
ADC_RESULT_FORMAT Data type defines the ADC Result Format
ADC_DMA_BUFFER_MODE Data type defines the ADC Buffer Mode
ADC_PAIR Data type defines the ADC Pair
ADC_CHANNEL123_INPUTS_NEG Data type defines the ADC Channel 123 Negative Input Select
ADC_CHANNEL123_INPUTS_POS Data type defines the ADC Channel 123 Positive Input
ADC_INPUTS_POSITIVE Data type defines the ADC inputs
ADC_CONVERSION_ORDER Data type defines the ADC Conversion Order
ADC_DMA_ADDRESS_INCREMENT Data type defines the ADC DMA Increment Rate
ADC_DMA_INPUT_BUFFER Data type defines the ADC DMA Buffer Per Input
ADC_ACQUISITION_TIME Data type defining the different ADC acquisition times by which the ADC can be configured
ADC_CONVERSION_CLOCK Data type defines the different ADC Conversion clock
ADC_SAMPLE Data type defining the size of the ADC sample register

20th Annual
Microchip MASTERs Conference 2016

JW Marriott Desert Ridge Resort-Phoenix, AZ

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