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

ADCC Driver Version 2.1.4
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

Typedef Documentation

adc_result_t

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.

Parameters:
none
Returns:

none

ADCC_DefineSetPoint()

void ADCC_DefineSetPoint (uint16_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 )

This API disables continuous conversion.

Parameters:
none
Returns:

none

ADCC_DischargeSampleCapacitor()

void ADCC_DischargeSampleCapacitor (void )

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 )

This API enables continuous conversion.

Parameters:
none
Returns:

none

ADCC_EnableDoubleSampling()

void ADCC_EnableDoubleSampling (void )

This API enables double-sampling bit.

Parameters:
none
Returns:

none

ADCC_GetAccumulatorValue()

uint16_t ADCC_GetAccumulatorValue (void )

This API retrieves 17-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() should be called before calling this function and completion status should be checked using ADCC_IsConversionDone() routine.

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() 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() should be called before calling this function.

Parameters:
none
Returns:

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.

Precondition:

ADCC_StartConversion() should be called before calling this function.

Parameters:
none
Returns:

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.

Parameters:
none
Returns:

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.

Precondition:

ADCC_StartConversion() 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_channel_t channel)

This API is used to retrieve the result of single A/D conversion on given channel.

Precondition:

ADCC_DisableContinuousConversion() function should have been called before calling this function

Parameters:
channel

- Analog channel number on which A/D conversion has to be applied. Refer adcc_channel_t for available 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() 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() 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() 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() 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 (uint8_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 (uint16_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 (uint8_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_SetStopOnInterrupt()

void ADCC_SetStopOnInterrupt (void )

Stops the ADCC from re-triggering A/D conversion cycle upon completion of each conversion.

Precondition:

ADCC_EnableContinuousConversion() function should have been called before calling this function.

Parameters:
none
Returns:

none

ADCC_SetUpperThreshold()

void ADCC_SetUpperThreshold (uint16_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_channel_t channel)

This API starts A/D conversion on selected channel.

Parameters:
channel

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

Returns:

none

ADCC_StopConversion()

void ADCC_StopConversion (void )

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 ISR for the interrupt-driven implementations.

Parameters:
none
Returns:

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

Detailed Description

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

ADCC Generated Driver File

Version: ADCC Driver Version 2.1.4

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

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