4.1.2.2 10-bit ADCC with Ch. Group Sel.

10-bit ADC with Computation and Channel Group Selection

4.1.2.2.1 Introduction

The Analog-to-Digital Converter with Computation (ADCC) peripheral converts both single-ended and differential analog input signals to a 10-bit binary representation of that signal. This peripheral takes in analog signals and combines them into a Sample-and-Hold (S/H) circuit. It is then fed to a converter to turn this measurement into a 10-digit binary number and is stored in the ADC result registers. This ADCC also supports Channel Grouping which allows multiple, simultaneous input connections to the ADC.

4.1.2.2.2 Supported Device Families

PIC16F180xx PIC18F-Q20

4.1.2.2.3 Required header files:


#include "mcc_generated_files/adcc/adcc.h"

4.1.2.2.4 Module Documentation

ADCC

This file contains the API prototypes and data types for the ADCC driver.

Module description

This file contains the API prototypes and data types for the ADCC driver.

Version: ADCC Driver Version 1.0.2
Typedefs
  • typedef uint16_t adc_result_t

    Used for the result of the Analog-to-Digital (A/D) conversion.

Definitions
Functions

Definition Documentation

ADCC_ClearAccumulator

#define ADCC_ClearAccumulator ADCC_ClearAccumulator

Defines the Custom Name for the ADCC_ClearAccumulator API.

ADCC_DefineSetPoint

#define ADCC_DefineSetPoint ADCC_DefineSetPoint

Defines the Custom Name for the ADCC_DefineSetPoint API.

ADCC_DisableContinuousConversion

#define ADCC_DisableContinuousConversion ADCC_DisableContinuousConversion

Defines the Custom Name for the ADCC_DisableContinuousConversion API.

ADCC_DischargeSampleCapacitor

#define ADCC_DischargeSampleCapacitor ADCC_DischargeSampleCapacitor

Defines the Custom Name for the ADCC_DischargeSampleCapacitor API.

ADCC_EnableContinuousConversion

#define ADCC_EnableContinuousConversion ADCC_EnableContinuousConversion

Defines the Custom Name for the ADCC_EnableContinuousConversion API.

ADCC_EnableDoubleSampling

#define ADCC_EnableDoubleSampling ADCC_EnableDoubleSampling

Defines the Custom Name for the ADCC_EnableDoubleSampling API.

ADCC_GetAccumulatorValue

#define ADCC_GetAccumulatorValue ADCC_GetAccumulatorValue

Defines the Custom Name for the ADCC_GetAccumulatorValue API.

ADCC_GetConversionResult

#define ADCC_GetConversionResult ADCC_GetConversionResult

Defines the Custom Name for the ADCC_GetConversionResult API.

ADCC_GetConversionStageStatus

#define ADCC_GetConversionStageStatus ADCC_GetConversionStageStatus

Defines the Custom Name for the ADCC_GetConversionStageStatus API.

ADCC_GetCurrentCountofConversions

#define ADCC_GetCurrentCountofConversions ADCC_GetCurrentCountofConversions

Defines the Custom Name for the ADCC_GetCurrentCountofConversions API.

ADCC_GetErrorCalculation

#define ADCC_GetErrorCalculation ADCC_GetErrorCalculation

Defines the Custom Name for the ADCC_GetErrorCalculation API.

ADCC_GetFilterValue

#define ADCC_GetFilterValue ADCC_GetFilterValue

Defines the Custom Name for the ADCC_GetFilterValue API.

ADCC_GetPreviousResult

#define ADCC_GetPreviousResult ADCC_GetPreviousResult

Defines the Custom Name for the ADCC_GetPreviousResult API.

ADCC_GetSingleConversion

#define ADCC_GetSingleConversion ADCC_GetSingleConversion

Defines the Custom Name for the ADCC_GetSingleConversion API.

ADCC_HasAccumulatorOverflowed

#define ADCC_HasAccumulatorOverflowed ADCC_HasAccumulatorOverflowed

Defines the Custom Name for the ADCC_HasAccumulatorOverflowed API.

ADCC_HasErrorCrossedLowerThreshold

#define ADCC_HasErrorCrossedLowerThreshold ADCC_HasErrorCrossedLowerThreshold

Defines the Custom Name for the ADCC_HasErrorCrossedLowerThreshold API.

ADCC_HasErrorCrossedUpperThreshold

#define ADCC_HasErrorCrossedUpperThreshold ADCC_HasErrorCrossedUpperThreshold

Defines the Custom Name for the ADCC_HasErrorCrossedUpperThreshold API.

ADCC_Initialize

#define ADCC_Initialize ADCC_Initialize

Defines the Custom Name for the ADCC_Initialize API.

Section: Included Files

ADCC_IsConversionDone

#define ADCC_IsConversionDone ADCC_IsConversionDone

Defines the Custom Name for the ADCC_IsConversionDone API.

ADCC_LoadAcquisitionRegister

#define ADCC_LoadAcquisitionRegister ADCC_LoadAcquisitionRegister

Defines the Custom Name for the ADCC_LoadAcquisitionRegister API.

ADCC_SetADIInterruptHandler

#define ADCC_SetADIInterruptHandler ADCC_SetADIInterruptHandler

Defines the Custom Name for the ADCC_SetADIInterruptHandler API.

ADCC_SetADTIInterruptHandler

#define ADCC_SetADTIInterruptHandler ADCC_SetADTIInterruptHandler

Defines the Custom Name for the ADCC_SetADTIInterruptHandler API.

ADCC_SetLowerThreshold

#define ADCC_SetLowerThreshold ADCC_SetLowerThreshold

Defines the Custom Name for the ADCC_SetLowerThreshold API.

ADCC_SetPrechargeTime

#define ADCC_SetPrechargeTime ADCC_SetPrechargeTime

Defines the Custom Name for the ADCC_SetPrechargeTime API.

ADCC_SetRepeatCount

#define ADCC_SetRepeatCount ADCC_SetRepeatCount

Defines the Custom Name for the ADCC_SetRepeatCount API.

ADCC_SetStopOnInterrupt

#define ADCC_SetStopOnInterrupt ADCC_SetStopOnInterrupt

Defines the Custom Name for the ADCC_SetStopOnInterrupt API.

ADCC_SetUpperThreshold

#define ADCC_SetUpperThreshold ADCC_SetUpperThreshold

Defines the Custom Name for the ADCC_SetUpperThreshold API.

ADCC_StartConversion

#define ADCC_StartConversion ADCC_StartConversion

Defines the Custom Name for the ADCC_StartConversion API.

ADCC_StopConversion

#define ADCC_StopConversion ADCC_StopConversion

Defines the Custom Name for the ADCC_StopConversion API.

Typedef Documentation

adc_result_t

adc_result_t

Used for the result of the Analog-to-Digital (A/D) conversion.

Function Documentation

ADCC_ClearAccumulator()

void ADCC_ClearAccumulator (void )[inline]

Clears the accumulator.

Parameters:
None.
Returns:

None.

ADCC_DefineSetPoint()

void ADCC_DefineSetPoint (uint16_t setPoint)

Sets the value of the ADC Threshold Setpoint(ADSTPT) register.

Parameters:
setPoint

- 16-bit value for the ADC Threshold Setpoint register

Returns:

None.

ADCC_DisableContinuousConversion()

void ADCC_DisableContinuousConversion (void )[inline]

Disables continuous conversion.

Parameters:
None.
Returns:

None.

ADCC_DischargeSampleCapacitor()

void ADCC_DischargeSampleCapacitor (void )[inline]

Discharges the input sample capacitor by setting the channel to AVss.

Parameters:
None.
Returns:

None.

ADCC_EnableContinuousConversion()

void ADCC_EnableContinuousConversion (void )[inline]

Enables continuous conversion.

Parameters:
None.
Returns:

None.

ADCC_EnableDoubleSampling()

void ADCC_EnableDoubleSampling (void )[inline]

Enables double-sampling bit.

Parameters:
None.
Returns:

None.

ADCC_GetAccumulatorValue()

uint16_t ADCC_GetAccumulatorValue (void )

Retrieves the value of ADC accumulator.

Parameters:
None.
Returns:

Value of ADC accumulator

ADCC_GetConversionResult()

adc_result_t ADCC_GetConversionResult (void )

Retrieves the result of the latest A/D conversion.

Precondition:

ADCC_StartConversion() is called before calling this function and completion status is checked using the ADCC_IsConversionDone() routine.

Parameters:
None.
Returns:

The result of A/D conversion. Refer to the adc_result_t.

ADCC_GetConversionStageStatus()

uint8_t ADCC_GetConversionStageStatus (void )

Retrieves the multi-stage status.

Precondition:

ADCC_StartConversion() is called before calling this function.

Parameters:
None.
Returns:

Contents of ADC STATUS register

ADCC_GetCurrentCountofConversions()

uint8_t ADCC_GetCurrentCountofConversions (void )

Retrieves the current value of ADC Repeat Count register.

Precondition:

ADCC_StartConversion() is called before calling this function.

Parameters:
None.
Returns:

Current value of the ADC Repeat Count register

ADCC_GetErrorCalculation()

uint16_t ADCC_GetErrorCalculation (void )

Retrieves the value of ADC Set-point Error register.

Precondition:

ADCC_StartConversion() is called before calling this function.

Parameters:
None.
Returns:

16-bit value obtained from the high byte ADERR(ADERRH) and low byte ADERR(ADERRL) registers.

ADCC_GetFilterValue()

uint16_t ADCC_GetFilterValue (void )

Retrieves the value of the ADC Filter(ADFLTR) register.

Parameters:
None.
Returns:

16-bit value obtained from the high byte ADFLTR(ADFLTRH) and low byte ADFLTR(ADFLTRL) registers.

ADCC_GetPreviousResult()

uint16_t ADCC_GetPreviousResult (void )

Retrieves the value of the ADC Previous(ADPREV) register.

Precondition:

ADCC_StartConversion() is called before calling this function.

Parameters:
None.
Returns:

16-bit value obtained from the high byte ADPREV(ADPREVH) and low byte ADPREV(ADPREVL) registers.

ADCC_GetSingleConversion()

adc_result_t ADCC_GetSingleConversion (adcc_channel_t channel)

Retrieves the result of a single A/D conversion on any given channel.

Precondition:

Enable ADC using the ADCC_Initialize() function. Also ADCC_DisableContinuousConversion() function is called before calling this function.

Parameters:
channel

- Analog channel number on which the A/D conversion will be applied. Refer to adcc_channel_t for available channels

Returns:

The result of a single A/D conversion. Refer to the adc_result_t.

ADCC_HasAccumulatorOverflowed()

bool ADCC_HasAccumulatorOverflowed (void )

Determines whether ADC accumulator has overflowed.

Precondition:

ADCC_StartConversion() is 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 )

Determines if ADC error is less than the lower threshold.

Precondition:

ADCC_StartConversion() is called before calling this function.

Parameters:
None.
Return values:
True

- ADC error has crossed the lower threshold

False

- ADC error has not crossed the lower threshold

ADCC_HasErrorCrossedUpperThreshold()

bool ADCC_HasErrorCrossedUpperThreshold (void )

Determines if ADC error has crossed the upper threshold.

Precondition:

ADCC_StartConversion() is called before calling this function.

Parameters:
None.
Return values:
True

- ADC error has crossed the upper threshold

False

- ADC error has not crossed the upper threshold

ADCC_Initialize()

void ADCC_Initialize (void )

Initializes the ADC module. This routine is called before any other ADC routine.

Section: ADCC Module APIs

Parameters:
None.
Returns:

None.

Section: ADCC Module APIs

ADCC_IsConversionDone()

bool ADCC_IsConversionDone (void )

Checks if ongoing A/D conversion is complete.

Precondition:

ADCC_StartConversion() is called before calling this function.

Parameters:
None.
Return values:
True

- A/D conversion is complete.

False

- A/D conversion is ongoing.

ADCC_ISR()

void ADCC_ISR (void )

Implements the ADC Interrupt(ADI) service routine for the interrupt-driven implementations.

Parameters:
None.
Returns:

None.

ADCC_LoadAcquisitionRegister()

void ADCC_LoadAcquisitionRegister (uint16_t acquisitionValue)

Loads ADC Acquisition Time Control register with the specified value.

Parameters:
acquisitionValue

- Value to be loaded in the acquisition time control register

Returns:

None.

ADCC_SetADIInterruptHandler()

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

Sets the callback for the ADC Interrupt(ADI).

Parameters:
InterruptHandler

- Callback function to be called on the interrupt event

Returns:

None.

ADCC_SetADTIInterruptHandler()

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

Sets the callback for the ADC Threshold Interrupt(ADTI).

Parameters:
InterruptHandler

- Callback function to be called on the interrupt event

Returns:

None.

ADCC_SetLowerThreshold()

void ADCC_SetLowerThreshold (uint16_t lowerThreshold)

Sets the value of ADC Lower Threshold(ADLTH) register.

Parameters:
lowerThreshold

- 16-bit value for the ADC Lower Threshold register

Returns:

None.

ADCC_SetPrechargeTime()

void ADCC_SetPrechargeTime (uint16_t prechargeTime)

Loads ADC Precharge Time Control register with the specified value.

Parameters:
prechargeTime

- Value to be loaded in the precharge time control register

Returns:

None.

ADCC_SetRepeatCount()

void ADCC_SetRepeatCount (uint8_t repeatCount)

Loads the ADC Repeat Count register with specified value.

Parameters:
repeatCount

- Value to be loaded to repeat counter

Returns:

None.

ADCC_SetStopOnInterrupt()

void ADCC_SetStopOnInterrupt (void )[inline]

Enables Stop On Interrupt bit.

Precondition:

ADCC_EnableContinuousConversion() function is called before calling this function.

Parameters:
None.
Returns:

None.

ADCC_SetUpperThreshold()

void ADCC_SetUpperThreshold (uint16_t upperThreshold)

Sets the value of ADC Upper Threshold(ADUTH) register.

Parameters:
upperThreshold

- 16-bit value for the ADC Upper Threshold register

Returns:

None.

ADCC_StartConversion()

void ADCC_StartConversion (adcc_channel_t channel)

Starts A/D conversion on the selected channel.

Precondition:

ADCC_Initialize() function is called before calling this function to enable ADC.

Parameters:
channel

- Analog channel number on which the A/D conversion has to be applied. Refer to adcc_channel_t for the available list of channels.

Returns:

None.

ADCC_StopConversion()

void ADCC_StopConversion (void )[inline]

Stops the ongoing A/D conversion.

Precondition:

ADCC_StartConversion() function is called before calling this function.

Parameters:
None.
Returns:

None.

ADCC_ThresholdISR()

void ADCC_ThresholdISR (void )

Implements the ADC Threshold Interrupt(ADTI) service routine for the interrupt-driven implementations.

Parameters:
None.
Returns:

None.

Enumeration Type Documentation

adcc_channel_t

enum adcc_channel_t

Contains the available ADC channels.

channel_ADCG1
channel_FVR_Buffer1
channel_Temp
channel_VDDIO3_by_10
channel_VDDIO2_by_10
channel_VSS
channel_ANA0

4.1.2.2.5 File Documentation

source/adcc.c File Reference

This file contains the API implementations for the ADCC driver.

#include <xc.h>
#include "../adcc.h"

Functions

Detailed Description

This file contains the API implementations for the ADCC driver.

ADCC Generated Driver File

Version: ADCC Driver Version 1.0.2

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

Macros

Typedefs

  • typedef uint16_t adc_result_t

    Used for the result of the Analog-to-Digital (A/D) conversion.

Detailed Description

ADCC Generated Driver API Header File