3.1.1.4 12-bit ADC

12-bit Analog-to-Digital Converter

3.1.1.4.1 Introduction

This Analog-to-Digital Converter (ADC) allows conversion of single-ended and differential analog input signals to a 12-bit binary representation of that signal. The analog inputs are multiplexed into a single Sample-and-Hold circuit. The converter then generates a 12-bit binary result via successive approximation and stores the conversion result into the ADC result registers.

3.1.1.4.2 Supported Device Families

PIC16(L)F178x

3.1.1.4.3 Required Header Files:

#include "mcc_generated_files/adc/adc.h"

3.1.1.4.4 Module Documentation

ADC

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

Module description

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

Version: ADC Driver Version 1.0.0
Typedefs
  • typedef uint16_t adc_result_t

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

Definitions
Functions

Definition Documentation

ADC_GetConversion

#define ADC_GetConversion ADC_GetConversion

Defines the Custom Name for the ADC_GetConversion API.

ADC_GetConversionResult

#define ADC_GetConversionResult ADC_GetConversionResult

Defines the Custom Name for the ADC_GetConversionResult API.

ADC_Initialize

#define ADC_Initialize ADC_Initialize

Defines the Custom Name for the ADC_Initialize API.

ADC_IsConversionDone

#define ADC_IsConversionDone ADC_IsConversionDone

Defines the Custom Name for the ADC_IsConversionDone API.

ADC_ISR

#define ADC_ISR ADC_ISR

Defines the Custom Name for the ADC_ISR API.

ADC_SetInterruptHandler

#define ADC_SetInterruptHandler ADC_SetInterruptHandler

Defines the Custom Name for the ADC_SetInterruptHandler API.

ADC_SetNegativeChannel

#define ADC_SetNegativeChannel ADC_SetNegativeChannel

Defines the Custom Name for the ADC_SetNegativeChannel API.

ADC_SetPositiveChannel

#define ADC_SetPositiveChannel ADC_SetPositiveChannel

Defines the Custom Name for the ADC_SetPositiveChannel API.

ADC_StartConversion

#define ADC_StartConversion ADC_StartConversion

Defines the Custom Name for the ADC_StartConversion API.

ADC_TemperatureAcquisitionDelay

#define ADC_TemperatureAcquisitionDelay ADC_TemperatureAcquisitionDelay

Defines the Custom Name for the ADC_TemperatureAcquisitionDelay API.

Typedef Documentation

adc_result_t

adc_result_t

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

Function Documentation

ADC_GetConversion()

adc_result_t ADC_GetConversion (adc_posChannel_t posChannel, adc_negChannel_t negChannel)

Retrieves the result of a single A/D conversion on the selected channels.

Parameters:
posChannel

- Postive analog channel number on which the A/D conversion will be applied. Refer to adc_posChannel_t for the available channels.

negChannel

- Negative analog channel number on which the A/D conversion will be applied. Refer to adc_negChannel_t for the available channels.

Returns:

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

ADC_GetConversionResult()

adc_result_t ADC_GetConversionResult (void )

Retrieves the result of the latest A/D conversion.

Parameters:
None.
Returns:

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

ADC_Initialize()

void ADC_Initialize (void )

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

Parameters:
None.
Returns:

None.

ADC_IsConversionDone()

bool ADC_IsConversionDone (void )

Checks if the A/D conversion is complete.

Parameters:
None.
Return values:
True

- A/D conversion is complete

False

- A/D conversion is ongoing

ADC_ISR()

void ADC_ISR (void )

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

Parameters:
None.
Returns:

None.

ADC_SetInterruptHandler()

void ADC_SetInterruptHandler (void(*)(void) InterruptHandler)

Sets the callback for the ADC Interrupt (ADI).

Parameters:
InterruptHandler

- Callback function to be called on the interrupt event

Returns:

None.

ADC_SetNegativeChannel()

void ADC_SetNegativeChannel (adc_negChannel_t channel)

Sets the negative channel for the A/D conversion.

Parameters:
channel

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

Returns:

None.

ADC_SetPositiveChannel()

void ADC_SetPositiveChannel (adc_posChannel_t channel)

Sets the positive channel for the A/D conversion.

Parameters:
channel

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

Returns:

None.

ADC_StartConversion()

void ADC_StartConversion (void )

Starts the A/D conversion.

Parameters:
None.
Returns:

None.

ADC_TemperatureAcquisitionDelay()

void ADC_TemperatureAcquisitionDelay (void )

Adds the acquisition delay for the temperature sensor.

Precondition:

Call this function when using the temperature sensor.

Parameters:
None.
Returns:

None.

Enumeration Type Documentation

adc_negChannel_t

enum adc_negChannel_t

Contains the available negative ADC channels.

negChannel_ADNREF
negChannel_AN0
negChannel_AN1
negChannel_AN2
adc_posChannel_t

enum adc_posChannel_t

Contains the available positive ADC channels.

posChannel_DAC4
posChannel_DAC3
posChannel_DAC2
posChannel_Temperature
posChannel_DAC1
posChannel_FVR
posChannel_AN0
posChannel_AN1
posChannel_AN2

3.1.1.4.5 Class Documentation

adc_sync_double_result_t Struct Reference

#include <adc.h>

Member Data Documentation

The documentation for this struct was generated from the following file:

source/

adc.h

adcResult1

adc_result_t adcResult1

adcResult2

adc_result_t adcResult2

Used Struct Reference

Detailed Description

result for a Double ADC conversion value.

The documentation for this struct was generated from the following file:

source/

adc.h

3.1.1.4.6 File Documentation

source/adc.c File Reference

This file contains the API implementations for the ADC module.

#include <xc.h>
#include "../adc.h"
#include "../../system/clock.h"

Functions

Detailed Description

This file contains the API implementations for the ADC module.

ADC Generated Driver File

Version: ADC Driver Version 1.0.0

Function Documentation

ADC_DefaultInterruptHandler()

static void ADC_DefaultInterruptHandler (void )[static]

Macro Definition Documentation

ACQ_US_DELAY

#define ACQ_US_DELAY 5

Variable Documentation

ADC_InterruptHandler

void(* ADC_InterruptHandler) (void)[static]

source/adc.h File Reference

#include <xc.h>
#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.