2.3 Analog Digital Converter (ADC)

This Plib implements software abstraction for ADC Peripheral.

Library Interface

Analog Digital Converter peripheral library provides the following interfaces:

Functions

NameDescription
ADCx_InitializeInitializes ADC peripheral
ADCx_EnableEnable (turn ON) ADC module
ADCx_DisableDisable ADC module
ADC_SamplingStartStarts the sampling
ADCx_ChannelSelectSelects ADC input channel
ADCx_ConversionStartStarts the ADC conversion of all the enabled channels with the software trigger
ADCx_ConversionStatusGetReturns the status of the conversion of the channel
ADCx_ConversionResultGetReturns the conversion result of the channel
ADCx_LastConversionResultGetReturns the result for the previous adc conversion of the channel
ADCx_ConversionSequenceIsFinishedReturns the status of automatic sequence conversion
ADCx_ComparisonWindowSetReturns the status of automatic sequence conversion
ADCx_WindowMonitorStatusGetReturns the status of the window monitor flag
ADCx_ComparisonWindowSetReturns the status of automatic sequence conversion
ADCx_WindowModeSetThis function configures the window comparison mode
ADCx_InterruptsClearThis function clears the interrupt flags
ADCx_InterruptsEnableThis function enables the interrupts
ADCx_InterruptsDisableThis function disables the interrupts
ADCx_CallbackRegisterRegisters the function to be called from interrupt
ADC_InputSelectSelects input for ADC
ADC_InputScanSelectSelects input for scanning ADC channels
ADC_ResultIsReadyReturns the status of the channel conversion
ADC_ResultGetProvides the ADC conversion result based on the buffer index
ADC_CompareEnableEnables digital comparisons for the given channel on the specified ADC core
ADC_CompareDisableDisables digital comparisons for the given channel on the specified ADC core
ADC_CompareWinThresholdSetConfigures the low and high threshold values for the comparator on the specified ADC core
ADC_CompareWinModeSetConfigures the low and high threshold values for the comparator on the specified ADC core
ADC_GlobalInterruptsStatusGetReturns the global interrupt status
ADC_CoreInterruptsEnableEnables the specified ADC core's interrupt
ADC_CoreInterruptsDisableDisable the specified ADC core's interrupts
ADC_CoreInterruptsStatusGetReturns the specified ADC core's interrupt status
ADC_CoreInterruptsStatusClearClears the specified ADC core's interrupt status
ADC_GlobalEdgeConversionStartGenerates global edge trigger and starts conversion on channels configured with Global edge as the trigger source
ADC_GlobalLevelConversionStartStarts global level trigger and starts conversion on channels configured with Global level as the trigger source
ADC_GlobalLevelConversionStopStops global level trigger and stops conversion on channels configured with Global level as the trigger source
ADC_SyncTriggerEnableEnables sync trigger defined by CTRLC.CNT value
ADC_SyncTriggerDisableDisables sync trigger
ADC_SyncTriggerCounterSetConfigures the value of CTRLC.CNT register
ADC_SoftwareControlledConversionEnableEnables software controlled conversion on the specified ADC core's channel
ADC_ChannelsEnableEnables the ADC channels
ADC_ChannelsDisableDisables the ADC channels
ADC_ChannelsInterruptEnableEnables the ADC interrupt sources
ADC_ChannelsInterruptDisableDisables the ADC interrupt sources
ADC_InterruptEnableThis function enables the interrupts
ADC_InterruptDisableThis function disables the interrupts
ADC_InterruptStatusGetReturns the status of ADC interrupt
ADC_ChannelSamplingStartEnables the Analog Mux Input and starts sampling on the ADC core and channel that was specified using the ADC_SoftwareControlledConversionEnable() API
ADC_ChannelSamplingStopStops sampling on the ADC core and channel that was specified using the ADC_SoftwareControlledConversionEnable() API
ADC_ChannelConversionStartStarts conversion on the ADC core and channel that was specified using the ADC_SoftwareControlledConversionEnable() API
ADC_ChannelResultIsReadyReturns the status of the channel conversion
ADC_ChannelResultGetReads the conversion result of the channel
ADC_EOSStatusGetIndicates whether End of scan interrupt flag is set on the specified ADC core
ADC_ResultGetReturns the ADC conversion value for the specified ADC core channel
ADC_FIFOReadReturns a single ADC conversion value from the ADC FIFO
ADC_FIFOBufferReadReturns multiple ADC conversion values from the ADC FIFO
ADC_GlobalCallbackRegisterRegisters the global callback function
ADC_COREnCallbackRegisterRegisters the ADC core specific callback function
ADC_ConversionSequenceSetSets the user sequence of the channel conversion
ADCx_ComparisonWindowSetSets Low threshold and High threshold in comparison window
ADC_ComparisonEventResultIsReadyReturns the status of the Comparison event
ADC_ComparisonRestartRestart the comparison function
ADC_SleepModeEnableThis function enables ADC sleep mode
ADC_SleepModeDisableThis function disables ADC sleep mode
ADC_FastWakeupEnableThis function enables ADC Fast Wakeup
ADC_FastWakeupDisableThis function disables ADC Fast Wakeup

Data types and constants

NameTypeDescription
ADC_MUXEnumIdentifies which ADC Mux is to be configured
ADC_RESULT_BUFFEREnumIdentifies which ADC buffer has to be read
ADC_INPUT_POSITIVEEnumIdentifies possible positive input for ADC
ADC_INPUT_NEGATIVEEnumIdentifies possible negative input for ADC
ADC_INPUTS_SCANEnumIdentifies possible ADC inputs which can be scanned
ADC_STATUSEnumIdentifies ADC interrupt flag status
ADC_POSINPUTEnumIdentifies ADC positive input pin to select
ADC_NEGINPUTEnumIdentifies ADC negative input pin to select
ADC_WINMODEEnumIdentifies ADC window comparison modes
ADC_CALLBACKTypedefDefines the data type and function signature for the ADC peripheral callback function
ADC_CALLBACK_OBJECTStructADC Callback structure
ADC_CORE_INT_CMPHITMacroIdentifies ADC core interrupt status
ADC_FIFO_CORID_GETMacroReturns the ADC core id in the ADC FIFO data
ADC_FIFO_DATA_GETMacroReturns the ADC conversion resunt from the ADC FIFO data
ADC_FIFO_CHNID_GETMacroReturns the ADC channel id in the ADC FIFO data
ADC_FIFO_CNT_GETMacroReturns the current number of entries present in the ADC FIFO
ADC_GLOBAL_INT_CRRDY1MacroIdentifies ADC global interrupt status
ADC_CHANNEL_MASKEnumIdentifies ADC channel mask
ADC_CHANNEL_NUMEnumIdentifies ADC channel number
ADC_INTERRUPT_EOC_MASKEnumIdentifies EOC interrupt sources number
ADC_INTERRUPT_MASKEnumIdentifies interrupt sources number
ADC_CORE_NUMEnumIdentifies ADC core
ADC_CORE_CALLBACKTypedefDefines the function pointer data type and function signature for the adc peripheral core callback function
ADC_GLOBAL_CALLBACKTypedefDefines the function pointer data type and function signature for the adc peripheral global callback function
ADC_CORE_CALLBACK_OBJECTStructADC Core events Callback structure
ADC_GLOBAL_CALLBACK_OBJECTStructADC Global Callback structure
Note: Not all APIs maybe implemented. See the specific device family section for available APIs.