3.1.2.1 10-bit ADCC
10-bit ADC with Computation
3.1.2.1.1 Introduction
This Analog-to-Digital Converter with Computation (ADCC) module converts an analog voltage value into a 10-bit numerical value and offers different computational actions that can be performed on the result such as averaging or low-pass filtering.
3.1.2.1.2 Supported Device Families
PIC18F-Q10 | PIC16F188xx |
3.1.2.1.3 Required header files:
#include "mcc_generated_files/adc/adcc.h"
3.1.2.1.4 Module Documentation
Analog-to-Digital Converter (ADC)
This file contains the API prototypes and data types for the ADC driver.
Module description
This file contains the API prototypes and data types for the ADC driver.
This header file provides type definitions for the ADC module.
Typedefs
typedef int16_t adc_result_t
ADC conversion result type.
typedef uint16_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_RA1 ADC_CHANNEL_ANA1
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_VSS = 0x3c, ADC_CHANNEL_TEMP = 0x3d, ADC_CHANNEL_DAC1 = 0x3e, ADC_CHANNEL_FVR_BUF1 = 0x3f, ADC_CHANNEL_ANA1 = 0x1 }
Enumeration defining all available channels for ADC conversion.
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_PREVIOUS_RESULT_VALUE_ABOVE_OR_BELOW_SETPOINT = 0x3, ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE = 0x4, ADC_FILTERED_VALUE_VS_SETPOINT = 0x5, ADC_ACTUAL_RESULT_VS_THRESHOLD_VALUE = 0x6, ADC_FILTERED_VALUE_VS_THRESHOLD_VALUE = 0x7 }
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_TMR5 = 0x7, ADC_TRIGGER_SOURCE_TMR6 = 0x8, ADC_TRIGGER_SOURCE_CCP1 = 0x9, ADC_TRIGGER_SOURCE_CCP2 = 0xa, ADC_TRIGGER_SOURCE_PWM3 = 0xb, ADC_TRIGGER_SOURCE_PWM4 = 0xc, ADC_TRIGGER_SOURCE_C1OUT = 0xd, ADC_TRIGGER_SOURCE_C2OUT = 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_CLC5 = 0x14, ADC_TRIGGER_SOURCE_CLC6 = 0x15, ADC_TRIGGER_SOURCE_CLC7 = 0x16, ADC_TRIGGER_SOURCE_CLC8 = 0x17, ADC_TRIGGER_SOURCE_ADERR = 0x1c, ADC_TRIGGER_SOURCE_ADRESH = 0x1d, ADC_TRIGGER_SOURCE_ADPCH = 0x1f }
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 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 ADC conversion on a selected channel.
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.
bool ADC_IsConversionDone (void)
Checks if ongoing ADC conversion is complete.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Conversion Done Interrupt (ADI).
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of the single conversion on the selected channel.
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_ConversionStop (void)
Stops the ongoing ADC conversion.
void ADC_SampleRepeatCountSet (adc_repeat_count_t repeatCount)
Loads the repeat counter with the specified value.
void ADC_ComputationModeSet (adc_computation_mode_t computationMode)
Sets the Computation mode.
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.
void ADC_ThresholdModeSet (adc_threshold_mode_t thresholdMode)
Sets the Conversion Threshold mode.
void ADC_ThresholdInterruptEnable (void)
Sets the ADC Threshold Interrupt Enable (ADTI) bit to 1.
void ADC_ThresholdInterruptDisable (void)
Sets the ADC Threshold Interrupt Enable (ADTI) bit to 0.
adc_accumulate_t ADC_AccumulatedResultGet (void)
Retrieves the value of accumulated conversions.
void ADC_ThresholdCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Threshold Interrupt (ADTI).
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 (uint8_t acquisitionValue)
Sets the specified value for the ADC Acquisition Time Control (ADACQ) register.
void ADC_PrechargeTimeSet (uint8_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 ADERR register is greater than the upper threshold.
bool ADC_IsErrorLesserThanLowerThreshold (void)
Determines if the value in the ADERR register is less 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-conversion 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_ConversionDoneInterruptFlagClear (void)
Clears the ADC Conversion Done Interrupt Flag (ADIF).
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) status.
void ADC_ThresholdInterruptFlagClear (void)
Clears the ADC Threshold Interrupt Flag (ADTIF).
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt Flag (ADTIF) status.
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_RA1
#define IO_RA1 ADC_CHANNEL_ANA1
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 accumulated conversions.
None. |
@adc_accumulate_t - The value of accumulated conversions |
ADC_AccumulatorClear()
void ADC_AccumulatorClear (void )
Clears the accumulator.
None. |
None. |
ADC_AcquisitionTimeSet()
void ADC_AcquisitionTimeSet (uint8_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-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).
*callback |
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).
None. |
None. |
ADC_ConversionResultGet()
adc_result_t ADC_ConversionResultGet (void )
Retrieves the result of the latest conversion.
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 - Status of conversion stages |
ADC_ConversionStart()
void ADC_ConversionStart (void )
Starts the ADC conversion on a selected channel.
Select the channel 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 ADC 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 ADACC is right shifted by the CRS bits. In 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 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 ongoing ADC conversion is complete.
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 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 ADERR register is less 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 Flag (ADTIF) status.
None. |
True |
ADTI flag is set |
False |
ADTI 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 (uint8_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 function for the ADC Threshold Interrupt (ADTI).
*callback |
The pointer to the function to be executed |
None. |
ADC_ThresholdInterruptDisable()
void ADC_ThresholdInterruptDisable (void )
Sets the ADC Threshold Interrupt Enable (ADTI) bit to 0.
None. |
None. |
ADC_ThresholdInterruptEnable()
void ADC_ThresholdInterruptEnable (void )
Sets the ADC Threshold Interrupt Enable (ADTI) bit to 1.
None. |
None. |
ADC_ThresholdInterruptFlagClear()
void ADC_ThresholdInterruptFlagClear (void )
Clears the ADC Threshold Interrupt Flag (ADTIF).
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_PREVIOUS_RESULT_VALUE_ABOVE_OR_BELOW_SETPOINT |
Previous result value above or below setpoint |
ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE |
First derivative of filtered value |
ADC_FILTERED_VALUE_VS_SETPOINT |
Filtered value vs setpoint |
ADC_ACTUAL_RESULT_VS_THRESHOLD_VALUE |
Actual result vs threshold value |
ADC_FILTERED_VALUE_VS_THRESHOLD_VALUE |
Filtered value vs threshold value |
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_PREVIOUS_RESULT_VALUE_ABOVE_OR_BELOW_SETPOINT |
Previous result value above or below setpoint |
ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE |
First derivative of filtered value |
ADC_FILTERED_VALUE_VS_SETPOINT |
Filtered value vs setpoint |
ADC_ACTUAL_RESULT_VS_THRESHOLD_VALUE |
Actual result vs threshold value |
ADC_FILTERED_VALUE_VS_THRESHOLD_VALUE |
Filtered value vs threshold value |
adc_channel_t
enum adc_channel_t
Enumeration defining all available channels for ADC conversion.
ADC_CHANNEL_VSS | VSS |
ADC_CHANNEL_TEMP | Temp |
ADC_CHANNEL_DAC1 | DAC1 |
ADC_CHANNEL_FVR_BUF1 | FVR_buf1 |
ADC_CHANNEL_ANA1 | IO_RA1: RA1 |
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_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_TMR5 | TMR5 |
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_C1OUT | C1OUT |
ADC_TRIGGER_SOURCE_C2OUT | C2OUT |
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_CLC5 | CLC5 |
ADC_TRIGGER_SOURCE_CLC6 | CLC6 |
ADC_TRIGGER_SOURCE_CLC7 | CLC7 |
ADC_TRIGGER_SOURCE_CLC8 | CLC8 |
ADC_TRIGGER_SOURCE_ADERR | ADERR |
ADC_TRIGGER_SOURCE_ADRESH | ADRESH |
ADC_TRIGGER_SOURCE_ADPCH | ADPCH |
3.1.2.1.5 File Documentation
source/Single-Ended_Interrupts/adc.h File Reference
#include <stdint.h> #include <stdbool.h> #include "./adc_types.h"
Functions
void ADC_Initialize (void)
Initializes the registers based on 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 ADC conversion on a selected channel.
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.
bool ADC_IsConversionDone (void)
Checks if ongoing ADC conversion is complete.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Conversion Done Interrupt (ADI).
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of the single conversion on the selected channel.
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_ConversionStop (void)
Stops the ongoing ADC conversion.
void ADC_SampleRepeatCountSet (adc_repeat_count_t repeatCount)
Loads the repeat counter with the specified value.
void ADC_ComputationModeSet (adc_computation_mode_t computationMode)
Sets the Computation mode.
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.
void ADC_ThresholdModeSet (adc_threshold_mode_t thresholdMode)
Sets the Conversion Threshold mode.
void ADC_ThresholdInterruptEnable (void)
Sets the ADC Threshold Interrupt Enable (ADTI) bit to 1.
void ADC_ThresholdInterruptDisable (void)
Sets the ADC Threshold Interrupt Enable (ADTI) bit to 0.
adc_accumulate_t ADC_AccumulatedResultGet (void)
Retrieves the value of accumulated conversions.
void ADC_ThresholdCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Threshold Interrupt (ADTI).
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 (uint8_t acquisitionValue)
Sets the specified value for the ADC Acquisition Time Control (ADACQ) register.
void ADC_PrechargeTimeSet (uint8_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 ADERR register is greater than the upper threshold.
bool ADC_IsErrorLesserThanLowerThreshold (void)
Determines if the value in the ADERR register is less 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-conversion 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_ConversionDoneInterruptFlagClear (void)
Clears the ADC Conversion Done Interrupt Flag (ADIF).
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) status.
void ADC_ThresholdInterruptFlagClear (void)
Clears the ADC Threshold Interrupt Flag (ADTIF).
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt Flag (ADTIF) status.
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_RA1 ADC_CHANNEL_ANA1
Defines the Custom Name pin mapping for channels in adc_channel_t.
Detailed Description
ADC Generated Driver API Header File
source/Single-Ended_Tasks/adc.h File Reference
#include <stdint.h> #include <stdbool.h> #include "./adc_types.h"
Functions
void ADC_Initialize (void)
Initializes the registers based on 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 ADC conversion on a selected channel.
bool ADC_IsConversionDone (void)
Checks if ongoing ADC conversion is complete.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Conversion Done Interrupt (ADI).
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of the single conversion on the selected channel.
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_ConversionStop (void)
Stops the ongoing ADC conversion.
void ADC_SampleRepeatCountSet (adc_repeat_count_t repeatCount)
Loads the repeat counter with the specified value.
void ADC_ComputationModeSet (adc_computation_mode_t computationMode)
Sets the Computation mode.
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.
void ADC_ThresholdModeSet (adc_threshold_mode_t thresholdMode)
Sets the Conversion Threshold mode.
adc_accumulate_t ADC_AccumulatedResultGet (void)
Retrieves the value of accumulated conversions.
void ADC_ThresholdCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Threshold Interrupt (ADTI).
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 (uint8_t acquisitionValue)
Sets the specified value for the ADC Acquisition Time Control (ADACQ) register.
void ADC_PrechargeTimeSet (uint8_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 ADERR register is greater than the upper threshold.
bool ADC_IsErrorLesserThanLowerThreshold (void)
Determines if the value in the ADERR register is less 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-conversion 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_ConversionDoneInterruptFlagClear (void)
Clears the ADC Conversion Done Interrupt Flag (ADIF).
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) status.
void ADC_ThresholdInterruptFlagClear (void)
Clears the ADC Threshold Interrupt Flag (ADTIF).
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt Flag (ADTIF) status.
void ADC_Tasks (void)
Implements the Tasks routine for the polling implementations.
Macros
#define IO_RA1 ADC_CHANNEL_ANA1
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_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 uint16_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 = 0x3c, ADC_CHANNEL_TEMP = 0x3d, ADC_CHANNEL_DAC1 = 0x3e, ADC_CHANNEL_FVR_BUF1 = 0x3f, ADC_CHANNEL_ANA1 = 0x1, ADC_CHANNEL_VSS = 0x3c, ADC_CHANNEL_TEMP = 0x3d, ADC_CHANNEL_DAC1 = 0x3e, ADC_CHANNEL_FVR_BUF1 = 0x3f, ADC_CHANNEL_ANA1 = 0x1 }
Enumeration defining all available channels for ADC conversion.
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_PREVIOUS_RESULT_VALUE_ABOVE_OR_BELOW_SETPOINT = 0x3, ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE = 0x4, ADC_FILTERED_VALUE_VS_SETPOINT = 0x5, ADC_ACTUAL_RESULT_VS_THRESHOLD_VALUE = 0x6, ADC_FILTERED_VALUE_VS_THRESHOLD_VALUE = 0x7, ADC_FIRST_DERIVATIVE_OF_SINGLE_MEASUREMENT = 0x0, ADC_ACTUAL_RESULT_VS_SETPOINT = 0x1, ADC_ACTUAL_RESULT_VS_FILTERED_VALUE = 0x2, ADC_PREVIOUS_RESULT_VALUE_ABOVE_OR_BELOW_SETPOINT = 0x3, ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE = 0x4, ADC_FILTERED_VALUE_VS_SETPOINT = 0x5, ADC_ACTUAL_RESULT_VS_THRESHOLD_VALUE = 0x6, ADC_FILTERED_VALUE_VS_THRESHOLD_VALUE = 0x7 }
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_CCP1 = 0x9, ADC_TRIGGER_SOURCE_CCP2 = 0xa, ADC_TRIGGER_SOURCE_PWM3 = 0xb, ADC_TRIGGER_SOURCE_PWM4 = 0xc, ADC_TRIGGER_SOURCE_C1OUT = 0xd, ADC_TRIGGER_SOURCE_C2OUT = 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_CLC5 = 0x14, ADC_TRIGGER_SOURCE_CLC6 = 0x15, ADC_TRIGGER_SOURCE_CLC7 = 0x16, ADC_TRIGGER_SOURCE_CLC8 = 0x17, ADC_TRIGGER_SOURCE_ADERR = 0x1c, ADC_TRIGGER_SOURCE_ADRESH = 0x1d, ADC_TRIGGER_SOURCE_ADPCH = 0x1f, 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_CCP1 = 0x9, ADC_TRIGGER_SOURCE_CCP2 = 0xa, ADC_TRIGGER_SOURCE_PWM3 = 0xb, ADC_TRIGGER_SOURCE_PWM4 = 0xc, ADC_TRIGGER_SOURCE_C1OUT = 0xd, ADC_TRIGGER_SOURCE_C2OUT = 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_CLC5 = 0x14, ADC_TRIGGER_SOURCE_CLC6 = 0x15, ADC_TRIGGER_SOURCE_CLC7 = 0x16, ADC_TRIGGER_SOURCE_CLC8 = 0x17, ADC_TRIGGER_SOURCE_ADERR = 0x1c, ADC_TRIGGER_SOURCE_ADRESH = 0x1d, ADC_TRIGGER_SOURCE_ADPCH = 0x1f }
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, 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_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
typedef uint16_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 = 0x3c, ADC_CHANNEL_TEMP = 0x3d, ADC_CHANNEL_DAC1 = 0x3e, ADC_CHANNEL_FVR_BUF1 = 0x3f, ADC_CHANNEL_ANA1 = 0x1, ADC_CHANNEL_VSS = 0x3c, ADC_CHANNEL_TEMP = 0x3d, ADC_CHANNEL_DAC1 = 0x3e, ADC_CHANNEL_FVR_BUF1 = 0x3f, ADC_CHANNEL_ANA1 = 0x1 }
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_PREVIOUS_RESULT_VALUE_ABOVE_OR_BELOW_SETPOINT = 0x3, ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE = 0x4, ADC_FILTERED_VALUE_VS_SETPOINT = 0x5, ADC_ACTUAL_RESULT_VS_THRESHOLD_VALUE = 0x6, ADC_FILTERED_VALUE_VS_THRESHOLD_VALUE = 0x7, ADC_FIRST_DERIVATIVE_OF_SINGLE_MEASUREMENT = 0x0, ADC_ACTUAL_RESULT_VS_SETPOINT = 0x1, ADC_ACTUAL_RESULT_VS_FILTERED_VALUE = 0x2, ADC_PREVIOUS_RESULT_VALUE_ABOVE_OR_BELOW_SETPOINT = 0x3, ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE = 0x4, ADC_FILTERED_VALUE_VS_SETPOINT = 0x5, ADC_ACTUAL_RESULT_VS_THRESHOLD_VALUE = 0x6, ADC_FILTERED_VALUE_VS_THRESHOLD_VALUE = 0x7 }
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_CCP1 = 0x9, ADC_TRIGGER_SOURCE_CCP2 = 0xa, ADC_TRIGGER_SOURCE_PWM3 = 0xb, ADC_TRIGGER_SOURCE_PWM4 = 0xc, ADC_TRIGGER_SOURCE_C1OUT = 0xd, ADC_TRIGGER_SOURCE_C2OUT = 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_CLC5 = 0x14, ADC_TRIGGER_SOURCE_CLC6 = 0x15, ADC_TRIGGER_SOURCE_CLC7 = 0x16, ADC_TRIGGER_SOURCE_CLC8 = 0x17, ADC_TRIGGER_SOURCE_ADERR = 0x1c, ADC_TRIGGER_SOURCE_ADRESH = 0x1d, ADC_TRIGGER_SOURCE_ADPCH = 0x1f, 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_CCP1 = 0x9, ADC_TRIGGER_SOURCE_CCP2 = 0xa, ADC_TRIGGER_SOURCE_PWM3 = 0xb, ADC_TRIGGER_SOURCE_PWM4 = 0xc, ADC_TRIGGER_SOURCE_C1OUT = 0xd, ADC_TRIGGER_SOURCE_C2OUT = 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_CLC5 = 0x14, ADC_TRIGGER_SOURCE_CLC6 = 0x15, ADC_TRIGGER_SOURCE_CLC7 = 0x16, ADC_TRIGGER_SOURCE_CLC8 = 0x17, ADC_TRIGGER_SOURCE_ADERR = 0x1c, ADC_TRIGGER_SOURCE_ADRESH = 0x1d, ADC_TRIGGER_SOURCE_ADPCH = 0x1f }
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, 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 }
Detailed Description
ADC Type Definitions Header File
Typedef Documentation
adc_accumulate_t
typedef uint16_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_PREVIOUS_RESULT_VALUE_ABOVE_OR_BELOW_SETPOINT |
Previous result value above or below setpoint |
ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE |
First derivative of filtered value |
ADC_FILTERED_VALUE_VS_SETPOINT |
Filtered value vs setpoint |
ADC_ACTUAL_RESULT_VS_THRESHOLD_VALUE |
Actual result vs threshold value |
ADC_FILTERED_VALUE_VS_THRESHOLD_VALUE |
Filtered value vs threshold value |
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_PREVIOUS_RESULT_VALUE_ABOVE_OR_BELOW_SETPOINT |
Previous result value above or below setpoint |
ADC_FIRST_DERIVATIVE_OF_FILTERED_VALUE |
First derivative of filtered value |
ADC_FILTERED_VALUE_VS_SETPOINT |
Filtered value vs setpoint |
ADC_ACTUAL_RESULT_VS_THRESHOLD_VALUE |
Actual result vs threshold value |
ADC_FILTERED_VALUE_VS_THRESHOLD_VALUE |
Filtered value vs threshold value |
adc_channel_t
enum adc_channel_t
ADC_CHANNEL_VSS |
VSS |
ADC_CHANNEL_TEMP |
Temp |
ADC_CHANNEL_DAC1 |
DAC1 |
ADC_CHANNEL_FVR_BUF1 |
FVR_buf1 |
ADC_CHANNEL_ANA1 |
IO_RA1: RA1 |
ADC_CHANNEL_VSS |
VSS |
ADC_CHANNEL_TEMP |
Temp |
ADC_CHANNEL_DAC1 |
DAC1 |
ADC_CHANNEL_FVR_BUF1 |
FVR_buf1 |
ADC_CHANNEL_ANA1 |
IO_RA1: RA1 |
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_2ND_PRECHARGE |
2nd precharge |
ADC_2ND_ACQUISITION |
2nd acquisition |
ADC_2ND_CONVERSION |
2nd 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_2ND_PRECHARGE |
2nd precharge |
ADC_2ND_ACQUISITION |
2nd acquisition |
ADC_2ND_CONVERSION |
2nd 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_CCP1 |
CCP1 |
ADC_TRIGGER_SOURCE_CCP2 |
CCP2 |
ADC_TRIGGER_SOURCE_PWM3 |
PWM3 |
ADC_TRIGGER_SOURCE_PWM4 |
PWM4 |
ADC_TRIGGER_SOURCE_C1OUT |
C1OUT |
ADC_TRIGGER_SOURCE_C2OUT |
C2OUT |
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_CLC5 |
CLC5 |
ADC_TRIGGER_SOURCE_CLC6 |
CLC6 |
ADC_TRIGGER_SOURCE_CLC7 |
CLC7 |
ADC_TRIGGER_SOURCE_CLC8 |
CLC8 |
ADC_TRIGGER_SOURCE_ADERR |
ADERR |
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_CCP1 |
CCP1 |
ADC_TRIGGER_SOURCE_CCP2 |
CCP2 |
ADC_TRIGGER_SOURCE_PWM3 |
PWM3 |
ADC_TRIGGER_SOURCE_PWM4 |
PWM4 |
ADC_TRIGGER_SOURCE_C1OUT |
C1OUT |
ADC_TRIGGER_SOURCE_C2OUT |
C2OUT |
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_CLC5 |
CLC5 |
ADC_TRIGGER_SOURCE_CLC6 |
CLC6 |
ADC_TRIGGER_SOURCE_CLC7 |
CLC7 |
ADC_TRIGGER_SOURCE_CLC8 |
CLC8 |
ADC_TRIGGER_SOURCE_ADERR |
ADERR |
ADC_TRIGGER_SOURCE_ADRESH |
ADRESH |
ADC_TRIGGER_SOURCE_ADPCH |
ADPCH |
source/Single-Ended_Interrupts/src/adc.c File Reference
This file contains the API implementations for the ADC driver.
#include <xc.h> #include "../adc.h"
Functions
void ADC_Initialize (void)
Initializes the registers based on 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 ADC conversion on a selected channel.
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.
bool ADC_IsConversionDone (void)
Checks if ongoing ADC conversion is complete.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Conversion Done Interrupt (ADI).
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of the single conversion on the selected channel.
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_ConversionStop (void)
Stops the ongoing ADC conversion.
void ADC_SampleRepeatCountSet (adc_repeat_count_t repeatCount)
Loads the repeat counter with the specified value.
void ADC_ComputationModeSet (adc_computation_mode_t computationMode)
Sets the Computation mode.
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.
void ADC_ThresholdModeSet (adc_threshold_mode_t thresholdMode)
Sets the Conversion Threshold mode.
void ADC_ThresholdInterruptEnable (void)
Sets the ADC Threshold Interrupt Enable (ADTI) bit to 1.
void ADC_ThresholdInterruptDisable (void)
Sets the ADC Threshold Interrupt Enable (ADTI) bit to 0.
adc_accumulate_t ADC_AccumulatedResultGet (void)
Retrieves the value of accumulated conversions.
void ADC_ThresholdCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Threshold Interrupt (ADTI).
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 (uint8_t acquisitionValue)
Sets the specified value for the ADC Acquisition Time Control (ADACQ) register.
void ADC_PrechargeTimeSet (uint8_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 ADERR register is greater than the upper threshold.
bool ADC_IsErrorLesserThanLowerThreshold (void)
Determines if the value in the ADERR register is less 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-conversion 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_ConversionDoneInterruptFlagClear (void)
Clears the ADC Conversion Done Interrupt Flag (ADIF).
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) status.
void ADC_ThresholdInterruptFlagClear (void)
Clears the ADC Threshold Interrupt Flag (ADTIF).
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt Flag (ADTIF) status.
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 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/src/adc.c File Reference
This file contains the API implementations for the ADC driver.
#include <xc.h> #include "../adc.h"
Functions
void ADC_Initialize (void)
Initializes the registers based on 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 ADC conversion on a selected channel.
bool ADC_IsConversionDone (void)
Checks if ongoing ADC conversion is complete.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Conversion Done Interrupt (ADI).
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of the single conversion on the selected channel.
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_ConversionStop (void)
Stops the ongoing ADC conversion.
void ADC_SampleRepeatCountSet (adc_repeat_count_t repeatCount)
Loads the repeat counter with the specified value.
void ADC_ComputationModeSet (adc_computation_mode_t computationMode)
Sets the Computation mode.
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.
void ADC_ThresholdModeSet (adc_threshold_mode_t thresholdMode)
Sets the Conversion Threshold mode.
adc_accumulate_t ADC_AccumulatedResultGet (void)
Retrieves the value of accumulated conversions.
void ADC_ThresholdCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Threshold Interrupt (ADTI).
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 (uint8_t acquisitionValue)
Sets the specified value for the ADC Acquisition Time Control (ADACQ) register.
void ADC_PrechargeTimeSet (uint8_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 ADERR register is greater than the upper threshold.
bool ADC_IsErrorLesserThanLowerThreshold (void)
Determines if the value in the ADERR register is less 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-conversion 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_ConversionDoneInterruptFlagClear (void)
Clears the ADC Conversion Done Interrupt Flag (ADIF).
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Conversion Done Interrupt Flag (ADIF) status.
void ADC_ThresholdInterruptFlagClear (void)
Clears the ADC Threshold Interrupt Flag (ADTIF).
bool ADC_IsThresholdInterruptFlagSet (void)
Checks the ADC Threshold Interrupt Flag (ADTIF) status.
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]