4.1.1.1 10-bit ADC

10-bit Analog-to-Digital Converter

4.1.1.1.1 Introduction

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

4.1.1.1.2 Supported Device Families

PIC18F-K20 PIC18(L)F-K22 PIC18(L)F-K50

4.1.1.1.3 Required Header Files:

#include "mcc_generated_files/adc/adc.h"

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

Functions

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

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

Parameters:
channel

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

Returns:

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

ADC_GetConversion() with Negative Channel

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

Parameters:
None.
Returns:

None.

ADC_IsConversionDone()

bool ADC_IsConversionDone (void )

Checks if ongoing A/D conversion is complete.

Parameters:
None.
Return values:
True

- A/D conversion is complete.

False

- A/D conversion is ongoing.

ADC_SelectChannel()

void ADC_SelectChannel (adc_channel_t channel)

Selects the channel for the A/D conversion.

Parameters:
channel

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

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 A/D conversion.

Parameters:
None.
Returns:

None.

ADC_TemperatureAcquisitionDelay()

void ADC_TemperatureAcquisitionDelay (void )

Adds the acquisition delay for the temperature sensor.

Precondition:

This function is called when temperature sensor is used.

Parameters:
None.
Returns:

None.

Enumeration Type Documentation

adc_channel_t

enum adc_channel_t

Contains the available ADC channels.

posChannel_FVR
adc_negChannel_t

enum adc_negChannel_t

Contains the available negative ADC channels.

negChannel_AVss
adc_posChannel_t

enum adc_posChannel_t

Contains the available ADC channels.

posChannel_CTMU
posChannel_Temp_diode
posChannel_Vdd_core
posChannel_1_024V_bandgap

4.1.1.1.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 files:

source/

adc.h

source/

adc_wNegChannel.h

adcResult1

adc_result_t adcResult1

adcResult2

adc_result_t adcResult2

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

Macro Definition Documentation

ACQ_US_DELAY

#define ACQ_US_DELAY 8

Section: Included Files Section: Macro Declarations

source/adc.h File Reference

#include <xc.h>
#include <stdint.h>
#include <stdbool.h>

Functions

Typedefs

  • typedef uint16_t adc_result_t

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

Detailed Description

ADC Generated Driver API Header File

source/adc_wNegChannel.c File Reference

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

Functions

Macro Definition Documentation

ACQ_US_DELAY

#define ACQ_US_DELAY 8

Section: Included Files Section: Macro Declarations

source/adc_wNegChannel.h File Reference

#include <xc.h>
#include <stdint.h>
#include <stdbool.h>

Functions

Typedef Documentation

adc_result_t

typedef uint16_t adc_result_t