4.1.2.4 12-bit ADCC with +/- Ch. Sel.
12-bit ADC with Computation and Positive and Negative Channel Selection
4.1.2.4.1 Introduction
This Analog-to-Digital Converter with Computation (ADCC) module converts both single-ended and differential analog input signals to a 12-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 12-digit binary number and is stored in the ADC result registers. This ADCC module also features positive and negative channel grouping which allows multiple input channels to be grouped together into a single input channel.
4.1.2.4.2 Supported Device Families
PIC16F171xx | PIC16F181x |
4.1.2.4.3 Required header files:
#include "mcc_generated_files/adcc/adcc.h"
4.1.2.4.4 Module Documentation
ADCC
This is the generated header file for the ADCC driver.
Module description
This is the generated header file for the ADCC driver.
Typedefs
typedef int16_t adc_result_t
This typedef should be used for result of A/D conversion.
Enumerations
enum adcc_posChannel_t { pChannel_ADCG1 = 0x23, pChannel_VSS = 0x3a, pChannel_Temp = 0x3b, pChannel_DAC1OUT = 0x3c, pChannel_DAC2OUT = 0x3d, pChannel_FVR_Buffer1 = 0x3e, pChannel_FVR_Buffer2 = 0x3f }
This enumeration contains available ADC positive channels.
enum adcc_negChannel_t { nChannel_VSS = 0x3a, nChannel_Temp = 0x3b, nChannel_DAC1OUT = 0x3c, nChannel_DAC2OUT = 0x3d, nChannel_FVR_Buffer1 = 0x3e, nChannel_FVR_Buffer2 = 0x3f }
This enumeration contains available ADC negative 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_posChannel_t posChannel, adcc_negChannel_t negChannel)
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_posChannel_t posChannel, adcc_negChannel_t negChannel)
This API is used to retrieve the result of single A/D conversion on given channels in differential mode..
void ADCC_StopConversion (void)
This API is used to stop ongoing A/D conversion.
void ADCC_SetStopOnInterrupt (void)
This API is used enable Stop On Interrupt bit.
void ADCC_DischargeSampleCapacitor (void)
This API is used to discharge input sample capacitor by setting the channel to AVss.
void ADCC_LoadAcquisitionRegister (uint16_t acquisitionValue)
This API is used to load ADC Acquisition Time Control register with specified value.
void ADCC_SetPrechargeTime (uint16_t prechargeTime)
This API is used to load ADC Precharge Time Control register with specified value.
void ADCC_SetRepeatCount (uint8_t repeatCount)
This API is used to load repeat counter 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.
int24_t ADCC_GetAccumulatorValue (void)
This API retrieves 18-bit value of ADC accumulator.
bool ADCC_HasAccumulatorOverflowed (void)
This API is used to determine whether ADC accumulator has overflowed.
int16_t ADCC_GetFilterValue (void)
This API retrieves the value of ADC Filter register.
int16_t ADCC_GetPreviousResult (void)
This API retrieves the value of ADC Previous register.
void ADCC_DefineSetPoint (int16_t setPoint)
This API used to set value of ADC Threshold Set-point.
void ADCC_SetUpperThreshold (int16_t upperThreshold)
This API used to set value of ADC Upper Threshold register.
void ADCC_SetLowerThreshold (int16_t lowerThreshold)
This API used to set value of ADC Lower Threshold register.
int16_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 Threshold ISR for the interrupt-driven implementations.
Typedef Documentation
adc_result_t
adc_result_t
This typedef should be used for result of A/D conversion.
Section: Included Files
Function Documentation
ADCC_ClearAccumulator()
void ADCC_ClearAccumulator (void )[inline]
This API clears the accumulator.
none |
none |
ADCC_DefineSetPoint()
void ADCC_DefineSetPoint (int16_t setPoint)
This API used to set value of ADC Threshold Set-point.
setPoint |
- 16-bit value for set point. |
none |
ADCC_DisableContinuousConversion()
void ADCC_DisableContinuousConversion (void )[inline]
This API disables continuous conversion.
none |
none |
ADCC_DischargeSampleCapacitor()
void ADCC_DischargeSampleCapacitor (void )[inline]
This API is used to discharge input sample capacitor by setting the channel to AVss.
none |
none |
ADCC_EnableContinuousConversion()
void ADCC_EnableContinuousConversion (void )[inline]
This API enables continuous conversion.
none |
none |
ADCC_EnableDoubleSampling()
void ADCC_EnableDoubleSampling (void )[inline]
This API enables double-sampling bit.
none |
none |
ADCC_GetAccumulatorValue()
int24_t ADCC_GetAccumulatorValue (void )
This API retrieves 18-bit value of ADC accumulator.
none |
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 function should be called before calling this function and completion status should be checked using ADCC_IsConversionDone function. |
none |
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 function should be called before calling this function. |
none |
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 function should be called before calling this function. |
none |
Current value of ADC Repeat Count register |
ADCC_GetErrorCalculation()
int16_t ADCC_GetErrorCalculation (void )
This API retrieves the value of ADC Set-point Error register.
ADCC_StartConversion function should be called before calling this function. |
none |
16-bit value obtained from ADERRH and ADERRL registers. |
ADCC_GetFilterValue()
int16_t ADCC_GetFilterValue (void )
This API retrieves the value of ADC Filter register.
none |
16-bit value obtained from ADFLTRH and ADFLTRL registers. |
ADCC_GetPreviousResult()
int16_t ADCC_GetPreviousResult (void )
This API retrieves the value of ADC Previous register.
ADCC_StartConversion function should be called before calling this function. |
none |
16-bit value obtained from ADPREVH and ADPREVL registers. |
ADCC_GetSingleConversion()
adc_result_t ADCC_GetSingleConversion (adcc_posChannel_t posChannel, adcc_negChannel_t negChannel)
This API is used to retrieve the result of single A/D conversion on given channels in differential mode..
ADCC_DisableContinuousConversion function should have been called before calling this function |
posChannel |
- Positive Analog channel number on which A/D conversion has to be applied. Refer adcc_posChannel_t for available list of positive channels negChannel - Negative Analog channel number on which A/D conversion has to be applied. Refer adcc_ngChannel_t for available list of negative channels |
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 function should be called before calling this function. |
none |
true |
- ADC accumulator has overflowed |
false |
- ADC accumulator has not overflowed |
ADCC_HasErrorCrossedLowerThreshold()
bool ADCC_HasErrorCrossedLowerThreshold (void )
This API is used to determine if ADC error is less than the lower threshold.
ADCC_StartConversion function should be called before calling this function. |
none |
true |
- if ERR < LTH |
false |
- if ERR >= LTH |
ADCC_HasErrorCrossedUpperThreshold()
bool ADCC_HasErrorCrossedUpperThreshold (void )
This API is used to determine if ADC error has crossed the upper threshold.
ADCC_StartConversion function should be called before calling this function. |
none |
true |
- if ERR > UTH |
false |
- if ERR <= UTH |
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 |
none |
Section: ADCC Module APIs
ADCC_IsConversionDone()
bool ADCC_IsConversionDone (void )
This API checks if ongoing A/D conversion is complete.
ADCC_StartConversion function should be called before calling this function. |
none |
true |
- if conversion is complete |
false |
- if conversion is ongoing |
ADCC_ISR()
void ADCC_ISR (void )
This routine is used to implement the ISR for the interrupt-driven implementations.
none |
none |
ADCC_LoadAcquisitionRegister()
void ADCC_LoadAcquisitionRegister (uint16_t acquisitionValue)
This API is used to load ADC Acquisition Time Control register with specified value.
acquisitionValue |
- Value to be loaded in the acquisition time control register. |
none |
ADCC_SetADIInterruptHandler()
void ADCC_SetADIInterruptHandler (void(*)(void) InterruptHandler)
This routine is used to set the callback for the ADI Interrupt.
Callback |
Function to be called |
none |
ADCC_SetADTIInterruptHandler()
void ADCC_SetADTIInterruptHandler (void(*)(void) InterruptHandler)
This routine is used to set the callback for the ADTI Interrupt.
Callback |
Function to be called |
none |
ADCC_SetLowerThreshold()
void ADCC_SetLowerThreshold (int16_t lowerThreshold)
This API used to set value of ADC Lower Threshold register.
lowerThreshold |
- 16-bit value for lower threshold. |
none |
ADCC_SetPrechargeTime()
void ADCC_SetPrechargeTime (uint16_t prechargeTime)
This API is used to load ADC Precharge Time Control register with specified value.
prechargeTime |
- Value to be loaded in the precharge time control register. |
none |
ADCC_SetRepeatCount()
void ADCC_SetRepeatCount (uint8_t repeatCount)
This API is used to load repeat counter with specified value.
repeatCount |
- Value to be loaded to repeat counter. |
none |
ADCC_SetStopOnInterrupt()
void ADCC_SetStopOnInterrupt (void )[inline]
This API is used enable Stop On Interrupt bit.
ADCC_EnableContinuousConversion function should have been called before calling this function. |
none |
none |
ADCC_SetUpperThreshold()
void ADCC_SetUpperThreshold (int16_t upperThreshold)
This API used to set value of ADC Upper Threshold register.
upperThreshold |
- 16-bit value for upper threshold. |
none |
ADCC_StartConversion()
void ADCC_StartConversion (adcc_posChannel_t posChannel, adcc_negChannel_t negChannel)
This API starts A/D conversion on selected channel.
posChannel |
- Positive Analog channel number on which A/D conversion has to be applied. Refer adcc_posChannel_t for available list of positive channels negChannel - Negative Analog channel number on which A/D conversion has to be applied. Refer adcc_ngChannel_t for available list of negative channels |
none |
ADCC_StopConversion()
void ADCC_StopConversion (void )[inline]
This API is used to stop ongoing A/D conversion.
ADCC_StartConversion function should have been called before calling this function. |
none |
none |
ADCC_ThresholdISR()
void ADCC_ThresholdISR (void )
This routine is used to implement the Threshold ISR for the interrupt-driven implementations.
none |
none |
Enumeration Type Documentation
adcc_negChannel_t
enum adcc_negChannel_t
This enumeration contains available ADC negative channels.
nChannel_VSS | |
nChannel_Temp | |
nChannel_DAC1OUT | |
nChannel_DAC2OUT | |
nChannel_FVR_Buffer1 | |
nChannel_FVR_Buffer2 |
adcc_posChannel_t
enum adcc_posChannel_t
This enumeration contains available ADC positive channels.
pChannel_ADCG1 | |
pChannel_VSS | |
pChannel_Temp | |
pChannel_DAC1OUT | |
pChannel_DAC2OUT | |
pChannel_FVR_Buffer1 | |
pChannel_FVR_Buffer2 |
4.1.2.4.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_posChannel_t posChannel, adcc_negChannel_t negChannel)
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_posChannel_t posChannel, adcc_negChannel_t negChannel)
This API is used to retrieve the result of single A/D conversion on given channels in differential mode..
void ADCC_StopConversion (void)
This API is used to stop ongoing A/D conversion.
void ADCC_SetStopOnInterrupt (void)
This API is used enable Stop On Interrupt bit.
void ADCC_DischargeSampleCapacitor (void)
This API is used to discharge input sample capacitor by setting the channel to AVss.
void ADCC_LoadAcquisitionRegister (uint16_t acquisitionValue)
This API is used to load ADC Acquisition Time Control register with specified value.
void ADCC_SetPrechargeTime (uint16_t prechargeTime)
This API is used to load ADC Precharge Time Control register with specified value.
void ADCC_SetRepeatCount (uint8_t repeatCount)
This API is used to load repeat counter 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.
int24_t ADCC_GetAccumulatorValue (void)
This API retrieves 18-bit value of ADC accumulator.
void ADCC_DefineSetPoint (int16_t setPoint)
This API used to set value of ADC Threshold Set-point.
int16_t ADCC_GetErrorCalculation (void)
This API retrieves the value of ADC Set-point Error register.
void ADCC_SetUpperThreshold (int16_t upperThreshold)
This API used to set value of ADC Upper Threshold register.
void ADCC_SetLowerThreshold (int16_t lowerThreshold)
This API used to set value of ADC Lower Threshold register.
int16_t ADCC_GetFilterValue (void)
This API retrieves the value of ADC Filter register.
int16_t ADCC_GetPreviousResult (void)
This API retrieves the value of ADC Previous register.
bool ADCC_HasAccumulatorOverflowed (void)
This API is used to determine whether ADC accumulator has overflowed.
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 Threshold 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
Function Documentation
ADCC_DefaultADI_ISR()
static void ADCC_DefaultADI_ISR (void )[static]
ADCC_DefaultADTI_ISR()
static void ADCC_DefaultADTI_ISR (void )[static]
Variable Documentation
ADCC_ADI_InterruptHandler
void(* ADCC_ADI_InterruptHandler) (void)[static]
Section: Included Files
ADCC_ADTI_InterruptHandler
void(* ADCC_ADTI_InterruptHandler) (void)[static]
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_posChannel_t posChannel, adcc_negChannel_t negChannel)
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_posChannel_t posChannel, adcc_negChannel_t negChannel)
This API is used to retrieve the result of single A/D conversion on given channels in differential mode..
void ADCC_StopConversion (void)
This API is used to stop ongoing A/D conversion.
void ADCC_SetStopOnInterrupt (void)
This API is used enable Stop On Interrupt bit.
void ADCC_DischargeSampleCapacitor (void)
This API is used to discharge input sample capacitor by setting the channel to AVss.
void ADCC_LoadAcquisitionRegister (uint16_t acquisitionValue)
This API is used to load ADC Acquisition Time Control register with specified value.
void ADCC_SetPrechargeTime (uint16_t prechargeTime)
This API is used to load ADC Precharge Time Control register with specified value.
void ADCC_SetRepeatCount (uint8_t repeatCount)
This API is used to load repeat counter 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.
int24_t ADCC_GetAccumulatorValue (void)
This API retrieves 18-bit value of ADC accumulator.
bool ADCC_HasAccumulatorOverflowed (void)
This API is used to determine whether ADC accumulator has overflowed.
int16_t ADCC_GetFilterValue (void)
This API retrieves the value of ADC Filter register.
int16_t ADCC_GetPreviousResult (void)
This API retrieves the value of ADC Previous register.
void ADCC_DefineSetPoint (int16_t setPoint)
This API used to set value of ADC Threshold Set-point.
void ADCC_SetUpperThreshold (int16_t upperThreshold)
This API used to set value of ADC Upper Threshold register.
void ADCC_SetLowerThreshold (int16_t lowerThreshold)
This API used to set value of ADC Lower Threshold register.
int16_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 Threshold ISR for the interrupt-driven implementations.
Typedefs
typedef int16_t adc_result_t
This typedef should be used for result of A/D conversion.
typedef __int24 int24_t
Enumerations
enum adcc_posChannel_t { pChannel_ADCG1 = 0x23, pChannel_VSS = 0x3a, pChannel_Temp = 0x3b, pChannel_DAC1OUT = 0x3c, pChannel_DAC2OUT = 0x3d, pChannel_FVR_Buffer1 = 0x3e, pChannel_FVR_Buffer2 = 0x3f }
This enumeration contains available ADC positive channels.
enum adcc_negChannel_t { nChannel_VSS = 0x3a, nChannel_Temp = 0x3b, nChannel_DAC1OUT = 0x3c, nChannel_DAC2OUT = 0x3d, nChannel_FVR_Buffer1 = 0x3e, nChannel_FVR_Buffer2 = 0x3f }
This enumeration contains available ADC negative channels.
Detailed Description
ADCC Generated Driver API Header File
Typedef Documentation
int24_t
typedef __int24 int24_t