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.

Version: ADCC Driver Version 1.0.1
Typedefs
  • typedef int16_t adc_result_t

    This typedef should be used for result of A/D conversion.

Enumerations
Functions

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.

Parameters:
none
Returns:

none

ADCC_DefineSetPoint()

void ADCC_DefineSetPoint (int16_t setPoint)

This API used to set value of ADC Threshold Set-point.

Parameters:
setPoint

- 16-bit value for set point.

Returns:

none

ADCC_DisableContinuousConversion()

void ADCC_DisableContinuousConversion (void )[inline]

This API disables continuous conversion.

Parameters:
none
Returns:

none

ADCC_DischargeSampleCapacitor()

void ADCC_DischargeSampleCapacitor (void )[inline]

This API is used to discharge input sample capacitor by setting the channel to AVss.

Parameters:
none
Returns:

none

ADCC_EnableContinuousConversion()

void ADCC_EnableContinuousConversion (void )[inline]

This API enables continuous conversion.

Parameters:
none
Returns:

none

ADCC_EnableDoubleSampling()

void ADCC_EnableDoubleSampling (void )[inline]

This API enables double-sampling bit.

Parameters:
none
Returns:

none

ADCC_GetAccumulatorValue()

int24_t ADCC_GetAccumulatorValue (void )

This API retrieves 18-bit value of ADC accumulator.

Parameters:
none
Returns:

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.

Precondition:

ADCC_StartConversion function should be called before calling this function and completion status should be checked using ADCC_IsConversionDone function.

Parameters:
none
Returns:

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.

Precondition:

ADCC_StartConversion function should be called before calling this function.

Parameters:
none
Returns:

Contents of ADC STATUS register.

ADCC_GetCurrentCountofConversions()

uint8_t ADCC_GetCurrentCountofConversions (void )

This API retrieves the current value of ADC Repeat Count register.

Precondition:

ADCC_StartConversion function should be called before calling this function.

Parameters:
none
Returns:

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.

Precondition:

ADCC_StartConversion function should be called before calling this function.

Parameters:
none
Returns:

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.

Parameters:
none
Returns:

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.

Precondition:

ADCC_StartConversion function should be called before calling this function.

Parameters:
none
Returns:

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..

Precondition:

ADCC_DisableContinuousConversion function should have been called before calling this function

Parameters:
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

Returns:

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.

Precondition:

ADCC_StartConversion function should be called before calling this function.

Parameters:
none
Return values:
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.

Precondition:

ADCC_StartConversion function should be called before calling this function.

Parameters:
none
Return values:
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.

Precondition:

ADCC_StartConversion function should be called before calling this function.

Parameters:
none
Return values:
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

Parameters:
none
Returns:

none

Section: ADCC Module APIs

ADCC_IsConversionDone()

bool ADCC_IsConversionDone (void )

This API checks if ongoing A/D conversion is complete.

Precondition:

ADCC_StartConversion function should be called before calling this function.

Parameters:
none
Return values:
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.

Parameters:
none
Returns:

none

ADCC_LoadAcquisitionRegister()

void ADCC_LoadAcquisitionRegister (uint16_t acquisitionValue)

This API is used to load ADC Acquisition Time Control register with specified value.

Parameters:
acquisitionValue

- Value to be loaded in the acquisition time control register.

Returns:

none

ADCC_SetADIInterruptHandler()

void ADCC_SetADIInterruptHandler (void(*)(void) InterruptHandler)

This routine is used to set the callback for the ADI Interrupt.

Parameters:
Callback

Function to be called

Returns:

none

ADCC_SetADTIInterruptHandler()

void ADCC_SetADTIInterruptHandler (void(*)(void) InterruptHandler)

This routine is used to set the callback for the ADTI Interrupt.

Parameters:
Callback

Function to be called

Returns:

none

ADCC_SetLowerThreshold()

void ADCC_SetLowerThreshold (int16_t lowerThreshold)

This API used to set value of ADC Lower Threshold register.

Parameters:
lowerThreshold

- 16-bit value for lower threshold.

Returns:

none

ADCC_SetPrechargeTime()

void ADCC_SetPrechargeTime (uint16_t prechargeTime)

This API is used to load ADC Precharge Time Control register with specified value.

Parameters:
prechargeTime

- Value to be loaded in the precharge time control register.

Returns:

none

ADCC_SetRepeatCount()

void ADCC_SetRepeatCount (uint8_t repeatCount)

This API is used to load repeat counter with specified value.

Parameters:
repeatCount

- Value to be loaded to repeat counter.

Returns:

none

ADCC_SetStopOnInterrupt()

void ADCC_SetStopOnInterrupt (void )[inline]

This API is used enable Stop On Interrupt bit.

Precondition:

ADCC_EnableContinuousConversion function should have been called before calling this function.

Parameters:
none
Returns:

none

ADCC_SetUpperThreshold()

void ADCC_SetUpperThreshold (int16_t upperThreshold)

This API used to set value of ADC Upper Threshold register.

Parameters:
upperThreshold

- 16-bit value for upper threshold.

Returns:

none

ADCC_StartConversion()

void ADCC_StartConversion (adcc_posChannel_t posChannel, adcc_negChannel_t negChannel)

This API starts A/D conversion on selected channel.

Parameters:
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

Returns:

none

ADCC_StopConversion()

void ADCC_StopConversion (void )[inline]

This API is used to stop ongoing A/D conversion.

Precondition:

ADCC_StartConversion function should have been called before calling this function.

Parameters:
none
Returns:

none

ADCC_ThresholdISR()

void ADCC_ThresholdISR (void )

This routine is used to implement the Threshold ISR for the interrupt-driven implementations.

Parameters:
none
Returns:

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

Detailed Description

This is the generated driver implementation file for the ADCC driver.

ADCC Generated Driver File

Version: ADCC Driver Version 1.0.1

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

Typedefs

  • typedef int16_t adc_result_t

    This typedef should be used for result of A/D conversion.

  • typedef __int24 int24_t

Enumerations

Detailed Description

ADCC Generated Driver API Header File

Typedef Documentation

int24_t

typedef __int24 int24_t