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
PIC16F184xx | PIC16F191xx | PIC18F-K42 | PIC18F-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
- 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 the PC terminal using printf.
- 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.
- ADC Use Case 3: ADCC Spike Detection Visualized with the Data Streamer Follow Data Streamer Use Cases starting from Data Streamer Use case 3: Send frames, at period set by timer, Add theADCC, then configure as in Data Streamer Use case 2: ADCC Spike Detection.
- ADC Use Case 3.5: Modifying the Spike Detection Sensitivity: Observe the change in sensitivity with the following settings.
- Recommended starting point: UART Driver, Timer0 PLIB Driver and the Data Streamer Library.
- Videos also included for: ADCC PLIB Driver.
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.
Typedefs
typedef int16_t adc_result_t
ADC conversion result type.
typedef int32_t adc_accumulate_t
ADC conversion accumulator type.
typedef int16_t adc_threshold_t
ADC conversion threshold type.
typedef uint8_t adc_repeat_count_t
ADC conversion repeat count type.
Definitions
#define IO_RA0 ADC_CHANNEL_ANA0
Defines the Custom Name pin mapping for channels in adc_channel_t.
#define CustomName_Initialize ADC_Initialize
Defines the Custom Name API mapping for ADC_Initialize.
#define CustomName_Deinitialize ADC_Deinitialize
Defines the Custom Name API mapping for ADC_Deinitialize.
#define CustomName_Enable ADC_Enable
Defines the Custom Name API mapping for ADC_Enable.
#define CustomName_Disable ADC_Disable
Defines the Custom Name API mapping for ADC_Disable.
#define CustomName_ConversionStart ADC_ConversionStart
Defines the Custom Name API mapping for ADC_ConversionStart.
#define CustomName_IsConversionDone ADC_IsConversionDone
Defines the Custom Name API mapping for ADC_IsConversionDone.
#define CustomName_ConversionResultGet ADC_ConversionResultGet
Defines the Custom Name API mapping for ADC_ConversionResultGet.
#define CustomName_ResolutionGet ADC_ResolutionGet
Defines the Custom Name API mapping for ADC_ResolutionGet.
#define CustomName_IsBusy ADC_IsBusy
Defines the Custom Name API mapping for ADC_IsBusy.
#define CustomName_BusyStatusSet ADC_BusyStatusSet
Defines the Custom Name API mapping for ADC_BusyStatusSet.
#define CustomName_ConversionDoneCallbackRegister ADC_ConversionDoneCallbackRegister
Defines the Custom Name API mapping for ADC_ConversionDoneCallbackRegister.
#define CustomName_ChannelSelect ADC_ChannelSelect
Defines the Custom Name API mapping for ADC_ChannelSelect.
#define CustomName_ChannelSelectAndConvert ADC_ChannelSelectAndConvert
Defines the Custom Name API mapping for ADC_ChannelSelectAndConvert.
#define CustomName_ConversionDoneInterruptEnable ADC_ConversionDoneInterruptEnable
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptEnable.
#define CustomName_ConversionDoneInterruptDisable ADC_ConversionDoneInterruptDisable
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptDisable.
#define CustomName_ConversionStop ADC_ConversionStop
Defines the Custom Name API mapping for ADC_ConversionStop.
#define CustomName_SampleRepeatCountSet ADC_SampleRepeatCountSet
Defines the Custom Name API mapping for ADC_SampleRepeatCountSet.
#define CustomName_ComputationModeSet ADC_ComputationModeSet
Defines the Custom Name API mapping for ADC_ComputationModeSet.
#define CustomName_UpperThresholdSet ADC_UpperThresholdSet
Defines the Custom Name API mapping for ADC_UpperThresholdSet.
#define CustomName_LowerThresholdSet ADC_LowerThresholdSet
Defines the Custom Name API mapping for ADC_LowerThresholdSet.
#define CustomName_ThresholdModeSet ADC_ThresholdModeSet
Defines the Custom Name API mapping for ADC_ThresholdModeSet.
#define CustomName_AccumulatedResultGet ADC_AccumulatedResultGet
Defines the Custom Name API mapping for ADC_AccumulatedResultGet.
#define CustomName_ThresholdCallbackRegister ADC_ThresholdCallbackRegister
Defines the Custom Name API mapping for ADC_ThresholdCallbackRegister.
#define CustomName_ThresholdInterruptEnable ADC_ThresholdInterruptEnable
Defines the Custom Name API mapping for ADC_ThresholdInterruptEnable.
#define CustomName_ThresholdInterruptDisable ADC_ThresholdInterruptDisable
Defines the Custom Name API mapping for ADC_ThresholdInterruptDisable.
#define CustomName_IsConversionDoneInterruptFlagSet ADC_IsConversionDoneInterruptFlagSet
Defines the Custom Name API mapping for ADC_IsConversionDoneInterruptFlagSet.
#define CustomName_IsThresholdInterruptFlagSet ADC_IsThresholdInterruptFlagSet
Defines the Custom Name API mapping for ADC_IsThresholdInterruptFlagSet.
#define CustomName_ConversionDoneInterruptFlagClear ADC_ConversionDoneInterruptFlagClear
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptFlagClear.
#define CustomName_ThresholdInterruptFlagClear ADC_ThresholdInterruptFlagClear
Defines the Custom Name API mapping for ADC_ThresholdInterruptFlagClear.
#define CustomName_StopOnInterruptEnable ADC_StopOnInterruptEnable
Defines the Custom Name API mapping for ADC_StopOnInterruptEnable.
#define CustomName_StopOnInterruptDisable ADC_StopOnInterruptDisable
Defines the Custom Name API mapping for ADC_StopOnInterruptDisable.
#define CustomName_ChargePumpEnable ADC_ChargePumpEnable
Defines the Custom Name API mapping for ADC_ChargePumpEnable.
#define CustomName_ChargePumpDisable ADC_ChargePumpDisable
Defines the Custom Name API mapping for ADC_ChargePumpDisable.
#define CustomName_IsChargePumpReady ADC_IsChargePumpReady
Defines the Custom Name API mapping for ADC_IsChargePumpReady.
#define CustomName_SampleCapacitorDischarge ADC_SampleCapacitorDischarge
Defines the Custom Name API mapping for ADC_SampleCapacitorDischarge.
#define CustomName_AcquisitionTimeSet ADC_AcquisitionTimeSet
Defines the Custom Name API mapping for ADC_AcquisitionTimeSet.
#define CustomName_PrechargeTimeSet ADC_PrechargeTimeSet
Defines the Custom Name API mapping for ADC_PrechargeTimeSet.
#define CustomName_CurrentConversionCountGet ADC_CurrentConversionCountGet
Defines the Custom Name API mapping for ADC_CurrentConversionCountGet.
#define CustomName_AccumulatorClear ADC_AccumulatorClear
Defines the Custom Name API mapping for ADC_AccumulatorClear.
#define CustomName_IsAccumulatorClearComplete ADC_IsAccumulatorClearComplete
Defines the Custom Name API mapping for ADC_IsAccumulatorClearComplete.
#define CustomName_HasAccumulatorOverflowed ADC_HasAccumulatorOverflowed
Defines the Custom Name API mapping for ADC_HasAccumulatorOverflowed.
#define CustomName_FilterValueGet ADC_FilterValueGet
Defines the Custom Name API mapping for ADC_FilterValueGet.
#define CustomName_PreviousResultGet ADC_PreviousResultGet
Defines the Custom Name API mapping for ADC_PreviousResultGet.
#define CustomName_SetPointDefine ADC_SetPointDefine
Defines the Custom Name API mapping for ADC_SetPointDefine.
#define CustomName_ErrorCalculationGet ADC_ErrorCalculationGet
Defines the Custom Name API mapping for ADC_ErrorCalculationGet.
#define CustomName_DoubleSamplingEnable ADC_DoubleSamplingEnable
Defines the Custom Name API mapping for ADC_DoubleSamplingEnable.
#define CustomName_DoubleSamplingDisable ADC_DoubleSamplingDisable
Defines the Custom Name API mapping for ADC_DoubleSamplingDisable.
#define CustomName_ContinuousConversionEnable ADC_ContinuousConversionEnable
Defines the Custom Name API mapping for ADC_ContinuousConversionEnable.
#define CustomName_ContinuousConversionDisable ADC_ContinuousConversionDisable
Defines the Custom Name API mapping for ADC_ContinuousConversionDisable.
#define CustomName_IsErrorGreaterThanUpperThreshold ADC_IsErrorGreaterThanUpperThreshold
Defines the Custom Name API mapping for ADC_IsErrorGreaterThanUpperThreshold.
#define CustomName_IsErrorLesserThanLowerThreshold ADC_IsErrorLesserThanLowerThreshold
Defines the Custom Name API mapping for ADC_IsErrorLesserThanLowerThreshold.
#define CustomName_ConversionStageStatusGet ADC_ConversionStageStatusGet
Defines the Custom Name API mapping for ADC_ConversionStageStatusGet.
#define CustomName_AutoTriggerSourceSet ADC_AutoTriggerSourceSet
Defines the Custom Name API mapping for ADC_AutoTriggerSourceSet.
#define CustomName_ErrorCalculationModeSet ADC_ErrorCalculationModeSet
Defines the Custom Name API mapping for ADC_ErrorCalculationModeSet.
#define CustomName_CalculationRightShiftSet ADC_CalculationRightShiftSet
Defines the Custom Name API mapping for ADC_CalculationRightShiftSet.
#define ADC_RESOLUTION 12
ADC resolution value.
#define ADC_BIT_SET 1
ADC bit set value.
#define ADC_BIT_CLEAR 0
ADC bit clear value.
#define IO_RA0 ADC_CHANNEL_ANA0
Defines the Custom Name pin mapping for channels in adc_channel_t.
#define CustomName_Initialize ADC_Initialize
Defines the Custom Name API mapping for ADC_Initialize.
#define CustomName_Deinitialize ADC_Deinitialize
Defines the Custom Name API mapping for ADC_Deinitialize.
#define CustomName_Enable ADC_Enable
Defines the Custom Name API mapping for ADC_Enable.
#define CustomName_Disable ADC_Disable
Defines the Custom Name API mapping for ADC_Disable.
#define CustomName_ConversionStart ADC_ConversionStart
Defines the Custom Name API mapping for ADC_ConversionStart.
#define CustomName_IsConversionDone ADC_IsConversionDone
Defines the Custom Name API mapping for ADC_IsConversionDone.
#define CustomName_ConversionResultGet ADC_ConversionResultGet
Defines the Custom Name API mapping for ADC_ConversionResultGet.
#define CustomName_ResolutionGet ADC_ResolutionGet
Defines the Custom Name API mapping for ADC_ResolutionGet.
#define CustomName_IsBusy ADC_IsBusy
Defines the Custom Name API mapping for ADC_IsBusy.
#define CustomName_BusyStatusSet ADC_BusyStatusSet
Defines the Custom Name API mapping for ADC_BusyStatusSet.
#define CustomName_ConversionDoneCallbackRegister ADC_ConversionDoneCallbackRegister
Defines the Custom Name API mapping for ADC_ConversionDoneCallbackRegister.
#define CustomName_ChannelSelect ADC_ChannelSelect
Defines the Custom Name API mapping for ADC_ChannelSelect.
#define CustomName_ChannelSelectAndConvert ADC_ChannelSelectAndConvert
Defines the Custom Name API mapping for ADC_ChannelSelectAndConvert.
#define CustomName_Tasks ADC_Tasks
Defines the Custom Name API mapping for ADC_Tasks.
#define CustomName_ConversionStop ADC_ConversionStop
Defines the Custom Name API mapping for ADC_ConversionStop.
#define CustomName_SampleRepeatCountSet ADC_SampleRepeatCountSet
Defines the Custom Name API mapping for ADC_SampleRepeatCountSet.
#define CustomName_ComputationModeSet ADC_ComputationModeSet
Defines the Custom Name API mapping for ADC_ComputationModeSet.
#define CustomName_UpperThresholdSet ADC_UpperThresholdSet
Defines the Custom Name API mapping for ADC_UpperThresholdSet.
#define CustomName_LowerThresholdSet ADC_LowerThresholdSet
Defines the Custom Name API mapping for ADC_LowerThresholdSet.
#define CustomName_ThresholdModeSet ADC_ThresholdModeSet
Defines the Custom Name API mapping for ADC_ThresholdModeSet.
#define CustomName_AccumulatedResultGet ADC_AccumulatedResultGet
Defines the Custom Name API mapping for ADC_AccumulatedResultGet.
#define CustomName_ThresholdCallbackRegister ADC_ThresholdCallbackRegister
Defines the Custom Name API mapping for ADC_ThresholdCallbackRegister.
#define CustomName_IsConversionDoneInterruptFlagSet ADC_IsConversionDoneInterruptFlagSet
Defines the Custom Name API mapping for ADC_IsConversionDoneInterruptFlagSet.
#define CustomName_IsThresholdInterruptFlagSet ADC_IsThresholdInterruptFlagSet
Defines the Custom Name API mapping for ADC_IsThresholdInterruptFlagSet.
#define CustomName_ConversionDoneInterruptFlagClear ADC_ConversionDoneInterruptFlagClear
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptFlagClear.
#define CustomName_ThresholdInterruptFlagClear ADC_ThresholdInterruptFlagClear
Defines the Custom Name API mapping for ADC_ThresholdInterruptFlagClear.
#define CustomName_StopOnInterruptEnable ADC_StopOnInterruptEnable
Defines the Custom Name API mapping for ADC_StopOnInterruptEnable.
#define CustomName_StopOnInterruptDisable ADC_StopOnInterruptDisable
Defines the Custom Name API mapping for ADC_StopOnInterruptDisable.
#define CustomName_ChargePumpEnable ADC_ChargePumpEnable
Defines the Custom Name API mapping for ADC_ChargePumpEnable.
#define CustomName_ChargePumpDisable ADC_ChargePumpDisable
Defines the Custom Name API mapping for ADC_ChargePumpDisable.
#define CustomName_IsChargePumpReady ADC_IsChargePumpReady
Defines the Custom Name API mapping for ADC_IsChargePumpReady.
#define CustomName_SampleCapacitorDischarge ADC_SampleCapacitorDischarge
Defines the Custom Name API mapping for ADC_SampleCapacitorDischarge.
#define CustomName_AcquisitionTimeSet ADC_AcquisitionTimeSet
Defines the Custom Name API mapping for ADC_AcquisitionTimeSet.
#define CustomName_PrechargeTimeSet ADC_PrechargeTimeSet
Defines the Custom Name API mapping for ADC_PrechargeTimeSet.
#define CustomName_CurrentConversionCountGet ADC_CurrentConversionCountGet
Defines the Custom Name API mapping for ADC_CurrentConversionCountGet.
#define CustomName_AccumulatorClear ADC_AccumulatorClear
Defines the Custom Name API mapping for ADC_AccumulatorClear.
#define CustomName_IsAccumulatorClearComplete ADC_IsAccumulatorClearComplete
Defines the Custom Name API mapping for ADC_IsAccumulatorClearComplete.
#define CustomName_HasAccumulatorOverflowed ADC_HasAccumulatorOverflowed
Defines the Custom Name API mapping for ADC_HasAccumulatorOverflowed.
#define CustomName_FilterValueGet ADC_FilterValueGet
Defines the Custom Name API mapping for ADC_FilterValueGet.
#define CustomName_PreviousResultGet ADC_PreviousResultGet
Defines the Custom Name API mapping for ADC_PreviousResultGet.
#define CustomName_SetPointDefine ADC_SetPointDefine
Defines the Custom Name API mapping for ADC_SetPointDefine.
#define CustomName_ErrorCalculationGet ADC_ErrorCalculationGet
Defines the Custom Name API mapping for ADC_ErrorCalculationGet.
#define CustomName_DoubleSamplingEnable ADC_DoubleSamplingEnable
Defines the Custom Name API mapping for ADC_DoubleSamplingEnable.
#define CustomName_DoubleSamplingDisable ADC_DoubleSamplingDisable
Defines the Custom Name API mapping for ADC_DoubleSamplingDisable.
#define CustomName_ContinuousConversionEnable ADC_ContinuousConversionEnable
Defines the Custom Name API mapping for ADC_ContinuousConversionEnable.
#define CustomName_ContinuousConversionDisable ADC_ContinuousConversionDisable
Defines the Custom Name API mapping for ADC_ContinuousConversionDisable.
#define CustomName_IsErrorGreaterThanUpperThreshold ADC_IsErrorGreaterThanUpperThreshold
Defines the Custom Name API mapping for ADC_IsErrorGreaterThanUpperThreshold.
#define CustomName_IsErrorLesserThanLowerThreshold ADC_IsErrorLesserThanLowerThreshold
Defines the Custom Name API mapping for ADC_IsErrorLesserThanLowerThreshold.
#define CustomName_ConversionStageStatusGet ADC_ConversionStageStatusGet
Defines the Custom Name API mapping for ADC_ConversionStageStatusGet.
#define CustomName_AutoTriggerSourceSet ADC_AutoTriggerSourceSet
Defines the Custom Name API mapping for ADC_AutoTriggerSourceSet.
#define CustomName_ErrorCalculationModeSet ADC_ErrorCalculationModeSet
Defines the Custom Name API mapping for ADC_ErrorCalculationModeSet.
#define CustomName_CalculationRightShiftSet ADC_CalculationRightShiftSet
Defines the Custom Name API mapping for ADC_CalculationRightShiftSet.
#define ADC_RESOLUTION 12
ADC resolution value.
#define ADC_BIT_SET 1
ADC bit set value.
#define ADC_BIT_CLEAR 0
ADC bit clear value.
Enumerations
enum adc_channel_t { ADC_CHANNEL_VSS = 0x3b, ADC_CHANNEL_TEMP = 0x3c, ADC_CHANNEL_DAC1 = 0x3d, ADC_CHANNEL_FVR_BUFFER1 = 0x3e, ADC_CHANNEL_FVR_BUFFER2 = 0x3f, ADC_CHANNEL_ANA0 = 0x0, ADC_CHANNEL_ANA2 = 0x2, ADC_CHANNEL_ANA6 = 0x6, ADC_CHANNEL_ANB2 = 0xa, ADC_CHANNEL_ANB4 = 0xc, ADC_CHANNEL_ANC1 = 0x11, ADC_CHANNEL_VSS = 0x3b, ADC_CHANNEL_TEMP = 0x3c, ADC_CHANNEL_DAC1 = 0x3d, ADC_CHANNEL_FVR_BUFFER1 = 0x3e, ADC_CHANNEL_FVR_BUFFER2 = 0x3f, ADC_CHANNEL_ANA0 = 0x0, ADC_CHANNEL_ANA2 = 0x2, ADC_CHANNEL_ANA6 = 0x6, ADC_CHANNEL_ANB2 = 0xa, ADC_CHANNEL_ANB4 = 0xc, ADC_CHANNEL_ANC1 = 0x11 }
Enumeration for available ADC channels.
enum adc_computation_mode_t { ADC_BASIC = 0x0, ADC_SERIES_ACCUMULATE = 0x1, ADC_SERIES_AVERAGE = 0x2, ADC_BURST_AVERAGE = 0x3, ADC_LOW_PASS_FILTER = 0x4, ADC_BASIC = 0x0, ADC_SERIES_ACCUMULATE = 0x1, ADC_SERIES_AVERAGE = 0x2, ADC_BURST_AVERAGE = 0x3, ADC_LOW_PASS_FILTER = 0x4 }
Enumeration for the ADC computation modes.
enum adc_calculation_mode_t { ADC_FIRST_DERIVATIVE_OF_SINGLE_MEASUREMENT = 0x0, ADC_ACTUAL_RESULT_VS_SETPOINT = 0x1, ADC_ACTUAL_RESULT_VS_FILTERED_VALUE = 0x2, ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE = 0x4, ADC_FILTERED_VALUE_VS_SETPOINT = 0x5, ADC_FIRST_DERIVATIVE_OF_SINGLE_MEASUREMENT = 0x0, ADC_ACTUAL_RESULT_VS_SETPOINT = 0x1, ADC_ACTUAL_RESULT_VS_FILTERED_VALUE = 0x2, ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE = 0x4, ADC_FILTERED_VALUE_VS_SETPOINT = 0x5 }
Enumeration for the ADC error calculation modes.
enum adc_threshold_mode_t { ADC_NEVER_INTERRUPT = 0x0, ADC_BELOW_LOWER_THRESHOLD = 0x1, ADC_ABOVE_LOWER_THRESHOLD = 0x2, ADC_INSIDE_LOWER_AND_UPPER_THRESHOLD = 0x3, ADC_OUTSIDE_LOWER_AND_UPPER_THRESHOLD = 0x4, ADC_BELOW_UPPER_THRESHOLD = 0x5, ADC_ABOVE_UPPER_THRESHOLD = 0x6, ADC_ALWAYS_INTERRUPT = 0x7, ADC_NEVER_INTERRUPT = 0x0, ADC_BELOW_LOWER_THRESHOLD = 0x1, ADC_ABOVE_LOWER_THRESHOLD = 0x2, ADC_INSIDE_LOWER_AND_UPPER_THRESHOLD = 0x3, ADC_OUTSIDE_LOWER_AND_UPPER_THRESHOLD = 0x4, ADC_BELOW_UPPER_THRESHOLD = 0x5, ADC_ABOVE_UPPER_THRESHOLD = 0x6, ADC_ALWAYS_INTERRUPT = 0x7 }
Enumeration for the ADC threshold modes.
enum adc_trigger_source_t { ADC_TRIGGER_SOURCE_DISABLED = 0x0, ADC_TRIGGER_SOURCE_ADACTPPS = 0x1, ADC_TRIGGER_SOURCE_TMR0 = 0x2, ADC_TRIGGER_SOURCE_TMR1 = 0x3, ADC_TRIGGER_SOURCE_TMR2 = 0x4, ADC_TRIGGER_SOURCE_TMR3 = 0x5, ADC_TRIGGER_SOURCE_TMR4 = 0x6, ADC_TRIGGER_SOURCE_TMR5 = 0x7, ADC_TRIGGER_SOURCE_TMR6 = 0x8, ADC_TRIGGER_SOURCE_SMT1_OVERFLOW = 0xe, ADC_TRIGGER_SOURCE_CCP1 = 0xf, ADC_TRIGGER_SOURCE_CCP2 = 0x10, ADC_TRIGGER_SOURCE_CCP3 = 0x11, ADC_TRIGGER_SOURCE_PWM1_OUT1 = 0x12, ADC_TRIGGER_SOURCE_PWM1_OUT2 = 0x13, ADC_TRIGGER_SOURCE_PWM2_OUT1 = 0x14, ADC_TRIGGER_SOURCE_PWM2_OUT2 = 0x15, ADC_TRIGGER_SOURCE_PWM3_OUT1 = 0x16, ADC_TRIGGER_SOURCE_PWM3_OUT2 = 0x17, ADC_TRIGGER_SOURCE_NCO1 = 0x1a, ADC_TRIGGER_SOURCE_NCO2 = 0x1b, ADC_TRIGGER_SOURCE_NCO3 = 0x1c, ADC_TRIGGER_SOURCE_CMP1 = 0x1d, ADC_TRIGGER_SOURCE_CMP2 = 0x1e, ADC_TRIGGER_SOURCE_LOGICAL_OR_OF_ALL_IOC_FLAGS = 0x1f, ADC_TRIGGER_SOURCE_CLC1 = 0x20, ADC_TRIGGER_SOURCE_CLC2 = 0x21, ADC_TRIGGER_SOURCE_CLC3 = 0x22, ADC_TRIGGER_SOURCE_CLC4 = 0x23, ADC_TRIGGER_SOURCE_CLC5 = 0x24, ADC_TRIGGER_SOURCE_CLC6 = 0x25, ADC_TRIGGER_SOURCE_CLC7 = 0x26, ADC_TRIGGER_SOURCE_CLC8 = 0x27, ADC_TRIGGER_SOURCE_ADERRH = 0x3d, ADC_TRIGGER_SOURCE_ADRESH = 0x3e, ADC_TRIGGER_SOURCE_ADPCH = 0x3f, ADC_TRIGGER_SOURCE_DISABLED = 0x0, ADC_TRIGGER_SOURCE_ADACTPPS = 0x1, ADC_TRIGGER_SOURCE_TMR0 = 0x2, ADC_TRIGGER_SOURCE_TMR1 = 0x3, ADC_TRIGGER_SOURCE_TMR2 = 0x4, ADC_TRIGGER_SOURCE_TMR3 = 0x5, ADC_TRIGGER_SOURCE_TMR4 = 0x6, ADC_TRIGGER_SOURCE_TMR5 = 0x7, ADC_TRIGGER_SOURCE_TMR6 = 0x8, ADC_TRIGGER_SOURCE_SMT1_OVERFLOW = 0xe, ADC_TRIGGER_SOURCE_CCP1 = 0xf, ADC_TRIGGER_SOURCE_CCP2 = 0x10, ADC_TRIGGER_SOURCE_CCP3 = 0x11, ADC_TRIGGER_SOURCE_PWM1_OUT1 = 0x12, ADC_TRIGGER_SOURCE_PWM1_OUT2 = 0x13, ADC_TRIGGER_SOURCE_PWM2_OUT1 = 0x14, ADC_TRIGGER_SOURCE_PWM2_OUT2 = 0x15, ADC_TRIGGER_SOURCE_PWM3_OUT1 = 0x16, ADC_TRIGGER_SOURCE_PWM3_OUT2 = 0x17, ADC_TRIGGER_SOURCE_NCO1 = 0x1a, ADC_TRIGGER_SOURCE_NCO2 = 0x1b, ADC_TRIGGER_SOURCE_NCO3 = 0x1c, ADC_TRIGGER_SOURCE_CMP1 = 0x1d, ADC_TRIGGER_SOURCE_CMP2 = 0x1e, ADC_TRIGGER_SOURCE_LOGICAL_OR_OF_ALL_IOC_FLAGS = 0x1f, ADC_TRIGGER_SOURCE_CLC1 = 0x20, ADC_TRIGGER_SOURCE_CLC2 = 0x21, ADC_TRIGGER_SOURCE_CLC3 = 0x22, ADC_TRIGGER_SOURCE_CLC4 = 0x23, ADC_TRIGGER_SOURCE_CLC5 = 0x24, ADC_TRIGGER_SOURCE_CLC6 = 0x25, ADC_TRIGGER_SOURCE_CLC7 = 0x26, ADC_TRIGGER_SOURCE_CLC8 = 0x27, ADC_TRIGGER_SOURCE_ADERRH = 0x3d, ADC_TRIGGER_SOURCE_ADRESH = 0x3e, ADC_TRIGGER_SOURCE_ADPCH = 0x3f }
Enumeration for the ADC auto-trigger sources.
enum adc_conversion_stage_t { ADC_NOT_CONVERTING = 0x0, ADC_1ST_PRECHARGE = 0x1, ADC_1ST_ACQUISITION = 0x2, ADC_1ST_CONVERSION = 0x3, ADC_SUSPENDED_BETWEEN_1ST_AND_2ND_SAMPLE = 0x4, ADC_2ST_PRECHARGE = 0x5, ADC_2ST_ACQUISITION = 0x6, ADC_2ST_CONVERSION = 0x7, ADC_NOT_CONVERTING = 0x0, ADC_1ST_PRECHARGE = 0x1, ADC_1ST_ACQUISITION = 0x2, ADC_1ST_CONVERSION = 0x3, ADC_SUSPENDED_BETWEEN_1ST_AND_2ND_SAMPLE = 0x4, ADC_2ST_PRECHARGE = 0x5, ADC_2ST_ACQUISITION = 0x6, ADC_2ST_CONVERSION = 0x7 }
Enumeration for the ADC conversion stage statuses.
Functions
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.
void ADC_Deinitialize (void)
Deinitializes the registers to power-on Reset values.
void ADC_Enable (void)
Sets the ADC Enable (ADON) bit to 1.
void ADC_Disable (void)
Sets the ADC Enable (ADON) bit to 0.
void ADC_ChannelSelect (adc_channel_t channel)
Sets the channel to use for the ADC conversion.
void ADC_ConversionStart (void)
Starts the conversion on a selected channel.
bool ADC_IsConversionDone (void)
Checks if the ongoing conversion is complete.
void ADC_ConversionStop (void)
Stops the ongoing conversion.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ComputationModeSet (adc_computation_mode_t computationMode)
Sets the computation mode.
void ADC_ThresholdModeSet (adc_threshold_mode_t thresholdMode)
Sets the conversion threshold mode.
void ADC_SampleRepeatCountSet (adc_repeat_count_t repeatCount)
Loads the repeat counter with the specified value.
void ADC_UpperThresholdSet (adc_threshold_t upperThreshold)
Sets the value of the ADC Upper Threshold (ADUTH) register.
void ADC_LowerThresholdSet (adc_threshold_t lowerThreshold)
Sets the value of the ADC Lower Threshold (ADLTH) register.
adc_accumulate_t ADC_AccumulatedResultGet (void)
Retrieves the value of the accumulated conversions.
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of the single conversion on the selected channel.
void ADC_StopOnInterruptEnable (void)
Sets the Stop-on-Interrupt (SOI) bit to '1'.
void ADC_StopOnInterruptDisable (void)
Sets the Stop-on-Interrupt (SOI) bit to '0'.
void ADC_SampleCapacitorDischarge (void)
Discharges the input sample capacitor by setting the channel to AVss.
void ADC_AcquisitionTimeSet (uint16_t acquisitionValue)
Sets the specified value for the ADC Acquisition Time Control (ADACQ) register.
void ADC_PrechargeTimeSet (uint16_t prechargeTime)
Sets the specified value for the ADC Precharge Time Control (ADPRE) register.
adc_repeat_count_t ADC_CurrentConversionCountGet (void)
Retrieves the current value of the ADC Repeat Counter (ADCNT) register.
void ADC_AccumulatorClear (void)
Clears the accumulator.
bool ADC_IsAccumulatorClearComplete (void)
Status of the accumulator clear operation.
bool ADC_HasAccumulatorOverflowed (void)
Determines whether the accumulator has overflowed.
adc_result_t ADC_FilterValueGet (void)
Retrieves the value of the ADC Filter (ADFLTR) register.
adc_result_t ADC_PreviousResultGet (void)
Retrieves the value of the ADC Previous Result(ADPREV) register.
void ADC_SetPointDefine (adc_threshold_t setPoint)
Sets the value of the ADC Threshold Setpoint (ADSTPT) register.
adc_result_t ADC_ErrorCalculationGet (void)
Retrieves the value of the ADC Setpoint Error (ADERR) register.
void ADC_DoubleSamplingEnable (void)
Sets the Double-Sample Enable (DSEN) bit to '1'.
void ADC_DoubleSamplingDisable (void)
Sets the Double-Sample Enable (DSEN) bit to '0'.
void ADC_ContinuousConversionEnable (void)
Sets the Continuous Operation Enable (CONT) bit to '1'.
void ADC_ContinuousConversionDisable (void)
Sets the Continuous Operation Enable (CONT) bit to '0'.
bool ADC_IsErrorGreaterThanUpperThreshold (void)
Determines if the value in the ADC Setpoint Error (ADERR) register is greater than the upper threshold. *.
bool ADC_IsErrorLesserThanLowerThreshold (void)
Determines if the value in the ADC Setpoint Error (ADERR) register is lesser than the lower threshold.
adc_conversion_stage_t ADC_ConversionStageStatusGet (void)
Retrieves the conversion stage status.
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto-trigger source.
void ADC_ErrorCalculationModeSet (adc_calculation_mode_t errorCalculationMode)
Sets the ADC Error Calculation Mode Select (CALC) bits.
void ADC_CalculationRightShiftSet (uint8_t rightShiftValue)
Sets the ADC Accumulated Calculation Right Shift Select (CRS) bits.
void ADC_ChargePumpEnable (void)
Sets the ADC Charge Pump On Control (CPON) bit to '1'.
void ADC_ChargePumpDisable (void)
Sets the ADC Charge Pump On Control (CPON) bit to '0'.
bool ADC_IsChargePumpReady (void)
Checks the Charge Pump Ready status.
uint8_t ADC_ResolutionGet (void)
Returns the resolution of the ADC module.
bool ADC_IsBusy (void)
Returns the busy status of the ADC module.
void ADC_BusyStatusSet (bool status)
Sets the busy status of the ADC module.
void ADC_ConversionDoneInterruptFlagClear (void)
Clears the ADC Conversion Done Interrupt Flag (ADIF) bit to '0'.
void ADC_ThresholdInterruptFlagClear (void)
Sets the ADC Threshold Interrupt Flag (ADTIF) bit to '0'.
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) status.
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt (ADTIF) flag status.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Conversion Done Interrupt (ADI).
void ADC_ThresholdCallbackRegister (void(*callback)(void))
Sets the callback for the threshold interrupt.
void ADC_ConversionDoneInterruptEnable (void)
Sets the ADC Interrupt Enable (ADIE) bit to '1'.
void ADC_ConversionDoneInterruptDisable (void)
Sets the ADC Interrupt Enable (ADIE) bit to '0'.
void ADC_ThresholdInterruptEnable (void)
Sets the ADC Threshold Interrupt Enable bit to '1'.
void ADC_ThresholdInterruptDisable (void)
Sets the ADC Threshold Interrupt Enable bit to '0'.
void ADC_ISR (void)
Implements the ADC Interrupt (ADI) service routine for the interrupt-driven implementations.
void ADC_ThresholdISR (void)
Implements the ADC Threshold Interrupt (ADTI) service routine for the interrupt-driven implementations.
void ADC_Tasks (void)
Implements the Tasks routine for the polling implementations.
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.
None. |
adc_accumulate_t - Value of ADC accumulator register |
ADC_AccumulatorClear()
void ADC_AccumulatorClear (void )
Clears the accumulator.
None. |
None. |
ADC_AcquisitionTimeSet()
void ADC_AcquisitionTimeSet (uint16_t acquisitionValue)
Sets the specified value for the ADC Acquisition Time Control (ADACQ) register.
acquisitionValue |
Value to be loaded in the ADACQ register |
None. |
ADC_AutoTriggerSourceSet()
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto-trigger source.
triggerSource |
Desired auto-trigger source. Refer to the adc_trigger_source_t for the list of available trigger sources. |
None. |
ADC_BusyStatusSet()
void ADC_BusyStatusSet (bool status)
Sets the busy status of the ADC module.
status |
True to set the ADC status to busy, false to set it to not busy. |
None. |
ADC_CalculationRightShiftSet()
void ADC_CalculationRightShiftSet (uint8_t rightShiftValue)
Sets the ADC Accumulated Calculation Right Shift Select (CRS) bits.
rightShiftValue |
Right shift value |
None. |
ADC_ChannelSelect()
void ADC_ChannelSelect (adc_channel_t channel)
Sets the channel to use for the ADC conversion.
channel |
Desired analog channel. Refer to the adc_channel_t enum for the list of available analog channels. |
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.
channel |
Desired analog channel. Refer to the adc_channel_t enum for the list of available analog channels. |
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'.
None. |
None. |
ADC_ChargePumpEnable()
void ADC_ChargePumpEnable (void )
Sets the ADC Charge Pump On Control (CPON) bit to '1'.
None. |
None. |
ADC_ComputationModeSet()
void ADC_ComputationModeSet (adc_computation_mode_t computationMode)
Sets the computation mode.
computationMode |
Desired computation mode. Refer to the adc_computation_mode_t enum for the list of available computation modes. |
None. |
ADC_ContinuousConversionDisable()
void ADC_ContinuousConversionDisable (void )
Sets the Continuous Operation Enable (CONT) bit to '0'.
None. |
None. |
ADC_ContinuousConversionEnable()
void ADC_ContinuousConversionEnable (void )
Sets the Continuous Operation Enable (CONT) bit to '1'.
None. |
None. |
ADC_ConversionDoneCallbackRegister()
void ADC_ConversionDoneCallbackRegister (void(*)(void) callback)
Sets the callback function for the ADC Conversion Done Interrupt (ADI).
Pointer |
The pointer to the function to be executed |
None. |
ADC_ConversionDoneInterruptDisable()
void ADC_ConversionDoneInterruptDisable (void )
Sets the ADC Interrupt Enable (ADIE) bit to '0'.
None. |
None. |
ADC_ConversionDoneInterruptEnable()
void ADC_ConversionDoneInterruptEnable (void )
Sets the ADC Interrupt Enable (ADIE) bit to '1'.
None. |
None. |
ADC_ConversionDoneInterruptFlagClear()
void ADC_ConversionDoneInterruptFlagClear (void )
Clears the ADC Conversion Done Interrupt Flag (ADIF) bit to '0'.
None. |
None. |
ADC_ConversionResultGet()
adc_result_t ADC_ConversionResultGet (void )
Retrieves the result of the latest conversion.
Call ADC_ConversionStart(void) before using this API. |
None. |
adc_result_t - The result of the conversion |
ADC_ConversionStageStatusGet()
adc_conversion_stage_t ADC_ConversionStageStatusGet (void )
Retrieves the conversion stage status.
None. |
adc_conversion_stage_t - Stage of the conversion stages |
ADC_ConversionStart()
void ADC_ConversionStart (void )
Starts the conversion on a selected channel.
Select the channel(s) using ADC_ChannelSelect and call ADC_Initialize(void) to initialize the ADC module before using this API. |
None. |
None. |
ADC_ConversionStop()
void ADC_ConversionStop (void )
Stops the ongoing conversion.
None. |
None. |
ADC_CurrentConversionCountGet()
adc_repeat_count_t ADC_CurrentConversionCountGet (void )
Retrieves the current value of the ADC Repeat Counter (ADCNT) register.
None. |
adc_repeat_count_t - Current value of the ADCNT register |
ADC_Deinitialize()
void ADC_Deinitialize (void )
Deinitializes the registers to power-on Reset values.
None. |
None. |
ADC_Disable()
void ADC_Disable (void )
Sets the ADC Enable (ADON) bit to 0.
None. |
None. |
ADC_DoubleSamplingDisable()
void ADC_DoubleSamplingDisable (void )
Sets the Double-Sample Enable (DSEN) bit to '0'.
None. |
None. |
ADC_DoubleSamplingEnable()
void ADC_DoubleSamplingEnable (void )
Sets the Double-Sample Enable (DSEN) bit to '1'.
None. |
None. |
ADC_Enable()
void ADC_Enable (void )
Sets the ADC Enable (ADON) bit to 1.
None. |
None. |
ADC_ErrorCalculationGet()
adc_result_t ADC_ErrorCalculationGet (void )
Retrieves the value of the ADC Setpoint Error (ADERR) register.
None. |
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.
errorCalculationMode |
Desired errorCalculationMode value. Refer to the adc_calculation_mode_t for the error calculation mode options. |
None. |
ADC_FilterValueGet()
adc_result_t ADC_FilterValueGet (void )
Retrieves the value of the ADC Filter (ADFLTR) register.
None. |
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.
None. |
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.
None. |
None. |
ADC_IsAccumulatorClearComplete()
bool ADC_IsAccumulatorClearComplete (void )
Status of the accumulator clear operation.
None. |
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.
None. |
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.
None. |
True |
Charge Pump is ready |
False |
Charge Pump is not ready |
ADC_IsConversionDone()
bool ADC_IsConversionDone (void )
Checks if the ongoing conversion is complete.
ADC_ConversionStart(void) is called before using this API. |
None. |
True |
Conversion is complete |
False |
Conversion is ongoing |
ADC_IsConversionDoneInterruptFlagSet()
bool ADC_IsConversionDoneInterruptFlagSet (void )
Checks the ADC Conversion Done Interrupt Flag (ADIF) status.
None. |
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. *.
None. |
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.
None. |
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.
None. |
None. |
ADC_IsThresholdInterruptFlagSet()
bool ADC_IsThresholdInterruptFlagSet (void )
Checks the ADC Threshold Interrupt (ADTIF) flag status.
None. |
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.
lowerThreshold |
Lower threshold value of the adc_threshold_t type for the ADLTH register |
None. |
ADC_PrechargeTimeSet()
void ADC_PrechargeTimeSet (uint16_t prechargeTime)
Sets the specified value for the ADC Precharge Time Control (ADPRE) register.
prechargeTime |
Value to be loaded in the ADPRE register |
None. |
ADC_PreviousResultGet()
adc_result_t ADC_PreviousResultGet (void )
Retrieves the value of the ADC Previous Result(ADPREV) register.
None. |
adc_result_t - Value obtained from the ADPREV register |
ADC_ResolutionGet()
uint8_t ADC_ResolutionGet (void )
Returns the resolution of the ADC module.
None. |
uint8_t - Resolution value |
ADC_SampleCapacitorDischarge()
void ADC_SampleCapacitorDischarge (void )
Discharges the input sample capacitor by setting the channel to AVss.
None. |
None. |
ADC_SampleRepeatCountSet()
void ADC_SampleRepeatCountSet (adc_repeat_count_t repeatCount)
Loads the repeat counter with the specified value.
repeatCount |
Repeat count value. Refer to the adc_repeat_count_t type. |
None. |
ADC_SetPointDefine()
void ADC_SetPointDefine (adc_threshold_t setPoint)
Sets the value of the ADC Threshold Setpoint (ADSTPT) register.
setPoint |
Value for the ADSTPT register of the adc_threshold_t type |
None. |
ADC_StopOnInterruptDisable()
void ADC_StopOnInterruptDisable (void )
Sets the Stop-on-Interrupt (SOI) bit to '0'.
None. |
None. |
ADC_StopOnInterruptEnable()
void ADC_StopOnInterruptEnable (void )
Sets the Stop-on-Interrupt (SOI) bit to '1'.
Call ADC_ContinuousConversionEnable API before using this API. |
None. |
None. |
ADC_Tasks()
void ADC_Tasks (void )
Implements the Tasks routine for the polling implementations.
None. |
None. |
ADC_ThresholdCallbackRegister()
void ADC_ThresholdCallbackRegister (void(*)(void) callback)
Sets the callback for the threshold interrupt.
*callback |
The pointer to the function to be executed |
None. |
ADC_ThresholdInterruptDisable()
void ADC_ThresholdInterruptDisable (void )
Sets the ADC Threshold Interrupt Enable bit to '0'.
None. |
None. |
ADC_ThresholdInterruptEnable()
void ADC_ThresholdInterruptEnable (void )
Sets the ADC Threshold Interrupt Enable bit to '1'.
None. |
None. |
ADC_ThresholdInterruptFlagClear()
void ADC_ThresholdInterruptFlagClear (void )
Sets the ADC Threshold Interrupt Flag (ADTIF) bit to '0'.
None. |
None. |
ADC_ThresholdISR()
void ADC_ThresholdISR (void )
Implements the ADC Threshold Interrupt (ADTI) service routine for the interrupt-driven implementations.
None. |
None. |
ADC_ThresholdModeSet()
void ADC_ThresholdModeSet (adc_threshold_mode_t thresholdMode)
Sets the conversion threshold mode.
thresholdMode |
Desired threshold mode. Refer to the adc_threshold_mode_t enum for the list of available threshold modes. |
None. |
ADC_UpperThresholdSet()
void ADC_UpperThresholdSet (adc_threshold_t upperThreshold)
Sets the value of the ADC Upper Threshold (ADUTH) register.
upperThreshold |
Upper threshold value of the adc_threshold_t type for the ADUTH register. |
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
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.
void ADC_Deinitialize (void)
Deinitializes the registers to power-on Reset values.
void ADC_Enable (void)
Sets the ADC Enable (ADON) bit to 1.
void ADC_Disable (void)
Sets the ADC Enable (ADON) bit to 0.
void ADC_ChannelSelect (adc_channel_t channel)
Sets the channel to use for the ADC conversion.
void ADC_ConversionStart (void)
Starts the conversion on a selected channel.
bool ADC_IsConversionDone (void)
Checks if the ongoing conversion is complete.
void ADC_ConversionStop (void)
Stops the ongoing conversion.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ComputationModeSet (adc_computation_mode_t computationMode)
Sets the computation mode.
void ADC_ThresholdModeSet (adc_threshold_mode_t thresholdMode)
Sets the conversion threshold mode.
void ADC_SampleRepeatCountSet (adc_repeat_count_t repeatCount)
Loads the repeat counter with the specified value.
void ADC_UpperThresholdSet (adc_threshold_t upperThreshold)
Sets the value of the ADC Upper Threshold (ADUTH) register.
void ADC_LowerThresholdSet (adc_threshold_t lowerThreshold)
Sets the value of the ADC Lower Threshold (ADLTH) register.
adc_accumulate_t ADC_AccumulatedResultGet (void)
Retrieves the value of the accumulated conversions.
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of the single conversion on the selected channel.
void ADC_StopOnInterruptEnable (void)
Sets the Stop-on-Interrupt (SOI) bit to '1'.
void ADC_StopOnInterruptDisable (void)
Sets the Stop-on-Interrupt (SOI) bit to '0'.
void ADC_SampleCapacitorDischarge (void)
Discharges the input sample capacitor by setting the channel to AVss.
void ADC_AcquisitionTimeSet (uint16_t acquisitionValue)
Sets the specified value for the ADC Acquisition Time Control (ADACQ) register.
void ADC_PrechargeTimeSet (uint16_t prechargeTime)
Sets the specified value for the ADC Precharge Time Control (ADPRE) register.
adc_repeat_count_t ADC_CurrentConversionCountGet (void)
Retrieves the current value of the ADC Repeat Counter (ADCNT) register.
void ADC_AccumulatorClear (void)
Clears the accumulator.
bool ADC_IsAccumulatorClearComplete (void)
Status of the accumulator clear operation.
bool ADC_HasAccumulatorOverflowed (void)
Determines whether the accumulator has overflowed.
adc_result_t ADC_FilterValueGet (void)
Retrieves the value of the ADC Filter (ADFLTR) register.
adc_result_t ADC_PreviousResultGet (void)
Retrieves the value of the ADC Previous Result(ADPREV) register.
void ADC_SetPointDefine (adc_threshold_t setPoint)
Sets the value of the ADC Threshold Setpoint (ADSTPT) register.
adc_result_t ADC_ErrorCalculationGet (void)
Retrieves the value of the ADC Setpoint Error (ADERR) register.
void ADC_DoubleSamplingEnable (void)
Sets the Double-Sample Enable (DSEN) bit to '1'.
void ADC_DoubleSamplingDisable (void)
Sets the Double-Sample Enable (DSEN) bit to '0'.
void ADC_ContinuousConversionEnable (void)
Sets the Continuous Operation Enable (CONT) bit to '1'.
void ADC_ContinuousConversionDisable (void)
Sets the Continuous Operation Enable (CONT) bit to '0'.
bool ADC_IsErrorGreaterThanUpperThreshold (void)
Determines if the value in the ADC Setpoint Error (ADERR) register is greater than the upper threshold. *.
bool ADC_IsErrorLesserThanLowerThreshold (void)
Determines if the value in the ADC Setpoint Error (ADERR) register is lesser than the lower threshold.
adc_conversion_stage_t ADC_ConversionStageStatusGet (void)
Retrieves the conversion stage status.
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto-trigger source.
void ADC_ErrorCalculationModeSet (adc_calculation_mode_t errorCalculationMode)
Sets the ADC Error Calculation Mode Select (CALC) bits.
void ADC_CalculationRightShiftSet (uint8_t rightShiftValue)
Sets the ADC Accumulated Calculation Right Shift Select (CRS) bits.
void ADC_ChargePumpEnable (void)
Sets the ADC Charge Pump On Control (CPON) bit to '1'.
void ADC_ChargePumpDisable (void)
Sets the ADC Charge Pump On Control (CPON) bit to '0'.
bool ADC_IsChargePumpReady (void)
Checks the Charge Pump Ready status.
uint8_t ADC_ResolutionGet (void)
Returns the resolution of the ADC module.
bool ADC_IsBusy (void)
Returns the busy status of the ADC module.
void ADC_BusyStatusSet (bool status)
Sets the busy status of the ADC module.
void ADC_ConversionDoneInterruptFlagClear (void)
Clears the ADC Conversion Done Interrupt Flag (ADIF) bit to '0'.
void ADC_ThresholdInterruptFlagClear (void)
Sets the ADC Threshold Interrupt Flag (ADTIF) bit to '0'.
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) status.
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt (ADTIF) flag status.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Conversion Done Interrupt (ADI).
void ADC_ThresholdCallbackRegister (void(*callback)(void))
Sets the callback for the threshold interrupt.
void ADC_ConversionDoneInterruptEnable (void)
Sets the ADC Interrupt Enable (ADIE) bit to '1'.
void ADC_ConversionDoneInterruptDisable (void)
Sets the ADC Interrupt Enable (ADIE) bit to '0'.
void ADC_ThresholdInterruptEnable (void)
Sets the ADC Threshold Interrupt Enable bit to '1'.
void ADC_ThresholdInterruptDisable (void)
Sets the ADC Threshold Interrupt Enable bit to '0'.
void ADC_ISR (void)
Implements the ADC Interrupt (ADI) service routine for the interrupt-driven implementations.
void ADC_ThresholdISR (void)
Implements the ADC Threshold Interrupt (ADTI) service routine for the interrupt-driven implementations.
Macros
#define IO_RA0 ADC_CHANNEL_ANA0
Defines the Custom Name pin mapping for channels in adc_channel_t.
#define CustomName_Initialize ADC_Initialize
Defines the Custom Name API mapping for ADC_Initialize.
#define CustomName_Deinitialize ADC_Deinitialize
Defines the Custom Name API mapping for ADC_Deinitialize.
#define CustomName_Enable ADC_Enable
Defines the Custom Name API mapping for ADC_Enable.
#define CustomName_Disable ADC_Disable
Defines the Custom Name API mapping for ADC_Disable.
#define CustomName_ConversionStart ADC_ConversionStart
Defines the Custom Name API mapping for ADC_ConversionStart.
#define CustomName_IsConversionDone ADC_IsConversionDone
Defines the Custom Name API mapping for ADC_IsConversionDone.
#define CustomName_ConversionResultGet ADC_ConversionResultGet
Defines the Custom Name API mapping for ADC_ConversionResultGet.
#define CustomName_ResolutionGet ADC_ResolutionGet
Defines the Custom Name API mapping for ADC_ResolutionGet.
#define CustomName_IsBusy ADC_IsBusy
Defines the Custom Name API mapping for ADC_IsBusy.
#define CustomName_BusyStatusSet ADC_BusyStatusSet
Defines the Custom Name API mapping for ADC_BusyStatusSet.
#define CustomName_ConversionDoneCallbackRegister ADC_ConversionDoneCallbackRegister
Defines the Custom Name API mapping for ADC_ConversionDoneCallbackRegister.
#define CustomName_ChannelSelect ADC_ChannelSelect
Defines the Custom Name API mapping for ADC_ChannelSelect.
#define CustomName_ChannelSelectAndConvert ADC_ChannelSelectAndConvert
Defines the Custom Name API mapping for ADC_ChannelSelectAndConvert.
#define CustomName_ConversionDoneInterruptEnable ADC_ConversionDoneInterruptEnable
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptEnable.
#define CustomName_ConversionDoneInterruptDisable ADC_ConversionDoneInterruptDisable
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptDisable.
#define CustomName_ConversionStop ADC_ConversionStop
Defines the Custom Name API mapping for ADC_ConversionStop.
#define CustomName_SampleRepeatCountSet ADC_SampleRepeatCountSet
Defines the Custom Name API mapping for ADC_SampleRepeatCountSet.
#define CustomName_ComputationModeSet ADC_ComputationModeSet
Defines the Custom Name API mapping for ADC_ComputationModeSet.
#define CustomName_UpperThresholdSet ADC_UpperThresholdSet
Defines the Custom Name API mapping for ADC_UpperThresholdSet.
#define CustomName_LowerThresholdSet ADC_LowerThresholdSet
Defines the Custom Name API mapping for ADC_LowerThresholdSet.
#define CustomName_ThresholdModeSet ADC_ThresholdModeSet
Defines the Custom Name API mapping for ADC_ThresholdModeSet.
#define CustomName_AccumulatedResultGet ADC_AccumulatedResultGet
Defines the Custom Name API mapping for ADC_AccumulatedResultGet.
#define CustomName_ThresholdCallbackRegister ADC_ThresholdCallbackRegister
Defines the Custom Name API mapping for ADC_ThresholdCallbackRegister.
#define CustomName_ThresholdInterruptEnable ADC_ThresholdInterruptEnable
Defines the Custom Name API mapping for ADC_ThresholdInterruptEnable.
#define CustomName_ThresholdInterruptDisable ADC_ThresholdInterruptDisable
Defines the Custom Name API mapping for ADC_ThresholdInterruptDisable.
#define CustomName_IsConversionDoneInterruptFlagSet ADC_IsConversionDoneInterruptFlagSet
Defines the Custom Name API mapping for ADC_IsConversionDoneInterruptFlagSet.
#define CustomName_IsThresholdInterruptFlagSet ADC_IsThresholdInterruptFlagSet
Defines the Custom Name API mapping for ADC_IsThresholdInterruptFlagSet.
#define CustomName_ConversionDoneInterruptFlagClear ADC_ConversionDoneInterruptFlagClear
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptFlagClear.
#define CustomName_ThresholdInterruptFlagClear ADC_ThresholdInterruptFlagClear
Defines the Custom Name API mapping for ADC_ThresholdInterruptFlagClear.
#define CustomName_StopOnInterruptEnable ADC_StopOnInterruptEnable
Defines the Custom Name API mapping for ADC_StopOnInterruptEnable.
#define CustomName_StopOnInterruptDisable ADC_StopOnInterruptDisable
Defines the Custom Name API mapping for ADC_StopOnInterruptDisable.
#define CustomName_ChargePumpEnable ADC_ChargePumpEnable
Defines the Custom Name API mapping for ADC_ChargePumpEnable.
#define CustomName_ChargePumpDisable ADC_ChargePumpDisable
Defines the Custom Name API mapping for ADC_ChargePumpDisable.
#define CustomName_IsChargePumpReady ADC_IsChargePumpReady
Defines the Custom Name API mapping for ADC_IsChargePumpReady.
#define CustomName_SampleCapacitorDischarge ADC_SampleCapacitorDischarge
Defines the Custom Name API mapping for ADC_SampleCapacitorDischarge.
#define CustomName_AcquisitionTimeSet ADC_AcquisitionTimeSet
Defines the Custom Name API mapping for ADC_AcquisitionTimeSet.
#define CustomName_PrechargeTimeSet ADC_PrechargeTimeSet
Defines the Custom Name API mapping for ADC_PrechargeTimeSet.
#define CustomName_CurrentConversionCountGet ADC_CurrentConversionCountGet
Defines the Custom Name API mapping for ADC_CurrentConversionCountGet.
#define CustomName_AccumulatorClear ADC_AccumulatorClear
Defines the Custom Name API mapping for ADC_AccumulatorClear.
#define CustomName_IsAccumulatorClearComplete ADC_IsAccumulatorClearComplete
Defines the Custom Name API mapping for ADC_IsAccumulatorClearComplete.
#define CustomName_HasAccumulatorOverflowed ADC_HasAccumulatorOverflowed
Defines the Custom Name API mapping for ADC_HasAccumulatorOverflowed.
#define CustomName_FilterValueGet ADC_FilterValueGet
Defines the Custom Name API mapping for ADC_FilterValueGet.
#define CustomName_PreviousResultGet ADC_PreviousResultGet
Defines the Custom Name API mapping for ADC_PreviousResultGet.
#define CustomName_SetPointDefine ADC_SetPointDefine
Defines the Custom Name API mapping for ADC_SetPointDefine.
#define CustomName_ErrorCalculationGet ADC_ErrorCalculationGet
Defines the Custom Name API mapping for ADC_ErrorCalculationGet.
#define CustomName_DoubleSamplingEnable ADC_DoubleSamplingEnable
Defines the Custom Name API mapping for ADC_DoubleSamplingEnable.
#define CustomName_DoubleSamplingDisable ADC_DoubleSamplingDisable
Defines the Custom Name API mapping for ADC_DoubleSamplingDisable.
#define CustomName_ContinuousConversionEnable ADC_ContinuousConversionEnable
Defines the Custom Name API mapping for ADC_ContinuousConversionEnable.
#define CustomName_ContinuousConversionDisable ADC_ContinuousConversionDisable
Defines the Custom Name API mapping for ADC_ContinuousConversionDisable.
#define CustomName_IsErrorGreaterThanUpperThreshold ADC_IsErrorGreaterThanUpperThreshold
Defines the Custom Name API mapping for ADC_IsErrorGreaterThanUpperThreshold.
#define CustomName_IsErrorLesserThanLowerThreshold ADC_IsErrorLesserThanLowerThreshold
Defines the Custom Name API mapping for ADC_IsErrorLesserThanLowerThreshold.
#define CustomName_ConversionStageStatusGet ADC_ConversionStageStatusGet
Defines the Custom Name API mapping for ADC_ConversionStageStatusGet.
#define CustomName_AutoTriggerSourceSet ADC_AutoTriggerSourceSet
Defines the Custom Name API mapping for ADC_AutoTriggerSourceSet.
#define CustomName_ErrorCalculationModeSet ADC_ErrorCalculationModeSet
Defines the Custom Name API mapping for ADC_ErrorCalculationModeSet.
#define CustomName_CalculationRightShiftSet ADC_CalculationRightShiftSet
Defines the Custom Name API mapping for ADC_CalculationRightShiftSet.
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
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.
void ADC_Deinitialize (void)
Deinitializes the registers to power-on Reset values.
void ADC_Enable (void)
Sets the ADC Enable (ADON) bit to 1.
void ADC_Disable (void)
Sets the ADC Enable (ADON) bit to 0.
void ADC_ChannelSelect (adc_channel_t channel)
Sets the channel to use for the ADC conversion.
void ADC_ConversionStart (void)
Starts the conversion on a selected channel.
bool ADC_IsConversionDone (void)
Checks if the ongoing conversion is complete.
void ADC_ConversionStop (void)
Stops the ongoing conversion.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ComputationModeSet (adc_computation_mode_t computationMode)
Sets the computation mode.
void ADC_ThresholdModeSet (adc_threshold_mode_t thresholdMode)
Sets the conversion threshold mode.
void ADC_SampleRepeatCountSet (adc_repeat_count_t repeatCount)
Loads the repeat counter with the specified value.
void ADC_UpperThresholdSet (adc_threshold_t upperThreshold)
Sets the value of the ADC Upper Threshold (ADUTH) register.
void ADC_LowerThresholdSet (adc_threshold_t lowerThreshold)
Sets the value of the ADC Lower Threshold (ADLTH) register.
adc_accumulate_t ADC_AccumulatedResultGet (void)
Retrieves the value of the accumulated conversions.
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of the single conversion on the selected channel.
void ADC_StopOnInterruptEnable (void)
Sets the Stop-on-Interrupt (SOI) bit to '1'.
void ADC_StopOnInterruptDisable (void)
Sets the Stop-on-Interrupt (SOI) bit to '0'.
void ADC_SampleCapacitorDischarge (void)
Discharges the input sample capacitor by setting the channel to AVss.
void ADC_AcquisitionTimeSet (uint16_t acquisitionValue)
Sets the specified value for the ADC Acquisition Time Control (ADACQ) register.
void ADC_PrechargeTimeSet (uint16_t prechargeTime)
Sets the specified value for the ADC Precharge Time Control (ADPRE) register.
adc_repeat_count_t ADC_CurrentConversionCountGet (void)
Retrieves the current value of the ADC Repeat Counter (ADCNT) register.
void ADC_AccumulatorClear (void)
Clears the accumulator.
bool ADC_IsAccumulatorClearComplete (void)
Status of the accumulator clear operation.
bool ADC_HasAccumulatorOverflowed (void)
Determines whether the accumulator has overflowed.
adc_result_t ADC_FilterValueGet (void)
Retrieves the value of the ADC Filter (ADFLTR) register.
adc_result_t ADC_PreviousResultGet (void)
Retrieves the value of the ADC Previous Result(ADPREV) register.
void ADC_SetPointDefine (adc_threshold_t setPoint)
Sets the value of the ADC Threshold Setpoint (ADSTPT) register.
adc_result_t ADC_ErrorCalculationGet (void)
Retrieves the value of the ADC Setpoint Error (ADERR) register.
void ADC_DoubleSamplingEnable (void)
Sets the Double-Sample Enable (DSEN) bit to '1'.
void ADC_DoubleSamplingDisable (void)
Sets the Double-Sample Enable (DSEN) bit to '0'.
void ADC_ContinuousConversionEnable (void)
Sets the Continuous Operation Enable (CONT) bit to '1'.
void ADC_ContinuousConversionDisable (void)
Sets the Continuous Operation Enable (CONT) bit to '0'.
bool ADC_IsErrorGreaterThanUpperThreshold (void)
Determines if the value in the ADC Setpoint Error (ADERR) register is greater than the upper threshold. *.
bool ADC_IsErrorLesserThanLowerThreshold (void)
Determines if the value in the ADC Setpoint Error (ADERR) register is lesser than the lower threshold.
adc_conversion_stage_t ADC_ConversionStageStatusGet (void)
Retrieves the conversion stage status.
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto-trigger source.
void ADC_ErrorCalculationModeSet (adc_calculation_mode_t errorCalculationMode)
Sets the ADC Error Calculation Mode Select (CALC) bits.
void ADC_CalculationRightShiftSet (uint8_t rightShiftValue)
Sets the ADC Accumulated Calculation Right Shift Select (CRS) bits.
void ADC_ChargePumpEnable (void)
Sets the ADC Charge Pump On Control (CPON) bit to '1'.
void ADC_ChargePumpDisable (void)
Sets the ADC Charge Pump On Control (CPON) bit to '0'.
bool ADC_IsChargePumpReady (void)
Checks the Charge Pump Ready status.
uint8_t ADC_ResolutionGet (void)
Returns the resolution of the ADC module.
bool ADC_IsBusy (void)
Returns the busy status of the ADC module.
void ADC_BusyStatusSet (bool status)
Sets the busy status of the ADC module.
void ADC_ConversionDoneInterruptFlagClear (void)
Clears the ADC Conversion Done Interrupt Flag (ADIF) bit to '0'.
void ADC_ThresholdInterruptFlagClear (void)
Sets the ADC Threshold Interrupt Flag (ADTIF) bit to '0'.
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) status.
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt (ADTIF) flag status.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Conversion Done Interrupt (ADI).
void ADC_ThresholdCallbackRegister (void(*callback)(void))
Sets the callback for the threshold interrupt.
void ADC_Tasks (void)
Implements the Tasks routine for the polling implementations.
Macros
#define IO_RA0 ADC_CHANNEL_ANA0
Defines the Custom Name pin mapping for channels in adc_channel_t.
#define CustomName_Initialize ADC_Initialize
Defines the Custom Name API mapping for ADC_Initialize.
#define CustomName_Deinitialize ADC_Deinitialize
Defines the Custom Name API mapping for ADC_Deinitialize.
#define CustomName_Enable ADC_Enable
Defines the Custom Name API mapping for ADC_Enable.
#define CustomName_Disable ADC_Disable
Defines the Custom Name API mapping for ADC_Disable.
#define CustomName_ConversionStart ADC_ConversionStart
Defines the Custom Name API mapping for ADC_ConversionStart.
#define CustomName_IsConversionDone ADC_IsConversionDone
Defines the Custom Name API mapping for ADC_IsConversionDone.
#define CustomName_ConversionResultGet ADC_ConversionResultGet
Defines the Custom Name API mapping for ADC_ConversionResultGet.
#define CustomName_ResolutionGet ADC_ResolutionGet
Defines the Custom Name API mapping for ADC_ResolutionGet.
#define CustomName_IsBusy ADC_IsBusy
Defines the Custom Name API mapping for ADC_IsBusy.
#define CustomName_BusyStatusSet ADC_BusyStatusSet
Defines the Custom Name API mapping for ADC_BusyStatusSet.
#define CustomName_ConversionDoneCallbackRegister ADC_ConversionDoneCallbackRegister
Defines the Custom Name API mapping for ADC_ConversionDoneCallbackRegister.
#define CustomName_ChannelSelect ADC_ChannelSelect
Defines the Custom Name API mapping for ADC_ChannelSelect.
#define CustomName_ChannelSelectAndConvert ADC_ChannelSelectAndConvert
Defines the Custom Name API mapping for ADC_ChannelSelectAndConvert.
#define CustomName_Tasks ADC_Tasks
Defines the Custom Name API mapping for ADC_Tasks.
#define CustomName_ConversionStop ADC_ConversionStop
Defines the Custom Name API mapping for ADC_ConversionStop.
#define CustomName_SampleRepeatCountSet ADC_SampleRepeatCountSet
Defines the Custom Name API mapping for ADC_SampleRepeatCountSet.
#define CustomName_ComputationModeSet ADC_ComputationModeSet
Defines the Custom Name API mapping for ADC_ComputationModeSet.
#define CustomName_UpperThresholdSet ADC_UpperThresholdSet
Defines the Custom Name API mapping for ADC_UpperThresholdSet.
#define CustomName_LowerThresholdSet ADC_LowerThresholdSet
Defines the Custom Name API mapping for ADC_LowerThresholdSet.
#define CustomName_ThresholdModeSet ADC_ThresholdModeSet
Defines the Custom Name API mapping for ADC_ThresholdModeSet.
#define CustomName_AccumulatedResultGet ADC_AccumulatedResultGet
Defines the Custom Name API mapping for ADC_AccumulatedResultGet.
#define CustomName_ThresholdCallbackRegister ADC_ThresholdCallbackRegister
Defines the Custom Name API mapping for ADC_ThresholdCallbackRegister.
#define CustomName_IsConversionDoneInterruptFlagSet ADC_IsConversionDoneInterruptFlagSet
Defines the Custom Name API mapping for ADC_IsConversionDoneInterruptFlagSet.
#define CustomName_IsThresholdInterruptFlagSet ADC_IsThresholdInterruptFlagSet
Defines the Custom Name API mapping for ADC_IsThresholdInterruptFlagSet.
#define CustomName_ConversionDoneInterruptFlagClear ADC_ConversionDoneInterruptFlagClear
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptFlagClear.
#define CustomName_ThresholdInterruptFlagClear ADC_ThresholdInterruptFlagClear
Defines the Custom Name API mapping for ADC_ThresholdInterruptFlagClear.
#define CustomName_StopOnInterruptEnable ADC_StopOnInterruptEnable
Defines the Custom Name API mapping for ADC_StopOnInterruptEnable.
#define CustomName_StopOnInterruptDisable ADC_StopOnInterruptDisable
Defines the Custom Name API mapping for ADC_StopOnInterruptDisable.
#define CustomName_ChargePumpEnable ADC_ChargePumpEnable
Defines the Custom Name API mapping for ADC_ChargePumpEnable.
#define CustomName_ChargePumpDisable ADC_ChargePumpDisable
Defines the Custom Name API mapping for ADC_ChargePumpDisable.
#define CustomName_IsChargePumpReady ADC_IsChargePumpReady
Defines the Custom Name API mapping for ADC_IsChargePumpReady.
#define CustomName_SampleCapacitorDischarge ADC_SampleCapacitorDischarge
Defines the Custom Name API mapping for ADC_SampleCapacitorDischarge.
#define CustomName_AcquisitionTimeSet ADC_AcquisitionTimeSet
Defines the Custom Name API mapping for ADC_AcquisitionTimeSet.
#define CustomName_PrechargeTimeSet ADC_PrechargeTimeSet
Defines the Custom Name API mapping for ADC_PrechargeTimeSet.
#define CustomName_CurrentConversionCountGet ADC_CurrentConversionCountGet
Defines the Custom Name API mapping for ADC_CurrentConversionCountGet.
#define CustomName_AccumulatorClear ADC_AccumulatorClear
Defines the Custom Name API mapping for ADC_AccumulatorClear.
#define CustomName_IsAccumulatorClearComplete ADC_IsAccumulatorClearComplete
Defines the Custom Name API mapping for ADC_IsAccumulatorClearComplete.
#define CustomName_HasAccumulatorOverflowed ADC_HasAccumulatorOverflowed
Defines the Custom Name API mapping for ADC_HasAccumulatorOverflowed.
#define CustomName_FilterValueGet ADC_FilterValueGet
Defines the Custom Name API mapping for ADC_FilterValueGet.
#define CustomName_PreviousResultGet ADC_PreviousResultGet
Defines the Custom Name API mapping for ADC_PreviousResultGet.
#define CustomName_SetPointDefine ADC_SetPointDefine
Defines the Custom Name API mapping for ADC_SetPointDefine.
#define CustomName_ErrorCalculationGet ADC_ErrorCalculationGet
Defines the Custom Name API mapping for ADC_ErrorCalculationGet.
#define CustomName_DoubleSamplingEnable ADC_DoubleSamplingEnable
Defines the Custom Name API mapping for ADC_DoubleSamplingEnable.
#define CustomName_DoubleSamplingDisable ADC_DoubleSamplingDisable
Defines the Custom Name API mapping for ADC_DoubleSamplingDisable.
#define CustomName_ContinuousConversionEnable ADC_ContinuousConversionEnable
Defines the Custom Name API mapping for ADC_ContinuousConversionEnable.
#define CustomName_ContinuousConversionDisable ADC_ContinuousConversionDisable
Defines the Custom Name API mapping for ADC_ContinuousConversionDisable.
#define CustomName_IsErrorGreaterThanUpperThreshold ADC_IsErrorGreaterThanUpperThreshold
Defines the Custom Name API mapping for ADC_IsErrorGreaterThanUpperThreshold.
#define CustomName_IsErrorLesserThanLowerThreshold ADC_IsErrorLesserThanLowerThreshold
Defines the Custom Name API mapping for ADC_IsErrorLesserThanLowerThreshold.
#define CustomName_ConversionStageStatusGet ADC_ConversionStageStatusGet
Defines the Custom Name API mapping for ADC_ConversionStageStatusGet.
#define CustomName_AutoTriggerSourceSet ADC_AutoTriggerSourceSet
Defines the Custom Name API mapping for ADC_AutoTriggerSourceSet.
#define CustomName_ErrorCalculationModeSet ADC_ErrorCalculationModeSet
Defines the Custom Name API mapping for ADC_ErrorCalculationModeSet.
#define CustomName_CalculationRightShiftSet ADC_CalculationRightShiftSet
Defines the Custom Name API mapping for ADC_CalculationRightShiftSet.
Detailed Description
ADC Generated Driver API Header File
source/single-ended-interrupts/adc/adc_types.h File Reference
Macros
#define ADC_RESOLUTION 12
ADC resolution value.
#define ADC_BIT_SET 1
ADC bit set value.
#define ADC_BIT_CLEAR 0
ADC bit clear value.
Typedefs
typedef int16_t adc_result_t
ADC conversion result type.
typedef int32_t adc_accumulate_t
ADC conversion accumulator type.
typedef int16_t adc_threshold_t
ADC conversion threshold type.
typedef uint8_t adc_repeat_count_t
ADC conversion repeat count type.
Enumerations
enum adc_channel_t { ADC_CHANNEL_VSS = 0x3b, ADC_CHANNEL_TEMP = 0x3c, ADC_CHANNEL_DAC1 = 0x3d, ADC_CHANNEL_FVR_BUFFER1 = 0x3e, ADC_CHANNEL_FVR_BUFFER2 = 0x3f, ADC_CHANNEL_ANA0 = 0x0, ADC_CHANNEL_ANA2 = 0x2, ADC_CHANNEL_ANA6 = 0x6, ADC_CHANNEL_ANB2 = 0xa, ADC_CHANNEL_ANB4 = 0xc, ADC_CHANNEL_ANC1 = 0x11, ADC_CHANNEL_VSS = 0x3b, ADC_CHANNEL_TEMP = 0x3c, ADC_CHANNEL_DAC1 = 0x3d, ADC_CHANNEL_FVR_BUFFER1 = 0x3e, ADC_CHANNEL_FVR_BUFFER2 = 0x3f, ADC_CHANNEL_ANA0 = 0x0, ADC_CHANNEL_ANA2 = 0x2, ADC_CHANNEL_ANA6 = 0x6, ADC_CHANNEL_ANB2 = 0xa, ADC_CHANNEL_ANB4 = 0xc, ADC_CHANNEL_ANC1 = 0x11 }
Enumeration for available ADC channels.
enum adc_computation_mode_t { ADC_BASIC = 0x0, ADC_SERIES_ACCUMULATE = 0x1, ADC_SERIES_AVERAGE = 0x2, ADC_BURST_AVERAGE = 0x3, ADC_LOW_PASS_FILTER = 0x4, ADC_BASIC = 0x0, ADC_SERIES_ACCUMULATE = 0x1, ADC_SERIES_AVERAGE = 0x2, ADC_BURST_AVERAGE = 0x3, ADC_LOW_PASS_FILTER = 0x4 }
Enumeration for the ADC computation modes.
enum adc_calculation_mode_t { ADC_FIRST_DERIVATIVE_OF_SINGLE_MEASUREMENT = 0x0, ADC_ACTUAL_RESULT_VS_SETPOINT = 0x1, ADC_ACTUAL_RESULT_VS_FILTERED_VALUE = 0x2, ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE = 0x4, ADC_FILTERED_VALUE_VS_SETPOINT = 0x5, ADC_FIRST_DERIVATIVE_OF_SINGLE_MEASUREMENT = 0x0, ADC_ACTUAL_RESULT_VS_SETPOINT = 0x1, ADC_ACTUAL_RESULT_VS_FILTERED_VALUE = 0x2, ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE = 0x4, ADC_FILTERED_VALUE_VS_SETPOINT = 0x5 }
Enumeration for the ADC error calculation modes.
enum adc_threshold_mode_t { ADC_NEVER_INTERRUPT = 0x0, ADC_BELOW_LOWER_THRESHOLD = 0x1, ADC_ABOVE_LOWER_THRESHOLD = 0x2, ADC_INSIDE_LOWER_AND_UPPER_THRESHOLD = 0x3, ADC_OUTSIDE_LOWER_AND_UPPER_THRESHOLD = 0x4, ADC_BELOW_UPPER_THRESHOLD = 0x5, ADC_ABOVE_UPPER_THRESHOLD = 0x6, ADC_ALWAYS_INTERRUPT = 0x7, ADC_NEVER_INTERRUPT = 0x0, ADC_BELOW_LOWER_THRESHOLD = 0x1, ADC_ABOVE_LOWER_THRESHOLD = 0x2, ADC_INSIDE_LOWER_AND_UPPER_THRESHOLD = 0x3, ADC_OUTSIDE_LOWER_AND_UPPER_THRESHOLD = 0x4, ADC_BELOW_UPPER_THRESHOLD = 0x5, ADC_ABOVE_UPPER_THRESHOLD = 0x6, ADC_ALWAYS_INTERRUPT = 0x7 }
Enumeration for the ADC threshold modes.
enum adc_trigger_source_t { ADC_TRIGGER_SOURCE_DISABLED = 0x0, ADC_TRIGGER_SOURCE_ADACTPPS = 0x1, ADC_TRIGGER_SOURCE_TMR0 = 0x2, ADC_TRIGGER_SOURCE_TMR1 = 0x3, ADC_TRIGGER_SOURCE_TMR2 = 0x4, ADC_TRIGGER_SOURCE_TMR3 = 0x5, ADC_TRIGGER_SOURCE_TMR4 = 0x6, ADC_TRIGGER_SOURCE_TMR5 = 0x7, ADC_TRIGGER_SOURCE_TMR6 = 0x8, ADC_TRIGGER_SOURCE_SMT1_OVERFLOW = 0xe, ADC_TRIGGER_SOURCE_CCP1 = 0xf, ADC_TRIGGER_SOURCE_CCP2 = 0x10, ADC_TRIGGER_SOURCE_CCP3 = 0x11, ADC_TRIGGER_SOURCE_PWM1_OUT1 = 0x12, ADC_TRIGGER_SOURCE_PWM1_OUT2 = 0x13, ADC_TRIGGER_SOURCE_PWM2_OUT1 = 0x14, ADC_TRIGGER_SOURCE_PWM2_OUT2 = 0x15, ADC_TRIGGER_SOURCE_PWM3_OUT1 = 0x16, ADC_TRIGGER_SOURCE_PWM3_OUT2 = 0x17, ADC_TRIGGER_SOURCE_NCO1 = 0x1a, ADC_TRIGGER_SOURCE_NCO2 = 0x1b, ADC_TRIGGER_SOURCE_NCO3 = 0x1c, ADC_TRIGGER_SOURCE_CMP1 = 0x1d, ADC_TRIGGER_SOURCE_CMP2 = 0x1e, ADC_TRIGGER_SOURCE_LOGICAL_OR_OF_ALL_IOC_FLAGS = 0x1f, ADC_TRIGGER_SOURCE_CLC1 = 0x20, ADC_TRIGGER_SOURCE_CLC2 = 0x21, ADC_TRIGGER_SOURCE_CLC3 = 0x22, ADC_TRIGGER_SOURCE_CLC4 = 0x23, ADC_TRIGGER_SOURCE_CLC5 = 0x24, ADC_TRIGGER_SOURCE_CLC6 = 0x25, ADC_TRIGGER_SOURCE_CLC7 = 0x26, ADC_TRIGGER_SOURCE_CLC8 = 0x27, ADC_TRIGGER_SOURCE_ADERRH = 0x3d, ADC_TRIGGER_SOURCE_ADRESH = 0x3e, ADC_TRIGGER_SOURCE_ADPCH = 0x3f, ADC_TRIGGER_SOURCE_DISABLED = 0x0, ADC_TRIGGER_SOURCE_ADACTPPS = 0x1, ADC_TRIGGER_SOURCE_TMR0 = 0x2, ADC_TRIGGER_SOURCE_TMR1 = 0x3, ADC_TRIGGER_SOURCE_TMR2 = 0x4, ADC_TRIGGER_SOURCE_TMR3 = 0x5, ADC_TRIGGER_SOURCE_TMR4 = 0x6, ADC_TRIGGER_SOURCE_TMR5 = 0x7, ADC_TRIGGER_SOURCE_TMR6 = 0x8, ADC_TRIGGER_SOURCE_SMT1_OVERFLOW = 0xe, ADC_TRIGGER_SOURCE_CCP1 = 0xf, ADC_TRIGGER_SOURCE_CCP2 = 0x10, ADC_TRIGGER_SOURCE_CCP3 = 0x11, ADC_TRIGGER_SOURCE_PWM1_OUT1 = 0x12, ADC_TRIGGER_SOURCE_PWM1_OUT2 = 0x13, ADC_TRIGGER_SOURCE_PWM2_OUT1 = 0x14, ADC_TRIGGER_SOURCE_PWM2_OUT2 = 0x15, ADC_TRIGGER_SOURCE_PWM3_OUT1 = 0x16, ADC_TRIGGER_SOURCE_PWM3_OUT2 = 0x17, ADC_TRIGGER_SOURCE_NCO1 = 0x1a, ADC_TRIGGER_SOURCE_NCO2 = 0x1b, ADC_TRIGGER_SOURCE_NCO3 = 0x1c, ADC_TRIGGER_SOURCE_CMP1 = 0x1d, ADC_TRIGGER_SOURCE_CMP2 = 0x1e, ADC_TRIGGER_SOURCE_LOGICAL_OR_OF_ALL_IOC_FLAGS = 0x1f, ADC_TRIGGER_SOURCE_CLC1 = 0x20, ADC_TRIGGER_SOURCE_CLC2 = 0x21, ADC_TRIGGER_SOURCE_CLC3 = 0x22, ADC_TRIGGER_SOURCE_CLC4 = 0x23, ADC_TRIGGER_SOURCE_CLC5 = 0x24, ADC_TRIGGER_SOURCE_CLC6 = 0x25, ADC_TRIGGER_SOURCE_CLC7 = 0x26, ADC_TRIGGER_SOURCE_CLC8 = 0x27, ADC_TRIGGER_SOURCE_ADERRH = 0x3d, ADC_TRIGGER_SOURCE_ADRESH = 0x3e, ADC_TRIGGER_SOURCE_ADPCH = 0x3f }
Enumeration for the ADC auto-trigger sources.
enum adc_conversion_stage_t { ADC_NOT_CONVERTING = 0x0, ADC_1ST_PRECHARGE = 0x1, ADC_1ST_ACQUISITION = 0x2, ADC_1ST_CONVERSION = 0x3, ADC_SUSPENDED_BETWEEN_1ST_AND_2ND_SAMPLE = 0x4, ADC_2ST_PRECHARGE = 0x5, ADC_2ST_ACQUISITION = 0x6, ADC_2ST_CONVERSION = 0x7, ADC_NOT_CONVERTING = 0x0, ADC_1ST_PRECHARGE = 0x1, ADC_1ST_ACQUISITION = 0x2, ADC_1ST_CONVERSION = 0x3, ADC_SUSPENDED_BETWEEN_1ST_AND_2ND_SAMPLE = 0x4, ADC_2ST_PRECHARGE = 0x5, ADC_2ST_ACQUISITION = 0x6, ADC_2ST_CONVERSION = 0x7 }
Enumeration for the ADC conversion stage statuses.
Detailed Description
ADC Type Definitions Header File
source/single-ended-tasks/adc/adc_types.h File Reference
Macros
#define ADC_RESOLUTION 12
ADC resolution value.
#define ADC_BIT_SET 1
ADC bit set value.
#define ADC_BIT_CLEAR 0
ADC bit clear value.
Typedefs
typedef int16_t adc_result_t
typedef int32_t adc_accumulate_t
typedef int16_t adc_threshold_t
typedef uint8_t adc_repeat_count_t
Enumerations
enum adc_channel_t { ADC_CHANNEL_VSS = 0x3b, ADC_CHANNEL_TEMP = 0x3c, ADC_CHANNEL_DAC1 = 0x3d, ADC_CHANNEL_FVR_BUFFER1 = 0x3e, ADC_CHANNEL_FVR_BUFFER2 = 0x3f, ADC_CHANNEL_ANA0 = 0x0, ADC_CHANNEL_ANA2 = 0x2, ADC_CHANNEL_ANA6 = 0x6, ADC_CHANNEL_ANB2 = 0xa, ADC_CHANNEL_ANB4 = 0xc, ADC_CHANNEL_ANC1 = 0x11, ADC_CHANNEL_VSS = 0x3b, ADC_CHANNEL_TEMP = 0x3c, ADC_CHANNEL_DAC1 = 0x3d, ADC_CHANNEL_FVR_BUFFER1 = 0x3e, ADC_CHANNEL_FVR_BUFFER2 = 0x3f, ADC_CHANNEL_ANA0 = 0x0, ADC_CHANNEL_ANA2 = 0x2, ADC_CHANNEL_ANA6 = 0x6, ADC_CHANNEL_ANB2 = 0xa, ADC_CHANNEL_ANB4 = 0xc, ADC_CHANNEL_ANC1 = 0x11 }
enum adc_computation_mode_t { ADC_BASIC = 0x0, ADC_SERIES_ACCUMULATE = 0x1, ADC_SERIES_AVERAGE = 0x2, ADC_BURST_AVERAGE = 0x3, ADC_LOW_PASS_FILTER = 0x4, ADC_BASIC = 0x0, ADC_SERIES_ACCUMULATE = 0x1, ADC_SERIES_AVERAGE = 0x2, ADC_BURST_AVERAGE = 0x3, ADC_LOW_PASS_FILTER = 0x4 }
enum adc_calculation_mode_t { ADC_FIRST_DERIVATIVE_OF_SINGLE_MEASUREMENT = 0x0, ADC_ACTUAL_RESULT_VS_SETPOINT = 0x1, ADC_ACTUAL_RESULT_VS_FILTERED_VALUE = 0x2, ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE = 0x4, ADC_FILTERED_VALUE_VS_SETPOINT = 0x5, ADC_FIRST_DERIVATIVE_OF_SINGLE_MEASUREMENT = 0x0, ADC_ACTUAL_RESULT_VS_SETPOINT = 0x1, ADC_ACTUAL_RESULT_VS_FILTERED_VALUE = 0x2, ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE = 0x4, ADC_FILTERED_VALUE_VS_SETPOINT = 0x5 }
enum adc_threshold_mode_t { ADC_NEVER_INTERRUPT = 0x0, ADC_BELOW_LOWER_THRESHOLD = 0x1, ADC_ABOVE_LOWER_THRESHOLD = 0x2, ADC_INSIDE_LOWER_AND_UPPER_THRESHOLD = 0x3, ADC_OUTSIDE_LOWER_AND_UPPER_THRESHOLD = 0x4, ADC_BELOW_UPPER_THRESHOLD = 0x5, ADC_ABOVE_UPPER_THRESHOLD = 0x6, ADC_ALWAYS_INTERRUPT = 0x7, ADC_NEVER_INTERRUPT = 0x0, ADC_BELOW_LOWER_THRESHOLD = 0x1, ADC_ABOVE_LOWER_THRESHOLD = 0x2, ADC_INSIDE_LOWER_AND_UPPER_THRESHOLD = 0x3, ADC_OUTSIDE_LOWER_AND_UPPER_THRESHOLD = 0x4, ADC_BELOW_UPPER_THRESHOLD = 0x5, ADC_ABOVE_UPPER_THRESHOLD = 0x6, ADC_ALWAYS_INTERRUPT = 0x7 }
enum adc_trigger_source_t { ADC_TRIGGER_SOURCE_DISABLED = 0x0, ADC_TRIGGER_SOURCE_ADACTPPS = 0x1, ADC_TRIGGER_SOURCE_TMR0 = 0x2, ADC_TRIGGER_SOURCE_TMR1 = 0x3, ADC_TRIGGER_SOURCE_TMR2 = 0x4, ADC_TRIGGER_SOURCE_TMR3 = 0x5, ADC_TRIGGER_SOURCE_TMR4 = 0x6, ADC_TRIGGER_SOURCE_TMR5 = 0x7, ADC_TRIGGER_SOURCE_TMR6 = 0x8, ADC_TRIGGER_SOURCE_SMT1_OVERFLOW = 0xe, ADC_TRIGGER_SOURCE_CCP1 = 0xf, ADC_TRIGGER_SOURCE_CCP2 = 0x10, ADC_TRIGGER_SOURCE_CCP3 = 0x11, ADC_TRIGGER_SOURCE_PWM1_OUT1 = 0x12, ADC_TRIGGER_SOURCE_PWM1_OUT2 = 0x13, ADC_TRIGGER_SOURCE_PWM2_OUT1 = 0x14, ADC_TRIGGER_SOURCE_PWM2_OUT2 = 0x15, ADC_TRIGGER_SOURCE_PWM3_OUT1 = 0x16, ADC_TRIGGER_SOURCE_PWM3_OUT2 = 0x17, ADC_TRIGGER_SOURCE_NCO1 = 0x1a, ADC_TRIGGER_SOURCE_NCO2 = 0x1b, ADC_TRIGGER_SOURCE_NCO3 = 0x1c, ADC_TRIGGER_SOURCE_CMP1 = 0x1d, ADC_TRIGGER_SOURCE_CMP2 = 0x1e, ADC_TRIGGER_SOURCE_LOGICAL_OR_OF_ALL_IOC_FLAGS = 0x1f, ADC_TRIGGER_SOURCE_CLC1 = 0x20, ADC_TRIGGER_SOURCE_CLC2 = 0x21, ADC_TRIGGER_SOURCE_CLC3 = 0x22, ADC_TRIGGER_SOURCE_CLC4 = 0x23, ADC_TRIGGER_SOURCE_CLC5 = 0x24, ADC_TRIGGER_SOURCE_CLC6 = 0x25, ADC_TRIGGER_SOURCE_CLC7 = 0x26, ADC_TRIGGER_SOURCE_CLC8 = 0x27, ADC_TRIGGER_SOURCE_ADERRH = 0x3d, ADC_TRIGGER_SOURCE_ADRESH = 0x3e, ADC_TRIGGER_SOURCE_ADPCH = 0x3f, ADC_TRIGGER_SOURCE_DISABLED = 0x0, ADC_TRIGGER_SOURCE_ADACTPPS = 0x1, ADC_TRIGGER_SOURCE_TMR0 = 0x2, ADC_TRIGGER_SOURCE_TMR1 = 0x3, ADC_TRIGGER_SOURCE_TMR2 = 0x4, ADC_TRIGGER_SOURCE_TMR3 = 0x5, ADC_TRIGGER_SOURCE_TMR4 = 0x6, ADC_TRIGGER_SOURCE_TMR5 = 0x7, ADC_TRIGGER_SOURCE_TMR6 = 0x8, ADC_TRIGGER_SOURCE_SMT1_OVERFLOW = 0xe, ADC_TRIGGER_SOURCE_CCP1 = 0xf, ADC_TRIGGER_SOURCE_CCP2 = 0x10, ADC_TRIGGER_SOURCE_CCP3 = 0x11, ADC_TRIGGER_SOURCE_PWM1_OUT1 = 0x12, ADC_TRIGGER_SOURCE_PWM1_OUT2 = 0x13, ADC_TRIGGER_SOURCE_PWM2_OUT1 = 0x14, ADC_TRIGGER_SOURCE_PWM2_OUT2 = 0x15, ADC_TRIGGER_SOURCE_PWM3_OUT1 = 0x16, ADC_TRIGGER_SOURCE_PWM3_OUT2 = 0x17, ADC_TRIGGER_SOURCE_NCO1 = 0x1a, ADC_TRIGGER_SOURCE_NCO2 = 0x1b, ADC_TRIGGER_SOURCE_NCO3 = 0x1c, ADC_TRIGGER_SOURCE_CMP1 = 0x1d, ADC_TRIGGER_SOURCE_CMP2 = 0x1e, ADC_TRIGGER_SOURCE_LOGICAL_OR_OF_ALL_IOC_FLAGS = 0x1f, ADC_TRIGGER_SOURCE_CLC1 = 0x20, ADC_TRIGGER_SOURCE_CLC2 = 0x21, ADC_TRIGGER_SOURCE_CLC3 = 0x22, ADC_TRIGGER_SOURCE_CLC4 = 0x23, ADC_TRIGGER_SOURCE_CLC5 = 0x24, ADC_TRIGGER_SOURCE_CLC6 = 0x25, ADC_TRIGGER_SOURCE_CLC7 = 0x26, ADC_TRIGGER_SOURCE_CLC8 = 0x27, ADC_TRIGGER_SOURCE_ADERRH = 0x3d, ADC_TRIGGER_SOURCE_ADRESH = 0x3e, ADC_TRIGGER_SOURCE_ADPCH = 0x3f }
enum adc_conversion_stage_t { ADC_NOT_CONVERTING = 0x0, ADC_1ST_PRECHARGE = 0x1, ADC_1ST_ACQUISITION = 0x2, ADC_1ST_CONVERSION = 0x3, ADC_SUSPENDED_BETWEEN_1ST_AND_2ND_SAMPLE = 0x4, ADC_2ST_PRECHARGE = 0x5, ADC_2ST_ACQUISITION = 0x6, ADC_2ST_CONVERSION = 0x7, ADC_NOT_CONVERTING = 0x0, ADC_1ST_PRECHARGE = 0x1, ADC_1ST_ACQUISITION = 0x2, ADC_1ST_CONVERSION = 0x3, ADC_SUSPENDED_BETWEEN_1ST_AND_2ND_SAMPLE = 0x4, ADC_2ST_PRECHARGE = 0x5, ADC_2ST_ACQUISITION = 0x6, ADC_2ST_CONVERSION = 0x7 }
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
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.
void ADC_Deinitialize (void)
Deinitializes the registers to power-on Reset values.
void ADC_Enable (void)
Sets the ADC Enable (ADON) bit to 1.
void ADC_Disable (void)
Sets the ADC Enable (ADON) bit to 0.
void ADC_ChannelSelect (adc_channel_t channel)
Sets the channel to use for the ADC conversion.
void ADC_ConversionStart (void)
Starts the conversion on a selected channel.
bool ADC_IsConversionDone (void)
Checks if the ongoing conversion is complete.
void ADC_ConversionStop (void)
Stops the ongoing conversion.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ComputationModeSet (adc_computation_mode_t computationMode)
Sets the computation mode.
void ADC_ThresholdModeSet (adc_threshold_mode_t thresholdMode)
Sets the conversion threshold mode.
void ADC_SampleRepeatCountSet (adc_repeat_count_t repeatCount)
Loads the repeat counter with the specified value.
void ADC_UpperThresholdSet (adc_threshold_t upperThreshold)
Sets the value of the ADC Upper Threshold (ADUTH) register.
void ADC_LowerThresholdSet (adc_threshold_t lowerThreshold)
Sets the value of the ADC Lower Threshold (ADLTH) register.
adc_accumulate_t ADC_AccumulatedResultGet (void)
Retrieves the value of the accumulated conversions.
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of the single conversion on the selected channel.
void ADC_StopOnInterruptEnable (void)
Sets the Stop-on-Interrupt (SOI) bit to '1'.
void ADC_StopOnInterruptDisable (void)
Sets the Stop-on-Interrupt (SOI) bit to '0'.
void ADC_SampleCapacitorDischarge (void)
Discharges the input sample capacitor by setting the channel to AVss.
void ADC_AcquisitionTimeSet (uint16_t acquisitionValue)
Sets the specified value for the ADC Acquisition Time Control (ADACQ) register.
void ADC_PrechargeTimeSet (uint16_t prechargeTime)
Sets the specified value for the ADC Precharge Time Control (ADPRE) register.
adc_repeat_count_t ADC_CurrentConversionCountGet (void)
Retrieves the current value of the ADC Repeat Counter (ADCNT) register.
void ADC_AccumulatorClear (void)
Clears the accumulator.
bool ADC_IsAccumulatorClearComplete (void)
Status of the accumulator clear operation.
bool ADC_HasAccumulatorOverflowed (void)
Determines whether the accumulator has overflowed.
adc_result_t ADC_FilterValueGet (void)
Retrieves the value of the ADC Filter (ADFLTR) register.
adc_result_t ADC_PreviousResultGet (void)
Retrieves the value of the ADC Previous Result(ADPREV) register.
void ADC_SetPointDefine (adc_threshold_t setPoint)
Sets the value of the ADC Threshold Setpoint (ADSTPT) register.
adc_result_t ADC_ErrorCalculationGet (void)
Retrieves the value of the ADC Setpoint Error (ADERR) register.
void ADC_DoubleSamplingEnable (void)
Sets the Double-Sample Enable (DSEN) bit to '1'.
void ADC_DoubleSamplingDisable (void)
Sets the Double-Sample Enable (DSEN) bit to '0'.
void ADC_ContinuousConversionEnable (void)
Sets the Continuous Operation Enable (CONT) bit to '1'.
void ADC_ContinuousConversionDisable (void)
Sets the Continuous Operation Enable (CONT) bit to '0'.
bool ADC_IsErrorGreaterThanUpperThreshold (void)
Determines if the value in the ADC Setpoint Error (ADERR) register is greater than the upper threshold. *.
bool ADC_IsErrorLesserThanLowerThreshold (void)
Determines if the value in the ADC Setpoint Error (ADERR) register is lesser than the lower threshold.
adc_conversion_stage_t ADC_ConversionStageStatusGet (void)
Retrieves the conversion stage status.
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto-trigger source.
void ADC_ErrorCalculationModeSet (adc_calculation_mode_t errorCalculationMode)
Sets the ADC Error Calculation Mode Select (CALC) bits.
void ADC_CalculationRightShiftSet (uint8_t rightShiftValue)
Sets the ADC Accumulated Calculation Right Shift Select (CRS) bits.
void ADC_ChargePumpEnable (void)
Sets the ADC Charge Pump On Control (CPON) bit to '1'.
void ADC_ChargePumpDisable (void)
Sets the ADC Charge Pump On Control (CPON) bit to '0'.
bool ADC_IsChargePumpReady (void)
Checks the Charge Pump Ready status.
uint8_t ADC_ResolutionGet (void)
Returns the resolution of the ADC module.
bool ADC_IsBusy (void)
Returns the busy status of the ADC module.
void ADC_BusyStatusSet (bool status)
Sets the busy status of the ADC module.
void ADC_ConversionDoneInterruptFlagClear (void)
Clears the ADC Conversion Done Interrupt Flag (ADIF) bit to '0'.
void ADC_ThresholdInterruptFlagClear (void)
Sets the ADC Threshold Interrupt Flag (ADTIF) bit to '0'.
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) status.
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt (ADTIF) flag status.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Conversion Done Interrupt (ADI).
void ADC_ThresholdCallbackRegister (void(*callback)(void))
Sets the callback for the threshold interrupt.
void ADC_ConversionDoneInterruptEnable (void)
Sets the ADC Interrupt Enable (ADIE) bit to '1'.
void ADC_ConversionDoneInterruptDisable (void)
Sets the ADC Interrupt Enable (ADIE) bit to '0'.
void ADC_ThresholdInterruptEnable (void)
Sets the ADC Threshold Interrupt Enable bit to '1'.
void ADC_ThresholdInterruptDisable (void)
Sets the ADC Threshold Interrupt Enable bit to '0'.
void ADC_ISR (void)
Implements the ADC Interrupt (ADI) service routine for the interrupt-driven implementations.
void ADC_ThresholdISR (void)
Implements the ADC Threshold Interrupt (ADTI) service routine for the interrupt-driven implementations.
Variables
static void(* ADC_ConversionDoneCallback )(void)
static void(* ADC_ThresholdCallback )(void)
static bool adc_busy_status
Detailed Description
This file contains the API implementations for the ADC driver.
ADC Generated Driver File
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
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.
void ADC_Deinitialize (void)
Deinitializes the registers to power-on Reset values.
void ADC_Enable (void)
Sets the ADC Enable (ADON) bit to 1.
void ADC_Disable (void)
Sets the ADC Enable (ADON) bit to 0.
void ADC_ChannelSelect (adc_channel_t channel)
Sets the channel to use for the ADC conversion.
void ADC_ConversionStart (void)
Starts the conversion on a selected channel.
bool ADC_IsConversionDone (void)
Checks if the ongoing conversion is complete.
void ADC_ConversionStop (void)
Stops the ongoing conversion.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ComputationModeSet (adc_computation_mode_t computationMode)
Sets the computation mode.
void ADC_ThresholdModeSet (adc_threshold_mode_t thresholdMode)
Sets the conversion threshold mode.
void ADC_SampleRepeatCountSet (adc_repeat_count_t repeatCount)
Loads the repeat counter with the specified value.
void ADC_UpperThresholdSet (adc_threshold_t upperThreshold)
Sets the value of the ADC Upper Threshold (ADUTH) register.
void ADC_LowerThresholdSet (adc_threshold_t lowerThreshold)
Sets the value of the ADC Lower Threshold (ADLTH) register.
adc_accumulate_t ADC_AccumulatedResultGet (void)
Retrieves the value of the accumulated conversions.
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of the single conversion on the selected channel.
void ADC_StopOnInterruptEnable (void)
Sets the Stop-on-Interrupt (SOI) bit to '1'.
void ADC_StopOnInterruptDisable (void)
Sets the Stop-on-Interrupt (SOI) bit to '0'.
void ADC_SampleCapacitorDischarge (void)
Discharges the input sample capacitor by setting the channel to AVss.
void ADC_AcquisitionTimeSet (uint16_t acquisitionValue)
Sets the specified value for the ADC Acquisition Time Control (ADACQ) register.
void ADC_PrechargeTimeSet (uint16_t prechargeTime)
Sets the specified value for the ADC Precharge Time Control (ADPRE) register.
adc_repeat_count_t ADC_CurrentConversionCountGet (void)
Retrieves the current value of the ADC Repeat Counter (ADCNT) register.
void ADC_AccumulatorClear (void)
Clears the accumulator.
bool ADC_IsAccumulatorClearComplete (void)
Status of the accumulator clear operation.
bool ADC_HasAccumulatorOverflowed (void)
Determines whether the accumulator has overflowed.
adc_result_t ADC_FilterValueGet (void)
Retrieves the value of the ADC Filter (ADFLTR) register.
adc_result_t ADC_PreviousResultGet (void)
Retrieves the value of the ADC Previous Result(ADPREV) register.
void ADC_SetPointDefine (adc_threshold_t setPoint)
Sets the value of the ADC Threshold Setpoint (ADSTPT) register.
adc_result_t ADC_ErrorCalculationGet (void)
Retrieves the value of the ADC Setpoint Error (ADERR) register.
void ADC_DoubleSamplingEnable (void)
Sets the Double-Sample Enable (DSEN) bit to '1'.
void ADC_DoubleSamplingDisable (void)
Sets the Double-Sample Enable (DSEN) bit to '0'.
void ADC_ContinuousConversionEnable (void)
Sets the Continuous Operation Enable (CONT) bit to '1'.
void ADC_ContinuousConversionDisable (void)
Sets the Continuous Operation Enable (CONT) bit to '0'.
bool ADC_IsErrorGreaterThanUpperThreshold (void)
Determines if the value in the ADC Setpoint Error (ADERR) register is greater than the upper threshold. *.
bool ADC_IsErrorLesserThanLowerThreshold (void)
Determines if the value in the ADC Setpoint Error (ADERR) register is lesser than the lower threshold.
adc_conversion_stage_t ADC_ConversionStageStatusGet (void)
Retrieves the conversion stage status.
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto-trigger source.
void ADC_ErrorCalculationModeSet (adc_calculation_mode_t errorCalculationMode)
Sets the ADC Error Calculation Mode Select (CALC) bits.
void ADC_CalculationRightShiftSet (uint8_t rightShiftValue)
Sets the ADC Accumulated Calculation Right Shift Select (CRS) bits.
void ADC_ChargePumpEnable (void)
Sets the ADC Charge Pump On Control (CPON) bit to '1'.
void ADC_ChargePumpDisable (void)
Sets the ADC Charge Pump On Control (CPON) bit to '0'.
bool ADC_IsChargePumpReady (void)
Checks the Charge Pump Ready status.
uint8_t ADC_ResolutionGet (void)
Returns the resolution of the ADC module.
bool ADC_IsBusy (void)
Returns the busy status of the ADC module.
void ADC_BusyStatusSet (bool status)
Sets the busy status of the ADC module.
void ADC_ConversionDoneInterruptFlagClear (void)
Clears the ADC Conversion Done Interrupt Flag (ADIF) bit to '0'.
void ADC_ThresholdInterruptFlagClear (void)
Sets the ADC Threshold Interrupt Flag (ADTIF) bit to '0'.
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) status.
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt (ADTIF) flag status.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Conversion Done Interrupt (ADI).
void ADC_ThresholdCallbackRegister (void(*callback)(void))
Sets the callback for the threshold interrupt.
void ADC_Tasks (void)
Implements the Tasks routine for the polling implementations.
Variables
static void(* ADC_ConversionDoneCallback )(void)
static void(* ADC_ThresholdCallback )(void)
static bool adc_busy_status
Detailed Description
This file contains the API implementations for the ADC driver.
ADC Generated Driver File
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.
-
Add ADCC to the project
-
Configure:
-
The ADCC as described in the example.
-
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.
-
Add ADCC
-
Add UART
-
Hardware Settings:
-
Operating Mode: Basic Mode (Default)
-
-
Configuration Settings:
-
Redirect Printf to UART: Yes.
-
-
Dependency Selector:
-
UART PLIB Selector: Select the UART that is connected to Serial/CDC port.
-
Redirect STDIO to UART (for printf support): Yes
-
-
Clock Configuration: Default (1 MHz)
-
Pins: (For all pins check board schematics)
-
Pin Grid View: Select an ANx.
-
Pin Grid View: Select pin for UART Transmit - Tx.
-
Pin Grid View: Select LED pin as output.
-
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
-
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.
-
Add ADCC
-
Add Timer (Use Case: 100 ms Timer)
-
Add Data Streamer (Use Case: Send Frames at a Period Set by the Timer)
-
Hardware Settings:
-
Operating Mode: Basic Mode (Default)
-
-
Software Settings:
-
UART Dependency Selection: Select the UART that is connected to Serial/CDC port.
-
-
Data Streamer Table:
-
uint16_t adcResult
-
uint8_t adcSampleCount
-
-
Clock Configuration: Default (1 MHz)
-
Pins: (For all pins check board schematics)
-
Pin Grid View: Select an ANx.
-
Pin Grid View: Select pin for UART Transmit - Tx.
-
Pin Grid View: Select LED pin as output.
-
Pin Grid View: Select Debug GPIO pin.
-
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.
-
Add ADCC
-
Add Data Streamer
-
Add Timer (Use Case: 100 ms Timer)
-
Hardware Settings:
-
Set Operating Mode: Basic_mode (default)
-
-
Computation Feature:
-
Threshold Interrupt Mode: ADERR < ADLTH or ADERR > ADUTH.
-
Lower Threshold: -35
-
Upper Threshold: 35
-
-
Interrupt Settings:
-
ADC Threshold Interrupt: Yes
-
-
Software Settings:
-
UART Dependency Selection: Select the UART that is connected to Serial/CDC port.
-
-
Data Streamer Table:
-
Add variable: uint16_t adcResult
-
Add variable: uint16_t adcResult_lastSpike
-
Add variable: uint8_t adcSpikeCount
-
-
Clock Configuration: Default (1 MHz)
-
Pins: (For all pins check board schematics)
-
Pin Grid View: Select an ANx.
-
Pin Grid View: Select pin for UART Transmit - Tx.
-
Pin Grid View: Select LED pin as output.
-
Pin Grid View: Select Debug GPIO pin.
-
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...
-
Hardware Settings:
-
Set Operating Mode : Average_mode
-
-
Computation Feature:
-
Set Repeat: 4
-
Set Accumulator Right Shift : 1
-