ADC Peripheral Library Interface for Harmony v2
Detailed descriptions for this library can be found in the MPLAB® Harmony Documentation.
Interface Header File
The interface to the ADC library is defined in the header file PLIB_ADC, which is included by the library header file PERIPHERAL. Any C language source (.c) file that uses the ADC library must include a peripheral header file.
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 | • Positive/negative voltage reference selection • Channel group selection • Positive/negative channel selection • Add/remove channels for scan • Enable/disablle the ADC module • Enable/disable the calibration • Enable/disable stop in Idle • Enable/disable internal reference channel |
MUX Selection and Channel Scan | • Positive/negative input selection for MUX A/MUX B: channel 0 • Positive/negative input selection for MUX A/MUX B: channels 1, 2, 3 • Enable/disable MUX A scan |
Sample and Hold Control Logic | • Sampling start/stop, status • Enable/disable sample auto start • Acquisition/auto-sample time selection • Max/min sample value • Sample mode control: Alternate Input, 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 • Enable/disable conversion stop sequence |
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 | • Enable/disable DMA • 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 the first or second conversion • Global software trigger control • Asynchronous dedicated sampling control • ADC Interrupt Service Routine (ISR) jump table address setting • Conversion order selection based on even/odd input |
Feature Existence 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 the ADC module operation when the device is in Idle mode |
PLIB_ADC_StopInIdleEnable | Discontinue the ADC module operation when the 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 | Negative analog input channel selection |
PLIB_ADC_InputScanMaskAdd | Selects the ADC analog channel for input scan |
PLIB_ADC_InputScanMaskRemove | Omits the ADC analog channel for input scan |
PLIB_ADC_InputScanMaskAddExtended | Selects the extended ADC analog channel for input scan |
PLIB_ADC_InputScanMaskRemoveExtended | Omits the 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 the manual conversion process of the ADC module |
PLIB_ADC_ConversionHasCompleted | Provides the conversion completion status of the ADC |
PLIB_ADC_ConversionTriggerSourceSelect | Selects the conversion trigger source |
PLIB_ADC_ConversionStopSequenceEnable | Stops the 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 | Enables 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 | Starts 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 the 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 | Scans the 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 the asynchronous dedicated S&H sampling |
PLIB_ADC_AsynchronousDedicatedSamplingEnable | Enables the 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 ADC modules supported |
ADC_VOLTAGE_REFERENCE | Defines the different ADC Voltage Reference by which the ADC can be configured |
ADC_INPUTS_NEGATIVE | Defines the different ADC Negative Input Enumeration |
ADC_SAMPLES_PER_INTERRUPT | Defines the Samples Per Interrupt Enumeration |
ADC_CHANNEL_GROUP | Defines the ADC Channel Group |
ADC_CLOCK_SOURCE | Defines the ADC Clock Source Select |
ADC_CONVERSION_TRIGGER_SOURCE | Defines the ADC Conversion Trigger Source |
ADC_RESULT_SIZE | Defines the ADC Result Size |
ADC_BUFFER_MODE | Defines the ADC Buffer Mode |
ADC_RESULT_BUF_STATUS | Defines the ADC Result Buffer Status |
ADC_MUX | Defines the different ADC MUX Enumeration |
ADC_SAMPLING_MODE | Defines the ADC Sampling Mode Select |
ADC_INPUTS_SCAN | Defines the ADC Scan inputs |
ADC_REFERENCE_INPUT | Defines the ADC Reference Input Enumeration |
ADC_RESULT_FORMAT | Defines the ADC Result Format |
ADC_DMA_BUFFER_MODE | Defines the ADC Buffer Mode |
ADC_PAIR | Defines the ADC Pair |
ADC_CHANNEL123_INPUTS_NEG | Defines the ADC Negative Input Select: channels 1, 2, 3 |
ADC_CHANNEL123_INPUTS_POS | Defines the ADC Positive Input: channels 1, 2, 3 |
ADC_INPUTS_POSITIVE | Defines the ADC inputs |
ADC_CONVERSION_ORDER | Defines the ADC Conversion Order |
ADC_DMA_ADDRESS_INCREMENT | Defines the ADC DMA Increment Rate |
ADC_DMA_INPUT_BUFFER | Defines the ADC DMA Buffer Per Input |
ADC_ACQUISITION_TIME | Defines the different ADC acquisition times by which the ADC can be configured |
ADC_CONVERSION_CLOCK | Defines the different ADC Conversion clock |
ADC_SAMPLE | Defines the size of the ADC sample register |