4.1.2.1 10-bit ADCC
10-bit ADC with Computation
4.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.
4.1.2.1.2 Supported Device Families
PIC18F-Q10 | PIC16F188xx |
4.1.2.1.3 Required header files:
#include "mcc_generated_files/adc/adcc.h"
4.1.2.1.4 Module Documentation
ADCC
Driver Version
Typedefs
-
typedef uint16_t adc_result_t
This typedef should be used for result of A/D conversion.
Enumerations
-
enum adcc_channel_t { channel_VSS = 0x3c, channel_Temp = 0x3d, channel_DAC1 = 0x3e, channel_FVR_buf1 = 0x3f }
This enumeration contains available ADC channels.
Functions
-
void ADCC_Initialize (void)
This API initializes the ADC module. This routine must be called before any other ADC routine.
-
void ADCC_StartConversion (adcc_channel_t channel)
This API starts A/D conversion on selected channel.
-
bool ADCC_IsConversionDone (void)
This API checks if ongoing A/D conversion is complete.
-
adc_result_t ADCC_GetConversionResult (void)
This API is used to retrieve the result of latest A/D conversion.
-
adc_result_t ADCC_GetSingleConversion (adcc_channel_t channel)
This API is used to retrieve the result of single A/D conversion on given channel.
-
void ADCC_StopConversion (void)
This API is used to stop ongoing A/D conversion.
-
void ADCC_SetStopOnInterrupt (void)
Stops the ADCC from re-triggering A/D conversion cycle upon completion of each conversion.
-
void ADCC_DischargeSampleCapacitor (void)
This API is used to discharge input sample capacitor by setting the channel to AVss.
-
void ADCC_LoadAcquisitionRegister (uint8_t acquisitionValue)
This API is used to load ADC Acquisition Time Control register with specified value.
-
void ADCC_SetPrechargeTime (uint8_t prechargeTime)
This API is used to load ADC Precharge Time Control register with specified value.
-
uint8_t ADCC_GetCurrentCountofConversions (void)
This API retrieves the current value of ADC Repeat Count register.
-
void ADCC_ClearAccumulator (void)
This API clears the accumulator.
-
uint16_t ADCC_GetAccumulatorValue (void)
This API retrieves 17-bit value of ADC accumulator.
-
bool ADCC_HasAccumulatorOverflowed (void)
This API is used to determine whether ADC accumulator has overflowed.
-
uint16_t ADCC_GetFilterValue (void)
This API retrieves the value of ADC Filter register.
-
uint16_t ADCC_GetPreviousResult (void)
This API retrieves the value of ADC Previous register.
-
void ADCC_DefineSetPoint (uint16_t setPoint)
This API used to set value of ADC Threshold Set-point.
-
void ADCC_SetUpperThreshold (uint16_t upperThreshold)
This API used to set value of ADC Upper Threshold register.
-
void ADCC_SetLowerThreshold (uint16_t lowerThreshold)
This API used to set value of ADC Lower Threshold register.
-
uint16_t ADCC_GetErrorCalculation (void)
This API retrieves the value of ADC Set-point Error register.
-
void ADCC_EnableDoubleSampling (void)
This API enables double-sampling bit.
-
void ADCC_EnableContinuousConversion (void)
This API enables continuous conversion.
-
void ADCC_DisableContinuousConversion (void)
This API disables continuous conversion.
-
bool ADCC_HasErrorCrossedUpperThreshold (void)
This API is used to determine if ADC error has crossed the upper threshold.
-
bool ADCC_HasErrorCrossedLowerThreshold (void)
This API is used to determine if ADC error is less than the lower threshold.
-
uint8_t ADCC_GetConversionStageStatus (void)
This API is used retrieve the multi-stage status.
-
void ADCC_SetADIInterruptHandler (void(*InterruptHandler)(void))
This routine is used to set the callback for the ADI Interrupt.
-
void ADCC_ISR (void)
This routine is used to implement the ISR for the interrupt-driven implementations.
-
void ADCC_SetADTIInterruptHandler (void(*InterruptHandler)(void))
This routine is used to set the callback for the ADTI Interrupt.
-
void ADCC_ThresholdISR (void)
This routine is used to implement the ISR for the interrupt-driven implementations.
Typedef Documentation
adc_result_t
This typedef should be used for result of A/D conversion.
Section: Included FilesSection: Data Types Definitions
Function Documentation
ADCC_ClearAccumulator()
void ADCC_ClearAccumulator (void )
This API clears the accumulator.
|
none |
ADCC_DefineSetPoint()
void ADCC_DefineSetPoint (uint16_t setPoint)
This API used to set value of ADC Threshold Set-point.
|
none |
ADCC_DisableContinuousConversion()
void ADCC_DisableContinuousConversion (void )
This API disables continuous conversion.
|
none |
ADCC_DischargeSampleCapacitor()
void ADCC_DischargeSampleCapacitor (void )
This API is used to discharge input sample capacitor by setting the channel to AVss.
|
none |
ADCC_EnableContinuousConversion()
void ADCC_EnableContinuousConversion (void )
This API enables continuous conversion.
|
none |
ADCC_EnableDoubleSampling()
void ADCC_EnableDoubleSampling (void )
This API enables double-sampling bit.
|
none |
ADCC_GetAccumulatorValue()
uint16_t ADCC_GetAccumulatorValue (void )
This API retrieves 17-bit value of ADC accumulator.
|
Value of ADC accumulator. |
ADCC_GetConversionResult()
adc_result_t ADCC_GetConversionResult (void )
This API is used to retrieve the result of latest A/D conversion.
ADCC_StartConversion() should be called before calling this function and completion status should be checked using ADCC_IsConversionDone() routine. |
|
The result of A/D conversion. Refer adc_result_t |
ADCC_GetConversionStageStatus()
uint8_t ADCC_GetConversionStageStatus (void )
This API is used retrieve the multi-stage status.
ADCC_StartConversion() should be called before calling this function. |
|
Contents of ADC STATUS register. |
ADCC_GetCurrentCountofConversions()
uint8_t ADCC_GetCurrentCountofConversions (void )
This API retrieves the current value of ADC Repeat Count register.
ADCC_StartConversion() should be called before calling this function. |
|
Current value of ADC Repeat Count register |
ADCC_GetErrorCalculation()
uint16_t ADCC_GetErrorCalculation (void )
This API retrieves the value of ADC Set-point Error register.
ADCC_StartConversion() should be called before calling this function. |
|
16-bit value obtained from ADERRH and ADERRL registers. |
ADCC_GetFilterValue()
uint16_t ADCC_GetFilterValue (void )
This API retrieves the value of ADC Filter register.
|
16-bit value obtained from ADFLTRH and ADFLTRL registers. |
ADCC_GetPreviousResult()
uint16_t ADCC_GetPreviousResult (void )
This API retrieves the value of ADC Previous register.
ADCC_StartConversion() should be called before calling this function. |
|
16-bit value obtained from ADPREVH and ADPREVL registers. |
ADCC_GetSingleConversion()
adc_result_t ADCC_GetSingleConversion (adcc_channel_t channel)
This API is used to retrieve the result of single A/D conversion on given channel.
ADCC_DisableContinuousConversion() function should have been called before calling this function |
|
The result of A/D conversion. Refer adc_result_t |
ADCC_HasAccumulatorOverflowed()
bool ADCC_HasAccumulatorOverflowed (void )
This API is used to determine whether ADC accumulator has overflowed.
ADCC_StartConversion() should be called before calling this function. |
|
|
ADCC_HasErrorCrossedLowerThreshold()
bool ADCC_HasErrorCrossedLowerThreshold (void )
This API is used to determine if ADC error is less than the lower threshold.
ADCC_StartConversion() should be called before calling this function. |
|
|
ADCC_HasErrorCrossedUpperThreshold()
bool ADCC_HasErrorCrossedUpperThreshold (void )
This API is used to determine if ADC error has crossed the upper threshold.
ADCC_StartConversion() should be called before calling this function. |
|
|
ADCC_Initialize()
void ADCC_Initialize (void )
This API initializes the ADC module. This routine must be called before any other ADC routine.
Section: ADCC Module APIs
|
none |
Section: ADCC Module APIs
ADCC_IsConversionDone()
bool ADCC_IsConversionDone (void )
This API checks if ongoing A/D conversion is complete.
ADCC_StartConversion() should be called before calling this function. |
|
|
ADCC_ISR()
void ADCC_ISR (void )
This routine is used to implement the ISR for the interrupt-driven implementations.
|
none |
ADCC_LoadAcquisitionRegister()
void ADCC_LoadAcquisitionRegister (uint8_t acquisitionValue)
This API is used to load ADC Acquisition Time Control register with specified value.
|
none |
ADCC_SetADIInterruptHandler()
void ADCC_SetADIInterruptHandler (void(*)(void) InterruptHandler)
This routine is used to set the callback for the ADI Interrupt.
|
none |
ADCC_SetADTIInterruptHandler()
void ADCC_SetADTIInterruptHandler (void(*)(void) InterruptHandler)
This routine is used to set the callback for the ADTI Interrupt.
|
none |
ADCC_SetLowerThreshold()
void ADCC_SetLowerThreshold (uint16_t lowerThreshold)
This API used to set value of ADC Lower Threshold register.
|
none |
ADCC_SetPrechargeTime()
void ADCC_SetPrechargeTime (uint8_t prechargeTime)
This API is used to load ADC Precharge Time Control register with specified value.
|
none |
ADCC_SetStopOnInterrupt()
void ADCC_SetStopOnInterrupt (void )
Stops the ADCC from re-triggering A/D conversion cycle upon completion of each conversion.
ADCC_EnableContinuousConversion() function should have been called before calling this function. |
|
none |
ADCC_SetUpperThreshold()
void ADCC_SetUpperThreshold (uint16_t upperThreshold)
This API used to set value of ADC Upper Threshold register.
|
none |
ADCC_StartConversion()
void ADCC_StartConversion (adcc_channel_t channel)
This API starts A/D conversion on selected channel.
|
none |
ADCC_StopConversion()
void ADCC_StopConversion (void )
This API is used to stop ongoing A/D conversion.
ADCC_StartConversion() function should have been called before calling this function. |
|
none |
ADCC_ThresholdISR()
void ADCC_ThresholdISR (void )
This routine is used to implement the ISR for the interrupt-driven implementations.
|
none |
4.1.2.1.5 File Documentation
source/adcc.c File Reference
This is the generated driver implementation file for the ADCC driver.
#include <xc.h>
#include "../adcc.h"
Functions
-
static void ADCC_DefaultADI_ISR (void)
-
static void ADCC_DefaultADTI_ISR (void)
-
void ADCC_Initialize (void)
This API initializes the ADC module. This routine must be called before any other ADC routine.
-
void ADCC_StartConversion (adcc_channel_t channel)
This API starts A/D conversion on selected channel.
-
bool ADCC_IsConversionDone (void)
This API checks if ongoing A/D conversion is complete.
-
adc_result_t ADCC_GetConversionResult (void)
This API is used to retrieve the result of latest A/D conversion.
-
adc_result_t ADCC_GetSingleConversion (adcc_channel_t channel)
This API is used to retrieve the result of single A/D conversion on given channel.
-
void ADCC_StopConversion (void)
This API is used to stop ongoing A/D conversion.
-
void ADCC_SetStopOnInterrupt (void)
Stops the ADCC from re-triggering A/D conversion cycle upon completion of each conversion.
-
void ADCC_DischargeSampleCapacitor (void)
This API is used to discharge input sample capacitor by setting the channel to AVss.
-
void ADCC_LoadAcquisitionRegister (uint8_t acquisitionValue)
This API is used to load ADC Acquisition Time Control register with specified value.
-
void ADCC_SetPrechargeTime (uint8_t prechargeTime)
This API is used to load ADC Precharge Time Control register with specified value.
-
void ADCC_SetRepeatCount (uint8_t repeatCount)
-
uint8_t ADCC_GetCurrentCountofConversions (void)
This API retrieves the current value of ADC Repeat Count register.
-
void ADCC_ClearAccumulator (void)
This API clears the accumulator.
-
uint16_t ADCC_GetAccumulatorValue (void)
This API retrieves 17-bit value of ADC accumulator.
-
bool ADCC_HasAccumulatorOverflowed (void)
This API is used to determine whether ADC accumulator has overflowed.
-
uint16_t ADCC_GetFilterValue (void)
This API retrieves the value of ADC Filter register.
-
uint16_t ADCC_GetPreviousResult (void)
This API retrieves the value of ADC Previous register.
-
void ADCC_DefineSetPoint (uint16_t setPoint)
This API used to set value of ADC Threshold Set-point.
-
void ADCC_SetUpperThreshold (uint16_t upperThreshold)
This API used to set value of ADC Upper Threshold register.
-
void ADCC_SetLowerThreshold (uint16_t lowerThreshold)
This API used to set value of ADC Lower Threshold register.
-
uint16_t ADCC_GetErrorCalculation (void)
This API retrieves the value of ADC Set-point Error register.
-
void ADCC_EnableDoubleSampling (void)
This API enables double-sampling bit.
-
void ADCC_EnableContinuousConversion (void)
This API enables continuous conversion.
-
void ADCC_DisableContinuousConversion (void)
This API disables continuous conversion.
-
bool ADCC_HasErrorCrossedUpperThreshold (void)
This API is used to determine if ADC error has crossed the upper threshold.
-
bool ADCC_HasErrorCrossedLowerThreshold (void)
This API is used to determine if ADC error is less than the lower threshold.
-
uint8_t ADCC_GetConversionStageStatus (void)
This API is used retrieve the multi-stage status.
-
void ADCC_ISR (void)
This routine is used to implement the ISR for the interrupt-driven implementations.
-
void ADCC_SetADIInterruptHandler (void(*InterruptHandler)(void))
This routine is used to set the callback for the ADI Interrupt.
-
void ADCC_ThresholdISR (void)
This routine is used to implement the ISR for the interrupt-driven implementations.
-
void ADCC_SetADTIInterruptHandler (void(*InterruptHandler)(void))
This routine is used to set the callback for the ADTI Interrupt.
Variables
-
static void(* ADCC_ADI_InterruptHandler )(void)
-
static void(* ADCC_ADTI_InterruptHandler )(void)
Detailed Description
This is the generated driver implementation file for the ADCC driver.
ADCC Generated Driver File
Variable Documentation
ADCC_ADI_InterruptHandler
void(* ADCC_ADI_InterruptHandler) (void)[static]
Section: Included Files
source/adcc.h File Reference
#include <stdint.h>
#include <stdbool.h>
Functions
-
void ADCC_Initialize (void)
This API initializes the ADC module. This routine must be called before any other ADC routine.
-
void ADCC_StartConversion (adcc_channel_t channel)
This API starts A/D conversion on selected channel.
-
bool ADCC_IsConversionDone (void)
This API checks if ongoing A/D conversion is complete.
-
adc_result_t ADCC_GetConversionResult (void)
This API is used to retrieve the result of latest A/D conversion.
-
adc_result_t ADCC_GetSingleConversion (adcc_channel_t channel)
This API is used to retrieve the result of single A/D conversion on given channel.
-
void ADCC_StopConversion (void)
This API is used to stop ongoing A/D conversion.
-
void ADCC_SetStopOnInterrupt (void)
Stops the ADCC from re-triggering A/D conversion cycle upon completion of each conversion.
-
void ADCC_DischargeSampleCapacitor (void)
This API is used to discharge input sample capacitor by setting the channel to AVss.
-
void ADCC_LoadAcquisitionRegister (uint8_t acquisitionValue)
This API is used to load ADC Acquisition Time Control register with specified value.
-
void ADCC_SetPrechargeTime (uint8_t prechargeTime)
This API is used to load ADC Precharge Time Control register with specified value.
-
uint8_t ADCC_GetCurrentCountofConversions (void)
This API retrieves the current value of ADC Repeat Count register.
-
void ADCC_ClearAccumulator (void)
This API clears the accumulator.
-
uint16_t ADCC_GetAccumulatorValue (void)
This API retrieves 17-bit value of ADC accumulator.
-
bool ADCC_HasAccumulatorOverflowed (void)
This API is used to determine whether ADC accumulator has overflowed.
-
uint16_t ADCC_GetFilterValue (void)
This API retrieves the value of ADC Filter register.
-
uint16_t ADCC_GetPreviousResult (void)
This API retrieves the value of ADC Previous register.
-
void ADCC_DefineSetPoint (uint16_t setPoint)
This API used to set value of ADC Threshold Set-point.
-
void ADCC_SetUpperThreshold (uint16_t upperThreshold)
This API used to set value of ADC Upper Threshold register.
-
void ADCC_SetLowerThreshold (uint16_t lowerThreshold)
This API used to set value of ADC Lower Threshold register.
-
uint16_t ADCC_GetErrorCalculation (void)
This API retrieves the value of ADC Set-point Error register.
-
void ADCC_EnableDoubleSampling (void)
This API enables double-sampling bit.
-
void ADCC_EnableContinuousConversion (void)
This API enables continuous conversion.
-
void ADCC_DisableContinuousConversion (void)
This API disables continuous conversion.
-
bool ADCC_HasErrorCrossedUpperThreshold (void)
This API is used to determine if ADC error has crossed the upper threshold.
-
bool ADCC_HasErrorCrossedLowerThreshold (void)
This API is used to determine if ADC error is less than the lower threshold.
-
uint8_t ADCC_GetConversionStageStatus (void)
This API is used retrieve the multi-stage status.
-
void ADCC_SetADIInterruptHandler (void(*InterruptHandler)(void))
This routine is used to set the callback for the ADI Interrupt.
-
void ADCC_ISR (void)
This routine is used to implement the ISR for the interrupt-driven implementations.
-
void ADCC_SetADTIInterruptHandler (void(*InterruptHandler)(void))
This routine is used to set the callback for the ADTI Interrupt.
-
void ADCC_ThresholdISR (void)
This routine is used to implement the ISR for the interrupt-driven implementations.
Typedefs
-
typedef uint16_t adc_result_t
This typedef should be used for result of A/D conversion.
Enumerations
-
enum adcc_channel_t { channel_VSS = 0x3c, channel_Temp = 0x3d, channel_DAC1 = 0x3e, channel_FVR_buf1 = 0x3f }
This enumeration contains available ADC channels.
Detailed Description
ADCC Generated Driver API Header File