3.1.2.2 10-bit ADCC with Ch. Group Sel.
10-bit ADC with Computation and Channel Group Selection
3.1.2.2.1 Introduction
The Analog-to-Digital Converter with Computation (ADCC) peripheral converts both single-ended and differential analog input signals to a 10-bit binary representation of that signal. This peripheral takes in analog signals and combines them into a Sample-and-Hold (S/H) circuit. It is then fed to a converter to turn this measurement into a 10-digit binary number and is stored in the ADC result registers. This ADCC also supports Channel Grouping which allows multiple, simultaneous input connections to the ADC.
3.1.2.2.2 Supported Device Families
PIC16F180xx | PIC18F-Q20 |
3.1.2.2.3 Required header files:
#include "mcc_generated_files/adcc/adcc.h"
3.1.2.2.4 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 ADC_RESOLUTION 10U
ADC resolution value.
#define ADC_BIT_SET 1U
ADC bit set value.
#define ADC_BIT_CLEAR 0U
ADC bit clear value.
Enumerations
enum adc_channel_t { ADC_CHANNEL_ADCG1 = 0x23, ADC_CHANNEL_VSS = 0x3a, ADC_CHANNEL_TEMP = 0x3b, ADC_CHANNEL_FVR_BUF1 = 0x3e, ADC_CHANNEL_FVR_BUF2 = 0x3f, ADC_CHANNEL_ANA0 = 0x0 }
Enumeration that describes the 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 }
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 }
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 }
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_TMR6 = 0x7, ADC_TRIGGER_SOURCE_CCP1 = 0x8, ADC_TRIGGER_SOURCE_CCP2 = 0x9, ADC_TRIGGER_SOURCE_PWM3 = 0xa, ADC_TRIGGER_SOURCE_PWM4 = 0xb, ADC_TRIGGER_SOURCE_PWM5 = 0xc, ADC_TRIGGER_SOURCE_NCO1 = 0xd, ADC_TRIGGER_SOURCE_C1OUT = 0xe, ADC_TRIGGER_SOURCE_IOC = 0xf, ADC_TRIGGER_SOURCE_CLC1 = 0x10, ADC_TRIGGER_SOURCE_CLC2 = 0x11, ADC_TRIGGER_SOURCE_CLC3 = 0x12, ADC_TRIGGER_SOURCE_CLC4 = 0x13, ADC_TRIGGER_SOURCE_ADERRH = 0x14, ADC_TRIGGER_SOURCE_ADRESH = 0x15, ADC_TRIGGER_SOURCE_ADPCH = 0x16 }
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_2ND_PRECHARGE = 0x5, ADC_2ND_ACQUISITION = 0x6, ADC_2ND_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) ON bit to '1'.
void ADC_Disable (void)
Sets the ADC (Enable) ON 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_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_ThresholdInterruptFlagClear (void)
Sets the ADC Threshold Interrupt Flag bit to '0'.
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt (ADCHxIF) flag.
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto conversion trigger source.
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)
Sets the ADC Conversion Done Interrupt Flag (ADIF) bit to '0'.
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) 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 (ADHxIE) bit to '1'.
void ADC_ThresholdInterruptDisable (void)
Sets the ADC Threshold Interrupt Disable (ADHxIE) bit to '0'.
void ADC_ISR (void)
Implements the ADC Conversion Done 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
#define ADC_BIT_CLEAR 0U
ADC bit clear value.
ADC_BIT_SET
#define ADC_BIT_SET 1U
ADC bit set value.
ADC_RESOLUTION
#define ADC_RESOLUTION 10U
ADC resolution value.
IO_RA0
#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 conversion trigger source.
triggerSource |
Desired auto conversion 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_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 )
Sets 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) ON 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) ON 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_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 than the lower threshold |
ADC_ISR()
void ADC_ISR (void )
Implements the ADC Conversion Done Interrupt (ADI) service routine for the interrupt-driven implementations.
None. |
None. |
ADC_IsThresholdInterruptFlagSet()
bool ADC_IsThresholdInterruptFlagSet (void )
Checks the ADC Threshold Interrupt (ADCHxIF) flag.
None. |
True |
ADCHxIF flag is set |
False |
ADCHxIF flag 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.
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 Disable (ADHxIE) bit to '0'.
None. |
None. |
ADC_ThresholdInterruptEnable()
void ADC_ThresholdInterruptEnable (void )
Sets the ADC Threshold Interrupt Enable (ADHxIE) bit to '1'.
None. |
None. |
ADC_ThresholdInterruptFlagClear()
void ADC_ThresholdInterruptFlagClear (void )
Sets the ADC Threshold Interrupt Flag 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_channel_t
enum adc_channel_t
Enumeration that describes the available ADC channels.
ADC_CHANNEL_ADCG1 |
ADCG1 |
ADC_CHANNEL_VSS |
VSS |
ADC_CHANNEL_TEMP |
Temp |
ADC_CHANNEL_FVR_BUF1 |
FVR_buf1 |
ADC_CHANNEL_FVR_BUF2 |
FVR_buf2 |
ADC_CHANNEL_ANA0 |
IO_RA0: RA0 |
adc_computation_mode_t
enum adc_computation_mode_t
Enumeration for the ADC computation modes.
ADC_BASIC |
Basic_mode |
ADC_SERIES_ACCUMULATE |
Accumulate_mode |
ADC_SERIES_AVERAGE |
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_2ND_PRECHARGE |
2nd Precharge |
ADC_2ND_ACQUISITION |
2nd Acquisition |
ADC_2ND_CONVERSION |
2nd 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_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_TMR6 |
TMR6 |
ADC_TRIGGER_SOURCE_CCP1 |
CCP1 |
ADC_TRIGGER_SOURCE_CCP2 |
CCP2 |
ADC_TRIGGER_SOURCE_PWM3 |
PWM3 |
ADC_TRIGGER_SOURCE_PWM4 |
PWM4 |
ADC_TRIGGER_SOURCE_PWM5 |
PWM5 |
ADC_TRIGGER_SOURCE_NCO1 |
NCO1 |
ADC_TRIGGER_SOURCE_C1OUT |
C1OUT |
ADC_TRIGGER_SOURCE_IOC |
IOC |
ADC_TRIGGER_SOURCE_CLC1 |
CLC1 |
ADC_TRIGGER_SOURCE_CLC2 |
CLC2 |
ADC_TRIGGER_SOURCE_CLC3 |
CLC3 |
ADC_TRIGGER_SOURCE_CLC4 |
CLC4 |
ADC_TRIGGER_SOURCE_ADERRH |
ADERRH |
ADC_TRIGGER_SOURCE_ADRESH |
ADRESH |
ADC_TRIGGER_SOURCE_ADPCH |
ADPCH |
3.1.2.2.5 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) ON bit to '1'.
void ADC_Disable (void)
Sets the ADC (Enable) ON 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_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_ThresholdInterruptFlagClear (void)
Sets the ADC Threshold Interrupt Flag bit to '0'.
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt (ADCHxIF) flag.
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto conversion trigger source.
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)
Sets the ADC Conversion Done Interrupt Flag (ADIF) bit to '0'.
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) 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 (ADHxIE) bit to '1'.
void ADC_ThresholdInterruptDisable (void)
Sets the ADC Threshold Interrupt Disable (ADHxIE) bit to '0'.
void ADC_ISR (void)
Implements the ADC Conversion Done 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.
Detailed Description
ADC Generated Driver API Header File
source/Sngle-Ended_Tasks/adc/adc.h File Reference
Enter a short description of your topic here (optional).
This is the start of your topic.
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) ON bit to '1'.
-
void ADC_Disable (void)
Sets the ADC (Enable) ON 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_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_ThresholdInterruptFlagClear (void)
Sets the ADC Threshold Interrupt Flag bit to '0'.
-
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt (ADCHxIF) flag.
-
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto conversion trigger source.
-
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)
Sets the ADC Conversion Done Interrupt Flag (ADIF) bit to '0'.
-
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) 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 (ADHxIE) bit to '1'.
-
void ADC_ThresholdInterruptDisable (void)
Sets the ADC Threshold Interrupt Disable (ADHxIE) bit to '0'.
-
void ADC_ISR (void)
Implements the ADC Conversion Done 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 routines for the polling implementations.
Macros
-
#define IO_RA0 ADC_CHANNEL_ANA0
Defines the Custom Name pin mapping for channels in adc_channel_t.
Detailed Description
ADC Generated Driver API Header File
source/Single-Ended_Interrupts/adc/adc_types.h File Reference
Macros
#define ADC_RESOLUTION 10U
ADC resolution value.
#define ADC_BIT_SET 1U
ADC bit set value.
#define ADC_BIT_CLEAR 0U
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_ADCG1 = 0x23, ADC_CHANNEL_VSS = 0x3a, ADC_CHANNEL_TEMP = 0x3b, ADC_CHANNEL_FVR_BUF1 = 0x3e, ADC_CHANNEL_FVR_BUF2 = 0x3f, ADC_CHANNEL_ANA0 = 0x0 }
Enumeration that describes the 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 }
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 }
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 }
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_TMR6 = 0x7, ADC_TRIGGER_SOURCE_CCP1 = 0x8, ADC_TRIGGER_SOURCE_CCP2 = 0x9, ADC_TRIGGER_SOURCE_PWM3 = 0xa, ADC_TRIGGER_SOURCE_PWM4 = 0xb, ADC_TRIGGER_SOURCE_PWM5 = 0xc, ADC_TRIGGER_SOURCE_NCO1 = 0xd, ADC_TRIGGER_SOURCE_C1OUT = 0xe, ADC_TRIGGER_SOURCE_IOC = 0xf, ADC_TRIGGER_SOURCE_CLC1 = 0x10, ADC_TRIGGER_SOURCE_CLC2 = 0x11, ADC_TRIGGER_SOURCE_CLC3 = 0x12, ADC_TRIGGER_SOURCE_CLC4 = 0x13, ADC_TRIGGER_SOURCE_ADERRH = 0x14, ADC_TRIGGER_SOURCE_ADRESH = 0x15, ADC_TRIGGER_SOURCE_ADPCH = 0x16 }
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_2ND_PRECHARGE = 0x5, ADC_2ND_ACQUISITION = 0x6, ADC_2ND_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
Enter a short description of your topic here (optional).
This is the start of your topic.
Macros
-
#define ADC_RESOLUTION 10U
ADC resolution value.
-
#define ADC_BIT_SET 1U
ADC bit set value.
-
#define ADC_BIT_CLEAR 0U
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_ADCG1 = 0x23, ADC_CHANNEL_VSS = 0x3a, ADC_CHANNEL_TEMP = 0x3b, ADC_CHANNEL_FVR_BUF1 = 0x3e, ADC_CHANNEL_FVR_BUF2 = 0x3f, ADC_CHANNEL_ANA0 = 0x0 }
Enumeration that describes the 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 }
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 }
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 }
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_TMR6 = 0x7, ADC_TRIGGER_SOURCE_CCP1 = 0x8, ADC_TRIGGER_SOURCE_CCP2 = 0x9, ADC_TRIGGER_SOURCE_PWM3 = 0xa, ADC_TRIGGER_SOURCE_PWM4 = 0xb, ADC_TRIGGER_SOURCE_PWM5 = 0xc, ADC_TRIGGER_SOURCE_NCO1 = 0xd, ADC_TRIGGER_SOURCE_C1OUT = 0xe, ADC_TRIGGER_SOURCE_IOC = 0xf, ADC_TRIGGER_SOURCE_CLC1 = 0x10, ADC_TRIGGER_SOURCE_CLC2 = 0x11, ADC_TRIGGER_SOURCE_CLC3 = 0x12, ADC_TRIGGER_SOURCE_CLC4 = 0x13, ADC_TRIGGER_SOURCE_ADERRH = 0x14, ADC_TRIGGER_SOURCE_ADRESH = 0x15, ADC_TRIGGER_SOURCE_ADPCH = 0x16 }
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_2ND_PRECHARGE = 0x5, ADC_2ND_ACQUISITION = 0x6, ADC_2ND_CONVERSION = 0x7 }
Enumeration for the ADC conversion stage statuses.
Detailed Description-types-task
ADC Type Definitions Header File
source/Single-Ended_Interrupts/adc/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) ON bit to '1'.
void ADC_Disable (void)
Sets the ADC (Enable) ON 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_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_ThresholdInterruptFlagClear (void)
Sets the ADC Threshold Interrupt Flag bit to '0'.
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt (ADCHxIF) flag.
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto conversion trigger source.
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)
Sets the ADC Conversion Done Interrupt Flag (ADIF) bit to '0'.
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) 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 (ADHxIE) bit to '1'.
void ADC_ThresholdInterruptDisable (void)
Sets the ADC Threshold Interrupt Disable (ADHxIE) bit to '0'.
void ADC_ISR (void)
Implements the ADC Conversion Done 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 bool adc_busy_status
static void(* ADC_ConversionDoneCallback )(void)
static void(* ADC_ThresholdCallback )(void)
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/adc.c File Reference
Enter a short description of your topic here (optional).
This is the start of your topic.
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) ON bit to '1'.
-
void ADC_Disable (void)
Sets the ADC (Enable) ON 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_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_ThresholdInterruptFlagClear (void)
Sets the ADC Threshold Interrupt Flag bit to '0'.
-
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt (ADCHxIF) flag.
-
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto conversion trigger source.
-
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)
Sets the ADC Conversion Done Interrupt Flag (ADIF) bit to '0'.
-
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) 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 (ADHxIE) bit to '1'.
-
void ADC_ThresholdInterruptDisable (void)
Sets the ADC Threshold Interrupt Disable (ADHxIE) bit to '0'.
-
void ADC_ISR (void)
Implements the ADC Conversion Done 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 routines for the polling implementations.
Variables
-
static bool adc_busy_status
-
static void(* ADC_ConversionDoneCallback )(void)
-
static void(* ADC_ThresholdCallback )(void)
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]