3.1.2.3 12-bit ADCC

12-bit ADC with Computation

3.1.2.3.1 Introduction

This Analog-to-Digital Converter with Computation (ADCC) module converts an analog voltage value into a 12-bit numerical value. It offers different computational actions that can be performed on the result such as averaging or low-pass filtering.

3.1.2.3.2 Supported Device Families

PIC16F184xxPIC16F191xxPIC18F-K42PIC18F-K83 PIC18F-Q4x

3.1.2.3.3 Required header files:


#include "mcc_generated_files/adc/adcc.h"

3.1.2.3.4 How to use the ADCC PLIB Driver

The ADCC Module driver generates an API interface to support the features of the peripheral. Some use cases of are linked below. Click the links to view the code snippets associated with each.

Instructions common for all code snippets can be found here: ADCC Use Case Code Snippet Instructions

Table 3-349. Running the ADCC Use-Cases
Videos Running the MCC Melody use case code snippets for PIC16F/18F:
Many of use cases build on the following components, so this is a good place to start if you are new to MCC Melody:

Module Documentation

Analog-to-Digital Converter (ADC)

This file provides API prototypes for the ADC driver.

Module description

This file provides API prototypes for the ADC driver.

This file provides type definitions for the ADC module.

Version: ADC Driver Version 3.0.0 ADC Package Version 5.0.0
Definitions
Enumerations
Functions
Definition Documentation
ADC_BIT_CLEAR[1/2]

#define ADC_BIT_CLEAR 0

ADC bit clear value.

ADC_BIT_CLEAR[1/2]

#define ADC_BIT_CLEAR 0

ADC bit clear value.

ADC_BIT_SET[1/2]

#define ADC_BIT_SET 1

ADC bit set value.

ADC_BIT_SET[1/2]

#define ADC_BIT_SET 1

ADC bit set value.

ADC_RESOLUTION[1/2]

#define ADC_RESOLUTION 12

ADC resolution value.

ADC_RESOLUTION[1/2]

#define ADC_RESOLUTION 12

ADC resolution value.

CustomName_AccumulatedResultGet[1/2]

#define CustomName_AccumulatedResultGet ADC_AccumulatedResultGet

Defines the Custom Name API mapping for ADC_AccumulatedResultGet.

CustomName_AccumulatedResultGet[1/2]

#define CustomName_AccumulatedResultGet ADC_AccumulatedResultGet

Defines the Custom Name API mapping for ADC_AccumulatedResultGet.

CustomName_AccumulatorClear[1/2]

#define CustomName_AccumulatorClear ADC_AccumulatorClear

Defines the Custom Name API mapping for ADC_AccumulatorClear.

CustomName_AccumulatorClear[1/2]

#define CustomName_AccumulatorClear ADC_AccumulatorClear

Defines the Custom Name API mapping for ADC_AccumulatorClear.

CustomName_AcquisitionTimeSet[1/2]

#define CustomName_AcquisitionTimeSet ADC_AcquisitionTimeSet

Defines the Custom Name API mapping for ADC_AcquisitionTimeSet.

CustomName_AcquisitionTimeSet[1/2]

#define CustomName_AcquisitionTimeSet ADC_AcquisitionTimeSet

Defines the Custom Name API mapping for ADC_AcquisitionTimeSet.

CustomName_AutoTriggerSourceSet[1/2]

#define CustomName_AutoTriggerSourceSet ADC_AutoTriggerSourceSet

Defines the Custom Name API mapping for ADC_AutoTriggerSourceSet.

CustomName_AutoTriggerSourceSet[1/2]

#define CustomName_AutoTriggerSourceSet ADC_AutoTriggerSourceSet

Defines the Custom Name API mapping for ADC_AutoTriggerSourceSet.

CustomName_BusyStatusSet[1/2]

#define CustomName_BusyStatusSet ADC_BusyStatusSet

Defines the Custom Name API mapping for ADC_BusyStatusSet.

CustomName_BusyStatusSet[1/2]

#define CustomName_BusyStatusSet ADC_BusyStatusSet

Defines the Custom Name API mapping for ADC_BusyStatusSet.

CustomName_CalculationRightShiftSet[1/2]

#define CustomName_CalculationRightShiftSet ADC_CalculationRightShiftSet

Defines the Custom Name API mapping for ADC_CalculationRightShiftSet.

CustomName_CalculationRightShiftSet[1/2]

#define CustomName_CalculationRightShiftSet ADC_CalculationRightShiftSet

Defines the Custom Name API mapping for ADC_CalculationRightShiftSet.

CustomName_ChannelSelect[1/2]

#define CustomName_ChannelSelect ADC_ChannelSelect

Defines the Custom Name API mapping for ADC_ChannelSelect.

CustomName_ChannelSelect[1/2]

#define CustomName_ChannelSelect ADC_ChannelSelect

Defines the Custom Name API mapping for ADC_ChannelSelect.

CustomName_ChannelSelectAndConvert[1/2]

#define CustomName_ChannelSelectAndConvert ADC_ChannelSelectAndConvert

Defines the Custom Name API mapping for ADC_ChannelSelectAndConvert.

CustomName_ChannelSelectAndConvert[1/2]

#define CustomName_ChannelSelectAndConvert ADC_ChannelSelectAndConvert

Defines the Custom Name API mapping for ADC_ChannelSelectAndConvert.

CustomName_ChargePumpDisable[1/2]

#define CustomName_ChargePumpDisable ADC_ChargePumpDisable

Defines the Custom Name API mapping for ADC_ChargePumpDisable.

CustomName_ChargePumpDisable[1/2]

#define CustomName_ChargePumpDisable ADC_ChargePumpDisable

Defines the Custom Name API mapping for ADC_ChargePumpDisable.

CustomName_ChargePumpEnable[1/2]

#define CustomName_ChargePumpEnable ADC_ChargePumpEnable

Defines the Custom Name API mapping for ADC_ChargePumpEnable.

CustomName_ChargePumpEnable[1/2]

#define CustomName_ChargePumpEnable ADC_ChargePumpEnable

Defines the Custom Name API mapping for ADC_ChargePumpEnable.

CustomName_ComputationModeSet[1/2]

#define CustomName_ComputationModeSet ADC_ComputationModeSet

Defines the Custom Name API mapping for ADC_ComputationModeSet.

CustomName_ComputationModeSet[1/2]

#define CustomName_ComputationModeSet ADC_ComputationModeSet

Defines the Custom Name API mapping for ADC_ComputationModeSet.

CustomName_ContinuousConversionDisable[1/2]

#define CustomName_ContinuousConversionDisable ADC_ContinuousConversionDisable

Defines the Custom Name API mapping for ADC_ContinuousConversionDisable.

CustomName_ContinuousConversionDisable[1/2]

#define CustomName_ContinuousConversionDisable ADC_ContinuousConversionDisable

Defines the Custom Name API mapping for ADC_ContinuousConversionDisable.

CustomName_ContinuousConversionEnable[1/2]

#define CustomName_ContinuousConversionEnable ADC_ContinuousConversionEnable

Defines the Custom Name API mapping for ADC_ContinuousConversionEnable.

CustomName_ContinuousConversionEnable[1/2]

#define CustomName_ContinuousConversionEnable ADC_ContinuousConversionEnable

Defines the Custom Name API mapping for ADC_ContinuousConversionEnable.

CustomName_ConversionDoneCallbackRegister[1/2]

#define CustomName_ConversionDoneCallbackRegister ADC_ConversionDoneCallbackRegister

Defines the Custom Name API mapping for ADC_ConversionDoneCallbackRegister.

CustomName_ConversionDoneCallbackRegister[1/2]

#define CustomName_ConversionDoneCallbackRegister ADC_ConversionDoneCallbackRegister

Defines the Custom Name API mapping for ADC_ConversionDoneCallbackRegister.

CustomName_ConversionDoneInterruptDisable

#define CustomName_ConversionDoneInterruptDisable ADC_ConversionDoneInterruptDisable

Defines the Custom Name API mapping for ADC_ConversionDoneInterruptDisable.

CustomName_ConversionDoneInterruptEnable

#define CustomName_ConversionDoneInterruptEnable ADC_ConversionDoneInterruptEnable

Defines the Custom Name API mapping for ADC_ConversionDoneInterruptEnable.

CustomName_ConversionDoneInterruptFlagClear[1/2]

#define CustomName_ConversionDoneInterruptFlagClear ADC_ConversionDoneInterruptFlagClear

Defines the Custom Name API mapping for ADC_ConversionDoneInterruptFlagClear.

CustomName_ConversionDoneInterruptFlagClear[1/2]

#define CustomName_ConversionDoneInterruptFlagClear ADC_ConversionDoneInterruptFlagClear

Defines the Custom Name API mapping for ADC_ConversionDoneInterruptFlagClear.

CustomName_ConversionResultGet[1/2]

#define CustomName_ConversionResultGet ADC_ConversionResultGet

Defines the Custom Name API mapping for ADC_ConversionResultGet.

CustomName_ConversionResultGet[1/2]

#define CustomName_ConversionResultGet ADC_ConversionResultGet

Defines the Custom Name API mapping for ADC_ConversionResultGet.

CustomName_ConversionStageStatusGet[1/2]

#define CustomName_ConversionStageStatusGet ADC_ConversionStageStatusGet

Defines the Custom Name API mapping for ADC_ConversionStageStatusGet.

CustomName_ConversionStageStatusGet[1/2]

#define CustomName_ConversionStageStatusGet ADC_ConversionStageStatusGet

Defines the Custom Name API mapping for ADC_ConversionStageStatusGet.

CustomName_ConversionStart[1/2]

#define CustomName_ConversionStart ADC_ConversionStart

Defines the Custom Name API mapping for ADC_ConversionStart.

CustomName_ConversionStart[1/2]

#define CustomName_ConversionStart ADC_ConversionStart

Defines the Custom Name API mapping for ADC_ConversionStart.

CustomName_ConversionStop[1/2]

#define CustomName_ConversionStop ADC_ConversionStop

Defines the Custom Name API mapping for ADC_ConversionStop.

CustomName_ConversionStop[1/2]

#define CustomName_ConversionStop ADC_ConversionStop

Defines the Custom Name API mapping for ADC_ConversionStop.

CustomName_CurrentConversionCountGet[1/2]

#define CustomName_CurrentConversionCountGet ADC_CurrentConversionCountGet

Defines the Custom Name API mapping for ADC_CurrentConversionCountGet.

CustomName_CurrentConversionCountGet[1/2]

#define CustomName_CurrentConversionCountGet ADC_CurrentConversionCountGet

Defines the Custom Name API mapping for ADC_CurrentConversionCountGet.

CustomName_Deinitialize[1/2]

#define CustomName_Deinitialize ADC_Deinitialize

Defines the Custom Name API mapping for ADC_Deinitialize.

CustomName_Deinitialize[1/2]

#define CustomName_Deinitialize ADC_Deinitialize

Defines the Custom Name API mapping for ADC_Deinitialize.

CustomName_Disable[1/2]

#define CustomName_Disable ADC_Disable

Defines the Custom Name API mapping for ADC_Disable.

CustomName_Disable[1/2]

#define CustomName_Disable ADC_Disable

Defines the Custom Name API mapping for ADC_Disable.

CustomName_DoubleSamplingDisable[1/2]

#define CustomName_DoubleSamplingDisable ADC_DoubleSamplingDisable

Defines the Custom Name API mapping for ADC_DoubleSamplingDisable.

CustomName_DoubleSamplingDisable[1/2]

#define CustomName_DoubleSamplingDisable ADC_DoubleSamplingDisable

Defines the Custom Name API mapping for ADC_DoubleSamplingDisable.

CustomName_DoubleSamplingEnable[1/2]

#define CustomName_DoubleSamplingEnable ADC_DoubleSamplingEnable

Defines the Custom Name API mapping for ADC_DoubleSamplingEnable.

CustomName_DoubleSamplingEnable[1/2]

#define CustomName_DoubleSamplingEnable ADC_DoubleSamplingEnable

Defines the Custom Name API mapping for ADC_DoubleSamplingEnable.

CustomName_Enable[1/2]

#define CustomName_Enable ADC_Enable

Defines the Custom Name API mapping for ADC_Enable.

CustomName_Enable[1/2]

#define CustomName_Enable ADC_Enable

Defines the Custom Name API mapping for ADC_Enable.

CustomName_ErrorCalculationGet[1/2]

#define CustomName_ErrorCalculationGet ADC_ErrorCalculationGet

Defines the Custom Name API mapping for ADC_ErrorCalculationGet.

CustomName_ErrorCalculationGet[1/2]

#define CustomName_ErrorCalculationGet ADC_ErrorCalculationGet

Defines the Custom Name API mapping for ADC_ErrorCalculationGet.

CustomName_ErrorCalculationModeSet[1/2]

#define CustomName_ErrorCalculationModeSet ADC_ErrorCalculationModeSet

Defines the Custom Name API mapping for ADC_ErrorCalculationModeSet.

CustomName_ErrorCalculationModeSet[1/2]

#define CustomName_ErrorCalculationModeSet ADC_ErrorCalculationModeSet

Defines the Custom Name API mapping for ADC_ErrorCalculationModeSet.

CustomName_FilterValueGet[1/2]

#define CustomName_FilterValueGet ADC_FilterValueGet

Defines the Custom Name API mapping for ADC_FilterValueGet.

CustomName_FilterValueGet[1/2]

#define CustomName_FilterValueGet ADC_FilterValueGet

Defines the Custom Name API mapping for ADC_FilterValueGet.

CustomName_HasAccumulatorOverflowed[1/2]

#define CustomName_HasAccumulatorOverflowed ADC_HasAccumulatorOverflowed

Defines the Custom Name API mapping for ADC_HasAccumulatorOverflowed.

CustomName_HasAccumulatorOverflowed[1/2]

#define CustomName_HasAccumulatorOverflowed ADC_HasAccumulatorOverflowed

Defines the Custom Name API mapping for ADC_HasAccumulatorOverflowed.

CustomName_Initialize[1/2]

#define CustomName_Initialize ADC_Initialize

Defines the Custom Name API mapping for ADC_Initialize.

CustomName_Initialize[1/2]

#define CustomName_Initialize ADC_Initialize

Defines the Custom Name API mapping for ADC_Initialize.

CustomName_IsAccumulatorClearComplete[1/2]

#define CustomName_IsAccumulatorClearComplete ADC_IsAccumulatorClearComplete

Defines the Custom Name API mapping for ADC_IsAccumulatorClearComplete.

CustomName_IsAccumulatorClearComplete[1/2]

#define CustomName_IsAccumulatorClearComplete ADC_IsAccumulatorClearComplete

Defines the Custom Name API mapping for ADC_IsAccumulatorClearComplete.

CustomName_IsBusy[1/2]

#define CustomName_IsBusy ADC_IsBusy

Defines the Custom Name API mapping for ADC_IsBusy.

CustomName_IsBusy[1/2]

#define CustomName_IsBusy ADC_IsBusy

Defines the Custom Name API mapping for ADC_IsBusy.

CustomName_IsChargePumpReady[1/2]

#define CustomName_IsChargePumpReady ADC_IsChargePumpReady

Defines the Custom Name API mapping for ADC_IsChargePumpReady.

CustomName_IsChargePumpReady[1/2]

#define CustomName_IsChargePumpReady ADC_IsChargePumpReady

Defines the Custom Name API mapping for ADC_IsChargePumpReady.

CustomName_IsConversionDone[1/2]

#define CustomName_IsConversionDone ADC_IsConversionDone

Defines the Custom Name API mapping for ADC_IsConversionDone.

CustomName_IsConversionDone[1/2]

#define CustomName_IsConversionDone ADC_IsConversionDone

Defines the Custom Name API mapping for ADC_IsConversionDone.

CustomName_IsConversionDoneInterruptFlagSet[1/2]

#define CustomName_IsConversionDoneInterruptFlagSet ADC_IsConversionDoneInterruptFlagSet

Defines the Custom Name API mapping for ADC_IsConversionDoneInterruptFlagSet.

CustomName_IsConversionDoneInterruptFlagSet[1/2]

#define CustomName_IsConversionDoneInterruptFlagSet ADC_IsConversionDoneInterruptFlagSet

Defines the Custom Name API mapping for ADC_IsConversionDoneInterruptFlagSet.

CustomName_IsErrorGreaterThanUpperThreshold[1/2]

#define CustomName_IsErrorGreaterThanUpperThreshold ADC_IsErrorGreaterThanUpperThreshold

Defines the Custom Name API mapping for ADC_IsErrorGreaterThanUpperThreshold.

CustomName_IsErrorGreaterThanUpperThreshold[1/2]

#define CustomName_IsErrorGreaterThanUpperThreshold ADC_IsErrorGreaterThanUpperThreshold

Defines the Custom Name API mapping for ADC_IsErrorGreaterThanUpperThreshold.

CustomName_IsErrorLesserThanLowerThreshold[1/2]

#define CustomName_IsErrorLesserThanLowerThreshold ADC_IsErrorLesserThanLowerThreshold

Defines the Custom Name API mapping for ADC_IsErrorLesserThanLowerThreshold.

CustomName_IsErrorLesserThanLowerThreshold[1/2]

#define CustomName_IsErrorLesserThanLowerThreshold ADC_IsErrorLesserThanLowerThreshold

Defines the Custom Name API mapping for ADC_IsErrorLesserThanLowerThreshold.

CustomName_IsThresholdInterruptFlagSet[1/2]

#define CustomName_IsThresholdInterruptFlagSet ADC_IsThresholdInterruptFlagSet

Defines the Custom Name API mapping for ADC_IsThresholdInterruptFlagSet.

CustomName_IsThresholdInterruptFlagSet[1/2]

#define CustomName_IsThresholdInterruptFlagSet ADC_IsThresholdInterruptFlagSet

Defines the Custom Name API mapping for ADC_IsThresholdInterruptFlagSet.

CustomName_LowerThresholdSet[1/2]

#define CustomName_LowerThresholdSet ADC_LowerThresholdSet

Defines the Custom Name API mapping for ADC_LowerThresholdSet.

CustomName_LowerThresholdSet[1/2]

#define CustomName_LowerThresholdSet ADC_LowerThresholdSet

Defines the Custom Name API mapping for ADC_LowerThresholdSet.

CustomName_PrechargeTimeSet[1/2]

#define CustomName_PrechargeTimeSet ADC_PrechargeTimeSet

Defines the Custom Name API mapping for ADC_PrechargeTimeSet.

CustomName_PrechargeTimeSet[1/2]

#define CustomName_PrechargeTimeSet ADC_PrechargeTimeSet

Defines the Custom Name API mapping for ADC_PrechargeTimeSet.

CustomName_PreviousResultGet[1/2]

#define CustomName_PreviousResultGet ADC_PreviousResultGet

Defines the Custom Name API mapping for ADC_PreviousResultGet.

CustomName_PreviousResultGet[1/2]

#define CustomName_PreviousResultGet ADC_PreviousResultGet

Defines the Custom Name API mapping for ADC_PreviousResultGet.

CustomName_ResolutionGet[1/2]

#define CustomName_ResolutionGet ADC_ResolutionGet

Defines the Custom Name API mapping for ADC_ResolutionGet.

CustomName_ResolutionGet[1/2]

#define CustomName_ResolutionGet ADC_ResolutionGet

Defines the Custom Name API mapping for ADC_ResolutionGet.

CustomName_SampleCapacitorDischarge[1/2]

#define CustomName_SampleCapacitorDischarge ADC_SampleCapacitorDischarge

Defines the Custom Name API mapping for ADC_SampleCapacitorDischarge.

CustomName_SampleCapacitorDischarge[1/2]

#define CustomName_SampleCapacitorDischarge ADC_SampleCapacitorDischarge

Defines the Custom Name API mapping for ADC_SampleCapacitorDischarge.

CustomName_SampleRepeatCountSet[1/2]

#define CustomName_SampleRepeatCountSet ADC_SampleRepeatCountSet

Defines the Custom Name API mapping for ADC_SampleRepeatCountSet.

CustomName_SampleRepeatCountSet[1/2]

#define CustomName_SampleRepeatCountSet ADC_SampleRepeatCountSet

Defines the Custom Name API mapping for ADC_SampleRepeatCountSet.

CustomName_SetPointDefine[1/2]

#define CustomName_SetPointDefine ADC_SetPointDefine

Defines the Custom Name API mapping for ADC_SetPointDefine.

CustomName_SetPointDefine[1/2]

#define CustomName_SetPointDefine ADC_SetPointDefine

Defines the Custom Name API mapping for ADC_SetPointDefine.

CustomName_StopOnInterruptDisable[1/2]

#define CustomName_StopOnInterruptDisable ADC_StopOnInterruptDisable

Defines the Custom Name API mapping for ADC_StopOnInterruptDisable.

CustomName_StopOnInterruptDisable[1/2]

#define CustomName_StopOnInterruptDisable ADC_StopOnInterruptDisable

Defines the Custom Name API mapping for ADC_StopOnInterruptDisable.

CustomName_StopOnInterruptEnable[1/2]

#define CustomName_StopOnInterruptEnable ADC_StopOnInterruptEnable

Defines the Custom Name API mapping for ADC_StopOnInterruptEnable.

CustomName_StopOnInterruptEnable[1/2]

#define CustomName_StopOnInterruptEnable ADC_StopOnInterruptEnable

Defines the Custom Name API mapping for ADC_StopOnInterruptEnable.

CustomName_Tasks

#define CustomName_Tasks ADC_Tasks

Defines the Custom Name API mapping for ADC_Tasks.

CustomName_ThresholdCallbackRegister[1/2]

#define CustomName_ThresholdCallbackRegister ADC_ThresholdCallbackRegister

Defines the Custom Name API mapping for ADC_ThresholdCallbackRegister.

CustomName_ThresholdCallbackRegister[1/2]

#define CustomName_ThresholdCallbackRegister ADC_ThresholdCallbackRegister

Defines the Custom Name API mapping for ADC_ThresholdCallbackRegister.

CustomName_ThresholdInterruptDisable

#define CustomName_ThresholdInterruptDisable ADC_ThresholdInterruptDisable

Defines the Custom Name API mapping for ADC_ThresholdInterruptDisable.

CustomName_ThresholdInterruptEnable

#define CustomName_ThresholdInterruptEnable ADC_ThresholdInterruptEnable

Defines the Custom Name API mapping for ADC_ThresholdInterruptEnable.

CustomName_ThresholdInterruptFlagClear[1/2]

#define CustomName_ThresholdInterruptFlagClear ADC_ThresholdInterruptFlagClear

Defines the Custom Name API mapping for ADC_ThresholdInterruptFlagClear.

CustomName_ThresholdInterruptFlagClear[1/2]

#define CustomName_ThresholdInterruptFlagClear ADC_ThresholdInterruptFlagClear

Defines the Custom Name API mapping for ADC_ThresholdInterruptFlagClear.

CustomName_ThresholdModeSet[1/2]

#define CustomName_ThresholdModeSet ADC_ThresholdModeSet

Defines the Custom Name API mapping for ADC_ThresholdModeSet.

CustomName_ThresholdModeSet[1/2]

#define CustomName_ThresholdModeSet ADC_ThresholdModeSet

Defines the Custom Name API mapping for ADC_ThresholdModeSet.

CustomName_UpperThresholdSet[1/2]

#define CustomName_UpperThresholdSet ADC_UpperThresholdSet

Defines the Custom Name API mapping for ADC_UpperThresholdSet.

CustomName_UpperThresholdSet[1/2]

#define CustomName_UpperThresholdSet ADC_UpperThresholdSet

Defines the Custom Name API mapping for ADC_UpperThresholdSet.

IO_RA0[1/2]

#define IO_RA0 ADC_CHANNEL_ANA0

Defines the Custom Name pin mapping for channels in adc_channel_t.

IO_RA0[1/2]

#define IO_RA0 ADC_CHANNEL_ANA0

Defines the Custom Name pin mapping for channels in adc_channel_t.

Typedef Documentation
adc_accumulate_t

adc_accumulate_t

ADC conversion accumulator type.

adc_repeat_count_t

adc_repeat_count_t

ADC conversion repeat count type.

adc_result_t

adc_result_t

ADC conversion result type.

adc_threshold_t

adc_threshold_t

ADC conversion threshold type.

Function Documentation
ADC_AccumulatedResultGet()

adc_accumulate_t ADC_AccumulatedResultGet (void )

Retrieves the value of the accumulated conversions.

Parameters:
None.
Returns:

adc_accumulate_t - Value of ADC accumulator register

ADC_AccumulatorClear()

void ADC_AccumulatorClear (void )

Clears the accumulator.

Parameters:
None.
Returns:

None.

ADC_AcquisitionTimeSet()

void ADC_AcquisitionTimeSet (uint16_t acquisitionValue)

Sets the specified value for the ADC Acquisition Time Control (ADACQ) register.

Parameters:
acquisitionValue

Value to be loaded in the ADACQ register

Returns:

None.

ADC_AutoTriggerSourceSet()

void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)

Sets the auto-trigger source.

Parameters:
triggerSource

Desired auto-trigger source. Refer to the adc_trigger_source_t for the list of available trigger sources.

Returns:

None.

ADC_BusyStatusSet()

void ADC_BusyStatusSet (bool status)

Sets the busy status of the ADC module.

Parameters:
status

True to set the ADC status to busy, false to set it to not busy.

Returns:

None.

ADC_CalculationRightShiftSet()

void ADC_CalculationRightShiftSet (uint8_t rightShiftValue)

Sets the ADC Accumulated Calculation Right Shift Select (CRS) bits.

Parameters:
rightShiftValue

Right shift value

Returns:

None.

ADC_ChannelSelect()

void ADC_ChannelSelect (adc_channel_t channel)

Sets the channel to use for the ADC conversion.

Parameters:
channel

Desired analog channel. Refer to the adc_channel_t enum for the list of available analog channels.

Returns:

None.

ADC_ChannelSelectAndConvert()

adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)

Starts the conversion and retrieves the result of the single conversion on the selected channel.

Parameters:
channel

Desired analog channel. Refer to the adc_channel_t enum for the list of available analog channels.

Returns:

adc_result_t - The result of the conversion

ADC_ChargePumpDisable()

void ADC_ChargePumpDisable (void )

Sets the ADC Charge Pump On Control (CPON) bit to '0'.

Parameters:
None.
Returns:

None.

ADC_ChargePumpEnable()

void ADC_ChargePumpEnable (void )

Sets the ADC Charge Pump On Control (CPON) bit to '1'.

Parameters:
None.
Returns:

None.

ADC_ComputationModeSet()

void ADC_ComputationModeSet (adc_computation_mode_t computationMode)

Sets the computation mode.

Parameters:
computationMode

Desired computation mode. Refer to the adc_computation_mode_t enum for the list of available computation modes.

Returns:

None.

ADC_ContinuousConversionDisable()

void ADC_ContinuousConversionDisable (void )

Sets the Continuous Operation Enable (CONT) bit to '0'.

Parameters:
None.
Returns:

None.

ADC_ContinuousConversionEnable()

void ADC_ContinuousConversionEnable (void )

Sets the Continuous Operation Enable (CONT) bit to '1'.

Parameters:
None.
Returns:

None.

ADC_ConversionDoneCallbackRegister()

void ADC_ConversionDoneCallbackRegister (void(*)(void) callback)

Sets the callback function for the ADC Conversion Done Interrupt (ADI).

Parameters:
Pointer

The pointer to the function to be executed

Returns:

None.

ADC_ConversionDoneInterruptDisable()

void ADC_ConversionDoneInterruptDisable (void )

Sets the ADC Interrupt Enable (ADIE) bit to '0'.

Parameters:
None.
Returns:

None.

ADC_ConversionDoneInterruptEnable()

void ADC_ConversionDoneInterruptEnable (void )

Sets the ADC Interrupt Enable (ADIE) bit to '1'.

Parameters:
None.
Returns:

None.

ADC_ConversionDoneInterruptFlagClear()

void ADC_ConversionDoneInterruptFlagClear (void )

Clears the ADC Conversion Done Interrupt Flag (ADIF) bit to '0'.

Parameters:
None.
Returns:

None.

ADC_ConversionResultGet()

adc_result_t ADC_ConversionResultGet (void )

Retrieves the result of the latest conversion.

Precondition:

Call ADC_ConversionStart(void) before using this API.

Parameters:
None.
Returns:

adc_result_t - The result of the conversion

ADC_ConversionStageStatusGet()

adc_conversion_stage_t ADC_ConversionStageStatusGet (void )

Retrieves the conversion stage status.

Parameters:
None.
Returns:

adc_conversion_stage_t - Stage of the conversion stages

ADC_ConversionStart()

void ADC_ConversionStart (void )

Starts the conversion on a selected channel.

Precondition:

Select the channel(s) using ADC_ChannelSelect and call ADC_Initialize(void) to initialize the ADC module before using this API.

Parameters:
None.
Returns:

None.

ADC_ConversionStop()

void ADC_ConversionStop (void )

Stops the ongoing conversion.

Parameters:
None.
Returns:

None.

ADC_CurrentConversionCountGet()

adc_repeat_count_t ADC_CurrentConversionCountGet (void )

Retrieves the current value of the ADC Repeat Counter (ADCNT) register.

Parameters:
None.
Returns:

adc_repeat_count_t - Current value of the ADCNT register

ADC_Deinitialize()

void ADC_Deinitialize (void )

Deinitializes the registers to power-on Reset values.

Parameters:
None.
Returns:

None.

ADC_Disable()

void ADC_Disable (void )

Sets the ADC Enable (ADON) bit to 0.

Parameters:
None.
Returns:

None.

ADC_DoubleSamplingDisable()

void ADC_DoubleSamplingDisable (void )

Sets the Double-Sample Enable (DSEN) bit to '0'.

Parameters:
None.
Returns:

None.

ADC_DoubleSamplingEnable()

void ADC_DoubleSamplingEnable (void )

Sets the Double-Sample Enable (DSEN) bit to '1'.

Parameters:
None.
Returns:

None.

ADC_Enable()

void ADC_Enable (void )

Sets the ADC Enable (ADON) bit to 1.

Parameters:
None.
Returns:

None.

ADC_ErrorCalculationGet()

adc_result_t ADC_ErrorCalculationGet (void )

Retrieves the value of the ADC Setpoint Error (ADERR) register.

Parameters:
None.
Returns:

adc_result_t - Value obtained from the ADERR register

ADC_ErrorCalculationModeSet()

void ADC_ErrorCalculationModeSet (adc_calculation_mode_t errorCalculationMode)

Sets the ADC Error Calculation Mode Select (CALC) bits.

Parameters:
errorCalculationMode

Desired errorCalculationMode value. Refer to the adc_calculation_mode_t for the error calculation mode options.

Returns:

None.

ADC_FilterValueGet()

adc_result_t ADC_FilterValueGet (void )

Retrieves the value of the ADC Filter (ADFLTR) register.

Parameters:
None.
Returns:

adc_result_t - Value obtained after the ADC Accumulator (ADACC) register is right shifted by the CRS bits. In Low-Pass Filter (LPF) mode, this is the output of the Low-Pass Filter.

ADC_HasAccumulatorOverflowed()

bool ADC_HasAccumulatorOverflowed (void )

Determines whether the accumulator has overflowed.

Parameters:
None.
Return values:
True

ADC accumulator has overflowed

False

ADC accumulator has not overflowed

ADC_Initialize()

void ADC_Initialize (void )

Initializes the registers based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI for the Analog-to-Digital Converter (ADC) operation.

Parameters:
None.
Returns:

None.

ADC_IsAccumulatorClearComplete()

bool ADC_IsAccumulatorClearComplete (void )

Status of the accumulator clear operation.

Parameters:
None.
Return values:
True

ADC accumulator clear operation complete

False

ADC accumulator clear operation not complete

ADC_IsBusy()

bool ADC_IsBusy (void )

Returns the busy status of the ADC module.

Parameters:
None.
Return values:
True

The ADC is in use

False

The ADC is not in use

ADC_IsChargePumpReady()

bool ADC_IsChargePumpReady (void )

Checks the Charge Pump Ready status.

Parameters:
None.
Return values:
True

Charge Pump is ready

False

Charge Pump is not ready

ADC_IsConversionDone()

bool ADC_IsConversionDone (void )

Checks if the ongoing conversion is complete.

Precondition:

ADC_ConversionStart(void) is called before using this API.

Parameters:
None.
Return values:
True

Conversion is complete

False

Conversion is ongoing

ADC_IsConversionDoneInterruptFlagSet()

bool ADC_IsConversionDoneInterruptFlagSet (void )

Checks the ADC Conversion Done Interrupt Flag (ADIF) status.

Parameters:
None.
Return values:
True

ADI flag is set

False

ADI flag is not set

ADC_IsErrorGreaterThanUpperThreshold()

bool ADC_IsErrorGreaterThanUpperThreshold (void )

Determines if the value in the ADC Setpoint Error (ADERR) register is greater than the upper threshold. *.

Parameters:
None.
Return values:
True

ADC error is greater than the upper threshold

False

ADC error is not greater than the upper threshold

ADC_IsErrorLesserThanLowerThreshold()

bool ADC_IsErrorLesserThanLowerThreshold (void )

Determines if the value in the ADC Setpoint Error (ADERR) register is lesser than the lower threshold.

Parameters:
None.
Return values:
True

ADC error is less than the lower threshold

False

ADC error is not less the lower threshold

ADC_ISR()

void ADC_ISR (void )

Implements the ADC Interrupt (ADI) service routine for the interrupt-driven implementations.

Parameters:
None.
Returns:

None.

ADC_IsThresholdInterruptFlagSet()

bool ADC_IsThresholdInterruptFlagSet (void )

Checks the ADC Threshold Interrupt (ADTIF) flag status.

Parameters:
None.
Return values:
True

ADTI flag status is set

False

ADTI flag status is not set

ADC_LowerThresholdSet()

void ADC_LowerThresholdSet (adc_threshold_t lowerThreshold)

Sets the value of the ADC Lower Threshold (ADLTH) register.

Parameters:
lowerThreshold

Lower threshold value of the adc_threshold_t type for the ADLTH register

Returns:

None.

ADC_PrechargeTimeSet()

void ADC_PrechargeTimeSet (uint16_t prechargeTime)

Sets the specified value for the ADC Precharge Time Control (ADPRE) register.

Parameters:
prechargeTime

Value to be loaded in the ADPRE register

Returns:

None.

ADC_PreviousResultGet()

adc_result_t ADC_PreviousResultGet (void )

Retrieves the value of the ADC Previous Result(ADPREV) register.

Parameters:
None.
Returns:

adc_result_t - Value obtained from the ADPREV register

ADC_ResolutionGet()

uint8_t ADC_ResolutionGet (void )

Returns the resolution of the ADC module.

Parameters:
None.
Returns:

uint8_t - Resolution value

ADC_SampleCapacitorDischarge()

void ADC_SampleCapacitorDischarge (void )

Discharges the input sample capacitor by setting the channel to AVss.

Parameters:
None.
Returns:

None.

ADC_SampleRepeatCountSet()

void ADC_SampleRepeatCountSet (adc_repeat_count_t repeatCount)

Loads the repeat counter with the specified value.

Parameters:
repeatCount

Repeat count value. Refer to the adc_repeat_count_t type.

Returns:

None.

ADC_SetPointDefine()

void ADC_SetPointDefine (adc_threshold_t setPoint)

Sets the value of the ADC Threshold Setpoint (ADSTPT) register.

Parameters:
setPoint

Value for the ADSTPT register of the adc_threshold_t type

Returns:

None.

ADC_StopOnInterruptDisable()

void ADC_StopOnInterruptDisable (void )

Sets the Stop-on-Interrupt (SOI) bit to '0'.

Parameters:
None.
Returns:

None.

ADC_StopOnInterruptEnable()

void ADC_StopOnInterruptEnable (void )

Sets the Stop-on-Interrupt (SOI) bit to '1'.

Precondition:

Call ADC_ContinuousConversionEnable API before using this API.

Parameters:
None.
Returns:

None.

ADC_Tasks()

void ADC_Tasks (void )

Implements the Tasks routine for the polling implementations.

Parameters:
None.
Returns:

None.

ADC_ThresholdCallbackRegister()

void ADC_ThresholdCallbackRegister (void(*)(void) callback)

Sets the callback for the threshold interrupt.

Parameters:
*callback

The pointer to the function to be executed

Returns:

None.

ADC_ThresholdInterruptDisable()

void ADC_ThresholdInterruptDisable (void )

Sets the ADC Threshold Interrupt Enable bit to '0'.

Parameters:
None.
Returns:

None.

ADC_ThresholdInterruptEnable()

void ADC_ThresholdInterruptEnable (void )

Sets the ADC Threshold Interrupt Enable bit to '1'.

Parameters:
None.
Returns:

None.

ADC_ThresholdInterruptFlagClear()

void ADC_ThresholdInterruptFlagClear (void )

Sets the ADC Threshold Interrupt Flag (ADTIF) bit to '0'.

Parameters:
None.
Returns:

None.

ADC_ThresholdISR()

void ADC_ThresholdISR (void )

Implements the ADC Threshold Interrupt (ADTI) service routine for the interrupt-driven implementations.

Parameters:
None.
Returns:

None.

ADC_ThresholdModeSet()

void ADC_ThresholdModeSet (adc_threshold_mode_t thresholdMode)

Sets the conversion threshold mode.

Parameters:
thresholdMode

Desired threshold mode. Refer to the adc_threshold_mode_t enum for the list of available threshold modes.

Returns:

None.

ADC_UpperThresholdSet()

void ADC_UpperThresholdSet (adc_threshold_t upperThreshold)

Sets the value of the ADC Upper Threshold (ADUTH) register.

Parameters:
upperThreshold

Upper threshold value of the adc_threshold_t type for the ADUTH register.

Returns:

None.

Enumeration Type Documentation
adc_calculation_mode_t

enum adc_calculation_mode_t

Enumeration for the ADC error calculation modes.

ADC_FIRST_DERIVATIVE_OF_SINGLE_MEASUREMENT

First derivative of single measurement

ADC_ACTUAL_RESULT_VS_SETPOINT

Actual result vs setpoint

ADC_ACTUAL_RESULT_VS_FILTERED_VALUE

Actual result vs filtered value

ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE

First derivative of filtered value

ADC_FILTERED_VALUE_VS_SETPOINT

Filtered value vs setpoint

ADC_FIRST_DERIVATIVE_OF_SINGLE_MEASUREMENT

First derivative of single measurement

ADC_ACTUAL_RESULT_VS_SETPOINT

Actual result vs setpoint

ADC_ACTUAL_RESULT_VS_FILTERED_VALUE

Actual result vs filtered value

ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE

First derivative of filtered value

ADC_FILTERED_VALUE_VS_SETPOINT

Filtered value vs setpoint

adc_channel_t

enum adc_channel_t

Enumeration for available ADC channels.

ADC_CHANNEL_VSS

VSS

ADC_CHANNEL_TEMP

Temp

ADC_CHANNEL_DAC1

DAC1

ADC_CHANNEL_FVR_BUFFER1

FVR_Buffer1

ADC_CHANNEL_FVR_BUFFER2

FVR_Buffer2

ADC_CHANNEL_ANA0

IO_RA0: RA0

ADC_CHANNEL_ANA2

IO_RA2: RA2

ADC_CHANNEL_ANA6

IO_RA6: RA6

ADC_CHANNEL_ANB2

IO_RB2: RB2

ADC_CHANNEL_ANB4

IO_RB4: RB4

ADC_CHANNEL_ANC1

IO_RC1: RC1

ADC_CHANNEL_VSS

VSS

ADC_CHANNEL_TEMP

Temp

ADC_CHANNEL_DAC1

DAC1

ADC_CHANNEL_FVR_BUFFER1

FVR_Buffer1

ADC_CHANNEL_FVR_BUFFER2

FVR_Buffer2

ADC_CHANNEL_ANA0

IO_RA0: RA0

ADC_CHANNEL_ANA2

IO_RA2: RA2

ADC_CHANNEL_ANA6

IO_RA6: RA6

ADC_CHANNEL_ANB2

IO_RB2: RB2

ADC_CHANNEL_ANB4

IO_RB4: RB4

ADC_CHANNEL_ANC1

IO_RC1: RC1

adc_computation_mode_t

enum adc_computation_mode_t

Enumeration for the ADC computation modes.

ADC_BASIC

Basic mode

ADC_SERIES_ACCUMULATE

Series Accumulate mode

ADC_SERIES_AVERAGE

Series Average mode

ADC_BURST_AVERAGE

Burst Average mode

ADC_LOW_PASS_FILTER

Low-Pass Filter mode

ADC_BASIC

Basic mode

ADC_SERIES_ACCUMULATE

Series Accumulate mode

ADC_SERIES_AVERAGE

Series Average mode

ADC_BURST_AVERAGE

Burst Average mode

ADC_LOW_PASS_FILTER

Low-Pass Filter mode

adc_conversion_stage_t

enum adc_conversion_stage_t

Enumeration for the ADC conversion stage statuses.

ADC_NOT_CONVERTING

Not converting

ADC_1ST_PRECHARGE

1st precharge

ADC_1ST_ACQUISITION

1st acquisition

ADC_1ST_CONVERSION

1st conversion

ADC_SUSPENDED_BETWEEN_1ST_AND_2ND_SAMPLE

Suspended between 1st and 2nd sample

ADC_2ST_PRECHARGE

2st precharge

ADC_2ST_ACQUISITION

2st acquisition

ADC_2ST_CONVERSION

2st conversion

ADC_NOT_CONVERTING

Not converting

ADC_1ST_PRECHARGE

1st precharge

ADC_1ST_ACQUISITION

1st acquisition

ADC_1ST_CONVERSION

1st conversion

ADC_SUSPENDED_BETWEEN_1ST_AND_2ND_SAMPLE

Suspended between 1st and 2nd sample

ADC_2ST_PRECHARGE

2st precharge

ADC_2ST_ACQUISITION

2st acquisition

ADC_2ST_CONVERSION

2st conversion

adc_threshold_mode_t

enum adc_threshold_mode_t

Enumeration for the ADC threshold modes.

ADC_NEVER_INTERRUPT

Disabled

ADC_BELOW_LOWER_THRESHOLD

ADERR < ADLTH

ADC_ABOVE_LOWER_THRESHOLD

ADERR >= ADLTH

ADC_INSIDE_LOWER_AND_UPPER_THRESHOLD

ADERR > ADLTH and ADERR < ADUTH

ADC_OUTSIDE_LOWER_AND_UPPER_THRESHOLD

ADERR < ADLTH or ADERR > ADUTH

ADC_BELOW_UPPER_THRESHOLD

ADERR <= ADUTH

ADC_ABOVE_UPPER_THRESHOLD

ADERR > ADUTH

ADC_ALWAYS_INTERRUPT

Enabled

ADC_NEVER_INTERRUPT

Disabled

ADC_BELOW_LOWER_THRESHOLD

ADERR < ADLTH

ADC_ABOVE_LOWER_THRESHOLD

ADERR >= ADLTH

ADC_INSIDE_LOWER_AND_UPPER_THRESHOLD

ADERR > ADLTH and ADERR < ADUTH

ADC_OUTSIDE_LOWER_AND_UPPER_THRESHOLD

ADERR < ADLTH or ADERR > ADUTH

ADC_BELOW_UPPER_THRESHOLD

ADERR <= ADUTH

ADC_ABOVE_UPPER_THRESHOLD

ADERR > ADUTH

ADC_ALWAYS_INTERRUPT

Enabled

adc_trigger_source_t

enum adc_trigger_source_t

Enumeration for the ADC auto-trigger sources.

ADC_TRIGGER_SOURCE_DISABLED

Disabled

ADC_TRIGGER_SOURCE_ADACTPPS

ADACTPPS

ADC_TRIGGER_SOURCE_TMR0

TMR0

ADC_TRIGGER_SOURCE_TMR1

TMR1

ADC_TRIGGER_SOURCE_TMR2

TMR2

ADC_TRIGGER_SOURCE_TMR3

TMR3

ADC_TRIGGER_SOURCE_TMR4

TMR4

ADC_TRIGGER_SOURCE_TMR5

TMR5

ADC_TRIGGER_SOURCE_TMR6

TMR6

ADC_TRIGGER_SOURCE_SMT1_OVERFLOW

SMT1_Overflow

ADC_TRIGGER_SOURCE_CCP1

CCP1

ADC_TRIGGER_SOURCE_CCP2

CCP2

ADC_TRIGGER_SOURCE_CCP3

CCP3

ADC_TRIGGER_SOURCE_PWM1_OUT1

PWM1_OUT1

ADC_TRIGGER_SOURCE_PWM1_OUT2

PWM1_OUT2

ADC_TRIGGER_SOURCE_PWM2_OUT1

PWM2_OUT1

ADC_TRIGGER_SOURCE_PWM2_OUT2

PWM2_OUT2

ADC_TRIGGER_SOURCE_PWM3_OUT1

PWM3_OUT1

ADC_TRIGGER_SOURCE_PWM3_OUT2

PWM3_OUT2

ADC_TRIGGER_SOURCE_NCO1

NCO1

ADC_TRIGGER_SOURCE_NCO2

NCO2

ADC_TRIGGER_SOURCE_NCO3

NCO3

ADC_TRIGGER_SOURCE_CMP1

CMP1

ADC_TRIGGER_SOURCE_CMP2

CMP2

ADC_TRIGGER_SOURCE_LOGICAL_OR_OF_ALL_IOC_FLAGS

Logical OR of all IOC flags

ADC_TRIGGER_SOURCE_CLC1

CLC1

ADC_TRIGGER_SOURCE_CLC2

CLC2

ADC_TRIGGER_SOURCE_CLC3

CLC3

ADC_TRIGGER_SOURCE_CLC4

CLC4

ADC_TRIGGER_SOURCE_CLC5

CLC5

ADC_TRIGGER_SOURCE_CLC6

CLC6

ADC_TRIGGER_SOURCE_CLC7

CLC7

ADC_TRIGGER_SOURCE_CLC8

CLC8

ADC_TRIGGER_SOURCE_ADERRH

ADERRH

ADC_TRIGGER_SOURCE_ADRESH

ADRESH

ADC_TRIGGER_SOURCE_ADPCH

ADPCH

ADC_TRIGGER_SOURCE_DISABLED

Disabled

ADC_TRIGGER_SOURCE_ADACTPPS

ADACTPPS

ADC_TRIGGER_SOURCE_TMR0

TMR0

ADC_TRIGGER_SOURCE_TMR1

TMR1

ADC_TRIGGER_SOURCE_TMR2

TMR2

ADC_TRIGGER_SOURCE_TMR3

TMR3

ADC_TRIGGER_SOURCE_TMR4

TMR4

ADC_TRIGGER_SOURCE_TMR5

TMR5

ADC_TRIGGER_SOURCE_TMR6

TMR6

ADC_TRIGGER_SOURCE_SMT1_OVERFLOW

SMT1_Overflow

ADC_TRIGGER_SOURCE_CCP1

CCP1

ADC_TRIGGER_SOURCE_CCP2

CCP2

ADC_TRIGGER_SOURCE_CCP3

CCP3

ADC_TRIGGER_SOURCE_PWM1_OUT1

PWM1_OUT1

ADC_TRIGGER_SOURCE_PWM1_OUT2

PWM1_OUT2

ADC_TRIGGER_SOURCE_PWM2_OUT1

PWM2_OUT1

ADC_TRIGGER_SOURCE_PWM2_OUT2

PWM2_OUT2

ADC_TRIGGER_SOURCE_PWM3_OUT1

PWM3_OUT1

ADC_TRIGGER_SOURCE_PWM3_OUT2

PWM3_OUT2

ADC_TRIGGER_SOURCE_NCO1

NCO1

ADC_TRIGGER_SOURCE_NCO2

NCO2

ADC_TRIGGER_SOURCE_NCO3

NCO3

ADC_TRIGGER_SOURCE_CMP1

CMP1

ADC_TRIGGER_SOURCE_CMP2

CMP2

ADC_TRIGGER_SOURCE_LOGICAL_OR_OF_ALL_IOC_FLAGS

Logical OR of all IOC flags

ADC_TRIGGER_SOURCE_CLC1

CLC1

ADC_TRIGGER_SOURCE_CLC2

CLC2

ADC_TRIGGER_SOURCE_CLC3

CLC3

ADC_TRIGGER_SOURCE_CLC4

CLC4

ADC_TRIGGER_SOURCE_CLC5

CLC5

ADC_TRIGGER_SOURCE_CLC6

CLC6

ADC_TRIGGER_SOURCE_CLC7

CLC7

ADC_TRIGGER_SOURCE_CLC8

CLC8

ADC_TRIGGER_SOURCE_ADERRH

ADERRH

ADC_TRIGGER_SOURCE_ADRESH

ADRESH

ADC_TRIGGER_SOURCE_ADPCH

ADPCH

File Documentation

source/single-ended-interrupts/adc/adc.h File Reference

#include <stdint.h>
#include <stdbool.h>
#include "./adc_types.h"
Functions
Macros
Detailed Description

ADC Generated Driver API Header File

source/single-ended-tasks/adc/adc.h File Reference

#include <stdint.h>
#include <stdbool.h>
#include "./adc_types.h"
Functions
Macros
Detailed Description

ADC Generated Driver API Header File

source/single-ended-interrupts/adc/adc_types.h File Reference

Enumerations
Detailed Description

ADC Type Definitions Header File

source/single-ended-tasks/adc/adc_types.h File Reference

Enumerations
Detailed Description

ADC Type Definitions Header File

Typedef Documentation
adc_accumulate_t

typedef int32_t adc_accumulate_t

adc_repeat_count_t

typedef uint8_t adc_repeat_count_t

adc_result_t

typedef int16_t adc_result_t

adc_threshold_t

typedef int16_t adc_threshold_t

Enumeration Type Documentation
adc_calculation_mode_t

enum adc_calculation_mode_t

ADC_FIRST_DERIVATIVE_OF_SINGLE_MEASUREMENT

First derivative of single measurement

ADC_ACTUAL_RESULT_VS_SETPOINT

Actual result vs setpoint

ADC_ACTUAL_RESULT_VS_FILTERED_VALUE

Actual result vs filtered value

ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE

First derivative of filtered value

ADC_FILTERED_VALUE_VS_SETPOINT

Filtered value vs setpoint

ADC_FIRST_DERIVATIVE_OF_SINGLE_MEASUREMENT

First derivative of single measurement

ADC_ACTUAL_RESULT_VS_SETPOINT

Actual result vs setpoint

ADC_ACTUAL_RESULT_VS_FILTERED_VALUE

Actual result vs filtered value

ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE

First derivative of filtered value

ADC_FILTERED_VALUE_VS_SETPOINT

Filtered value vs setpoint

adc_channel_t

enum adc_channel_t

ADC_CHANNEL_VSS

VSS

ADC_CHANNEL_TEMP

Temp

ADC_CHANNEL_DAC1

DAC1

ADC_CHANNEL_FVR_BUFFER1

FVR_Buffer1

ADC_CHANNEL_FVR_BUFFER2

FVR_Buffer2

ADC_CHANNEL_ANA0

IO_RA0: RA0

ADC_CHANNEL_ANA2

IO_RA2: RA2

ADC_CHANNEL_ANA6

IO_RA6: RA6

ADC_CHANNEL_ANB2

IO_RB2: RB2

ADC_CHANNEL_ANB4

IO_RB4: RB4

ADC_CHANNEL_ANC1

IO_RC1: RC1

ADC_CHANNEL_VSS

VSS

ADC_CHANNEL_TEMP

Temp

ADC_CHANNEL_DAC1

DAC1

ADC_CHANNEL_FVR_BUFFER1

FVR_Buffer1

ADC_CHANNEL_FVR_BUFFER2

FVR_Buffer2

ADC_CHANNEL_ANA0

IO_RA0: RA0

ADC_CHANNEL_ANA2

IO_RA2: RA2

ADC_CHANNEL_ANA6

IO_RA6: RA6

ADC_CHANNEL_ANB2

IO_RB2: RB2

ADC_CHANNEL_ANB4

IO_RB4: RB4

ADC_CHANNEL_ANC1

IO_RC1: RC1

adc_computation_mode_t

enum adc_computation_mode_t

ADC_BASIC

Basic mode

ADC_SERIES_ACCUMULATE

Series Accumulate mode

ADC_SERIES_AVERAGE

Series Average mode

ADC_BURST_AVERAGE

Burst Average mode

ADC_LOW_PASS_FILTER

Low-Pass Filter mode

ADC_BASIC

Basic mode

ADC_SERIES_ACCUMULATE

Series Accumulate mode

ADC_SERIES_AVERAGE

Series Average mode

ADC_BURST_AVERAGE

Burst Average mode

ADC_LOW_PASS_FILTER

Low-Pass Filter mode

adc_conversion_stage_t

enum adc_conversion_stage_t

ADC_NOT_CONVERTING

Not converting

ADC_1ST_PRECHARGE

1st precharge

ADC_1ST_ACQUISITION

1st acquisition

ADC_1ST_CONVERSION

1st conversion

ADC_SUSPENDED_BETWEEN_1ST_AND_2ND_SAMPLE

Suspended between 1st and 2nd sample

ADC_2ST_PRECHARGE

2st precharge

ADC_2ST_ACQUISITION

2st acquisition

ADC_2ST_CONVERSION

2st conversion

ADC_NOT_CONVERTING

Not converting

ADC_1ST_PRECHARGE

1st precharge

ADC_1ST_ACQUISITION

1st acquisition

ADC_1ST_CONVERSION

1st conversion

ADC_SUSPENDED_BETWEEN_1ST_AND_2ND_SAMPLE

Suspended between 1st and 2nd sample

ADC_2ST_PRECHARGE

2st precharge

ADC_2ST_ACQUISITION

2st acquisition

ADC_2ST_CONVERSION

2st conversion

adc_threshold_mode_t

enum adc_threshold_mode_t

ADC_NEVER_INTERRUPT

Disabled

ADC_BELOW_LOWER_THRESHOLD

ADERR < ADLTH

ADC_ABOVE_LOWER_THRESHOLD

ADERR >= ADLTH

ADC_INSIDE_LOWER_AND_UPPER_THRESHOLD

ADERR > ADLTH and ADERR < ADUTH

ADC_OUTSIDE_LOWER_AND_UPPER_THRESHOLD

ADERR < ADLTH or ADERR > ADUTH

ADC_BELOW_UPPER_THRESHOLD

ADERR <= ADUTH

ADC_ABOVE_UPPER_THRESHOLD

ADERR > ADUTH

ADC_ALWAYS_INTERRUPT

Enabled

ADC_NEVER_INTERRUPT

Disabled

ADC_BELOW_LOWER_THRESHOLD

ADERR < ADLTH

ADC_ABOVE_LOWER_THRESHOLD

ADERR >= ADLTH

ADC_INSIDE_LOWER_AND_UPPER_THRESHOLD

ADERR > ADLTH and ADERR < ADUTH

ADC_OUTSIDE_LOWER_AND_UPPER_THRESHOLD

ADERR < ADLTH or ADERR > ADUTH

ADC_BELOW_UPPER_THRESHOLD

ADERR <= ADUTH

ADC_ABOVE_UPPER_THRESHOLD

ADERR > ADUTH

ADC_ALWAYS_INTERRUPT

Enabled

adc_trigger_source_t

enum adc_trigger_source_t

ADC_TRIGGER_SOURCE_DISABLED

Disabled

ADC_TRIGGER_SOURCE_ADACTPPS

ADACTPPS

ADC_TRIGGER_SOURCE_TMR0

TMR0

ADC_TRIGGER_SOURCE_TMR1

TMR1

ADC_TRIGGER_SOURCE_TMR2

TMR2

ADC_TRIGGER_SOURCE_TMR3

TMR3

ADC_TRIGGER_SOURCE_TMR4

TMR4

ADC_TRIGGER_SOURCE_TMR5

TMR5

ADC_TRIGGER_SOURCE_TMR6

TMR6

ADC_TRIGGER_SOURCE_SMT1_OVERFLOW

SMT1_Overflow

ADC_TRIGGER_SOURCE_CCP1

CCP1

ADC_TRIGGER_SOURCE_CCP2

CCP2

ADC_TRIGGER_SOURCE_CCP3

CCP3

ADC_TRIGGER_SOURCE_PWM1_OUT1

PWM1_OUT1

ADC_TRIGGER_SOURCE_PWM1_OUT2

PWM1_OUT2

ADC_TRIGGER_SOURCE_PWM2_OUT1

PWM2_OUT1

ADC_TRIGGER_SOURCE_PWM2_OUT2

PWM2_OUT2

ADC_TRIGGER_SOURCE_PWM3_OUT1

PWM3_OUT1

ADC_TRIGGER_SOURCE_PWM3_OUT2

PWM3_OUT2

ADC_TRIGGER_SOURCE_NCO1

NCO1

ADC_TRIGGER_SOURCE_NCO2

NCO2

ADC_TRIGGER_SOURCE_NCO3

NCO3

ADC_TRIGGER_SOURCE_CMP1

CMP1

ADC_TRIGGER_SOURCE_CMP2

CMP2

ADC_TRIGGER_SOURCE_LOGICAL_OR_OF_ALL_IOC_FLAGS

Logical OR of all IOC flags

ADC_TRIGGER_SOURCE_CLC1

CLC1

ADC_TRIGGER_SOURCE_CLC2

CLC2

ADC_TRIGGER_SOURCE_CLC3

CLC3

ADC_TRIGGER_SOURCE_CLC4

CLC4

ADC_TRIGGER_SOURCE_CLC5

CLC5

ADC_TRIGGER_SOURCE_CLC6

CLC6

ADC_TRIGGER_SOURCE_CLC7

CLC7

ADC_TRIGGER_SOURCE_CLC8

CLC8

ADC_TRIGGER_SOURCE_ADERRH

ADERRH

ADC_TRIGGER_SOURCE_ADRESH

ADRESH

ADC_TRIGGER_SOURCE_ADPCH

ADPCH

ADC_TRIGGER_SOURCE_DISABLED

Disabled

ADC_TRIGGER_SOURCE_ADACTPPS

ADACTPPS

ADC_TRIGGER_SOURCE_TMR0

TMR0

ADC_TRIGGER_SOURCE_TMR1

TMR1

ADC_TRIGGER_SOURCE_TMR2

TMR2

ADC_TRIGGER_SOURCE_TMR3

TMR3

ADC_TRIGGER_SOURCE_TMR4

TMR4

ADC_TRIGGER_SOURCE_TMR5

TMR5

ADC_TRIGGER_SOURCE_TMR6

TMR6

ADC_TRIGGER_SOURCE_SMT1_OVERFLOW

SMT1_Overflow

ADC_TRIGGER_SOURCE_CCP1

CCP1

ADC_TRIGGER_SOURCE_CCP2

CCP2

ADC_TRIGGER_SOURCE_CCP3

CCP3

ADC_TRIGGER_SOURCE_PWM1_OUT1

PWM1_OUT1

ADC_TRIGGER_SOURCE_PWM1_OUT2

PWM1_OUT2

ADC_TRIGGER_SOURCE_PWM2_OUT1

PWM2_OUT1

ADC_TRIGGER_SOURCE_PWM2_OUT2

PWM2_OUT2

ADC_TRIGGER_SOURCE_PWM3_OUT1

PWM3_OUT1

ADC_TRIGGER_SOURCE_PWM3_OUT2

PWM3_OUT2

ADC_TRIGGER_SOURCE_NCO1

NCO1

ADC_TRIGGER_SOURCE_NCO2

NCO2

ADC_TRIGGER_SOURCE_NCO3

NCO3

ADC_TRIGGER_SOURCE_CMP1

CMP1

ADC_TRIGGER_SOURCE_CMP2

CMP2

ADC_TRIGGER_SOURCE_LOGICAL_OR_OF_ALL_IOC_FLAGS

Logical OR of all IOC flags

ADC_TRIGGER_SOURCE_CLC1

CLC1

ADC_TRIGGER_SOURCE_CLC2

CLC2

ADC_TRIGGER_SOURCE_CLC3

CLC3

ADC_TRIGGER_SOURCE_CLC4

CLC4

ADC_TRIGGER_SOURCE_CLC5

CLC5

ADC_TRIGGER_SOURCE_CLC6

CLC6

ADC_TRIGGER_SOURCE_CLC7

CLC7

ADC_TRIGGER_SOURCE_CLC8

CLC8

ADC_TRIGGER_SOURCE_ADERRH

ADERRH

ADC_TRIGGER_SOURCE_ADRESH

ADRESH

ADC_TRIGGER_SOURCE_ADPCH

ADPCH

source/single-ended-interrupts/adc/src/adc.c File Reference

This file contains the API implementations for the ADC driver.

#include <xc.h>
#include "../adc.h"
#include "../adc_types.h"
Functions
Detailed Description

This file contains the API implementations for the ADC driver.

ADC Generated Driver File

Version: ADC Driver Version 3.0.0 ADC Package Version 5.0.0
Variable Documentation
adc_busy_status

bool adc_busy_status[static]

ADC_ConversionDoneCallback

void(* ADC_ConversionDoneCallback) (void)[static]

ADC_ThresholdCallback

void(* ADC_ThresholdCallback) (void)[static]

source/single-ended-tasks/adc/src/adc.c File Reference

This file contains the API implementations for the ADC driver.

#include <xc.h>
#include "../adc.h"
#include "../adc_types.h"
Functions
Detailed Description

This file contains the API implementations for the ADC driver.

ADC Generated Driver File

Version: ADC Driver Version 3.0.0 ADC Package Version 5.0.0
Variable Documentation
adc_busy_status

bool adc_busy_status[static]

ADC_ConversionDoneCallback

void(* ADC_ConversionDoneCallback) (void)[static]

ADC_ThresholdCallback

void(* ADC_ThresholdCallback) (void)[static]

Module Documentation

ADCC Use Cases

ADCC Use Case Code Snippet Instructions

For new users it is recommended to start with the Timer0, UART and Data Streamer, since these components are used to support other use cases.

The use cases show example uses of the ADCC PLIB Driver, within an MCC Melody project:
  • Add ADCC to the project

  • Configure:
    1. The ADCC as described in the example.

    2. Any other peripherals or pins needed for the use case.

  • Generate the code

  • Add the code snippet(s) to the application code

  • Program the board

ADC Use Case 1: ADCC in Basic_mode with Printf of ADC Result

An ADC conversion is taken every 100 ms, on the selected analog channel. After each ADC conversion a LED is toggled and the ADC Result is sent to PC terminal using printf.

Note: Before each conversion is started, the sample capacitor is first discharged, by connecting it to the ground potential of the microcontroller.

Device Resources:
  1. Add ADCC

  2. Add UART

ADCC Configuration:
  • Hardware Settings:
    1. Operating Mode: Basic Mode (Default)

UART:
  • Configuration Settings:
    1. Redirect Printf to UART: Yes.

  • Dependency Selector:  

    1. UART PLIB Selector: Select the UART that is connected to Serial/CDC port.

    2. Redirect STDIO to UART (for printf support): Yes

System:
  • Clock Configuration: Default (1 MHz)

  • Pins: (For all pins check board schematics)
    1. Pin Grid View: Select an ANx.

    2. Pin Grid View: Select pin for UART Transmit - Tx.

    3. Pin Grid View: Select LED pin as output.  

    4. Pins: Rename Custom Name to "LED".

After configuring the components as described above, click 'Generate' to generate the code. Then add the following code snippets to your application:

/* Required header files for UART Example 1 */
#include "mcc_generated_files/system/system.h"
int main(void)
{
    SYSTEM_Initialize();
    
    uint16_t volatile adcResult;

    while(1)
    {
        ADCC_DischargeSampleCapacitor();   //Discharge capacitor voltage by connecting the VSS channel
        adcResult = ADCC_GetSingleConversion(channel_ANC3); //Get the conversion result
        LED_Toggle();
        printf("The ADC Result is: %d\r\n",adcResult);

        __delay_ms(100);  
    }
}
ADC Use Case 2: ADCC Samples Visualized with the Data Streamer
An ADC conversion is taken, on the selected analog channel, every 100 ms.
  • ADC converstions are triggerd by an timer overflow callback, where the Data Streamer variables adcResult and adcSampleCount are updated.

  • After each ADC conversion a LED is toggled and SEND_FRAME is set to true, so that a frame is sent to the Data Visualizer from the main while loop.

Device Resources:
  1. Add ADCC

  2. Add Timer (Use Case: 100 ms Timer)

  3. Add Data Streamer (Use Case: Send Frames at a Period Set by the Timer)

ADCC:
  • Hardware Settings:
    1. Operating Mode: Basic Mode (Default)

Data Streamer:  

  • Software Settings:
    1. UART Dependency Selection: Select the UART that is connected to Serial/CDC port.

  • Data Streamer Table:
    1. uint16_t adcResult

    2. uint8_t adcSampleCount

System:
  • Clock Configuration: Default (1 MHz)

  • Pins: (For all pins check board schematics)
    1. Pin Grid View: Select an ANx.  

    2. Pin Grid View: Select pin for UART Transmit - Tx.  

    3. Pin Grid View: Select LED pin as output.  

    4. Pin Grid View: Select Debug GPIO pin.

    5. Pins: Rename Custom Names to "LED" and "DebugIO" respectively.

After configuring the components as described above, click 'Generate' to generate the code. Then add the following code snippets to your application:

D,1,1,adcResult
B,1,1,adcSampleCount
#include "mcc_generated_files/system/system.h"

/* Create a pointer of type TMR_INTERFACE and assign it to the address of the Timer0 TMR_INTERFACE struct.
This enables us to get access the portable API interface, which ensures that it's easy to change the peripheral instance the timer runs on. */
const struct TMR_INTERFACE *Timer = &Timer0;
volatile bool SEND_FRAME = false;
void Timer_Callback_100ms(void){
    ADCC_DischargeSampleCapacitor();   //Discharge capacitor voltage by connecting the VSS channel
    Data_Streamer.adcResult = ADCC_GetSingleConversion(channel_ANC3); //Get the conversion result
    Data_Streamer.adcSampleCount++;
    LED_Toggle();
    SEND_FRAME = true;
}
int main(void)
{
    SYSTEM_Initialize();
    
    Data_Streamer.adcSampleCount = 0;
    Data_Streamer.adcResult = 0;
    
    Timer->TimeoutCallbackRegister(Timer_Callback_100ms);
    
    INTERRUPT_GlobalInterruptEnable();

    while(1)
    {
        if(SEND_FRAME){
            WriteFrame();
            SEND_FRAME = false;
        }
    }
}
ADC Use Case 3: ADCC Spike Detection Visualized with the Data Streamer

A change (above a set threshold) in the ADC result between successive conversions, represents a "spike". When a spike is detected, an callback updates the adcResult_lastSpike and adcSpikeCount variables.

Tested using PIC18F16Q41 CNANO board and potentiometer. When quickly turning the potentiometer a spike is detected.

Device Resources:
  1. Add ADCC

  2. Add Data Streamer

  3. Add Timer (Use Case: 100 ms Timer)

ADCC:  

  • Hardware Settings:
    1. Set Operating Mode: Basic_mode (default)

  • Computation Feature:
    1. Threshold Interrupt Mode: ADERR < ADLTH or ADERR > ADUTH.

    2. Lower Threshold: -35

    3. Upper Threshold: 35

  • Interrupt Settings:
    1. ADC Threshold Interrupt: Yes

Data Streamer:  

  • Software Settings:
    1. UART Dependency Selection: Select the UART that is connected to Serial/CDC port.

  • Data Streamer Table:
    1. Add variable: uint16_t adcResult  

    2. Add variable: uint16_t adcResult_lastSpike

    3. Add variable: uint8_t adcSpikeCount

System:
  • Clock Configuration: Default (1 MHz)

  • Pins: (For all pins check board schematics)
    1. Pin Grid View: Select an ANx.  

    2. Pin Grid View: Select pin for UART Transmit - Tx.  

    3. Pin Grid View: Select LED pin as output.  

    4. Pin Grid View: Select Debug GPIO pin.

    5. Pins: Rename Custom Names to "LED" and "DebugIO" respectively.

After configuring the components as described above, click 'Generate' to generate the code. Then add the following code snippets to your application:

D,1,1,adcResult
D,1,1,adcResult_lastSpike
B,1,1,adcSpikeCount
#include "mcc_generated_files/system/system.h"
const struct TMR_INTERFACE *Timer = &Timer0;
volatile bool SEND_FRAME = false;
void ADCC_Callback_SpikeThreashold(void){
    Data_Streamer.adcResult_lastSpike = ADCC_GetConversionResult();
    Data_Streamer.adcSpikeCount++;
    LED_Toggle();
    DebugIO_Toggle();
    SEND_FRAME = true;
}

void Timer_Callback_100ms(void){
    ADCC_DischargeSampleCapacitor();         //Discharge capacitor voltage by connecting the VSS channel
    Data_Streamer.adcResult =  ADCC_GetSingleConversion(channel_ANC3); //Replace with suitable analog input - consulting your schematic 
    FRAME_SEND = true;
}
int main(void)
{
    SYSTEM_Initialize();
    
    Data_Streamer.adcSpikeCount = 0;
    Data_Streamer.adcResult_lastSpike = 0;
    Data_Streamer.adcResult = 0;

    Timer->TimeoutCallbackRegister(Timer_Callback_100ms);
    ADCC_SetADTIInterruptHandler(ADCC_Callback_SpikeThreashold);
    INTERRUPT_GlobalInterruptEnable();

    while(1)
    {
        if(SEND_FRAME){
            WriteFrame();
            SEND_FRAME = false;
        }
    }
}
ADC Use Case 3.5: Modifying the Spike Detection Sensitivity:

Observe the change in sensitivity with the following settings...

ADCC:
  • Hardware Settings:
    1. Set Operating Mode : Average_mode

  • Computation Feature:
    1. Set Repeat: 4

    2. Set Accumulator Right Shift : 1