4.2.1 10-bit ADC

10-bit Analog-to-Digital Converter

4.2.1.1 Introduction

This Analog-to-Digital Converter (ADC) features a 10-bit successive approximation. The device also supports 16 differential voltage input combinations. Two of the differential inputs (ADC1, ADC0 and ADC3, ADC2) are equipped with a programmable gain stage. This provides amplification steps of 0 dB (1x), 20 dB (10x), or 46 dB (200x) on the differential input voltage before the A/D conversion. Seven differential analog input channels share a common negative terminal (ADC1), while any other ADC input can be selected as the positive input terminal. If 1x or 10x gain is used, 8-bit resolution can be expected. If 200x gain is used, 6- bit resolution can be expected. Note that internal references of 1.1V should not be used on 10x and 200x gain.

4.2.1.2 Supported Device Families

ATmega32xx

4.2.1.3 Required header files:

#include "mcc_generated_files/adc/adc[X].h"
Note: Replace [X] with the selected instance of the ADC module.

4.2.1.4 Module Documentation

4.2.1.4.1 ADC

This file contains the API prototypes and other data types for the Analog-to-Digital Converter (ADC) module.

Module description

This file contains the API prototypes and other data types for the Analog-to-Digital Converter (ADC) module.

Version: ADC Driver Version 1.0.0
Typedefs
  • typedef void(* adc_irq_cb_t) (void)

    Function pointer to the callback function called by the IRQ when operating in Normal mode. The default value is set to NULL, which means that no callback function will be used.

  • typedef uint16_t adc_result_t

    Data type for the result of the Analog-to-Digital Conversion (ADC).

  • typedef uint8_t adc_0_channel_t

    Data type for the ADC Input Selection.

Functions

Typedef Documentation

adc_0_channel_t

uint8_t adc_0_channel_t

Data type for the ADC Input Selection.

adc_irq_cb_t

void adc_irq_cb_t

Function pointer to the callback function called by the IRQ when operating in Normal mode. The default value is set to NULL, which means that no callback function will be used.

adc_result_t

uint16_t adc_result_t

Data type for the result of the Analog-to-Digital Conversion (ADC).

Function Documentation

ADC_DigitalInputDisable()

void ADC_DigitalInputDisable (uint8_t DisableValue)

Disables Register 0 for ADC digital input.

Parameters:
uint8_t

DisableValue - Value for the disabled digital input.

Returns:

None.

ADC_Disable()

void ADC_Disable (void )

Disables the ADC module and the clock by clearing the Enable bit in the ADC Control register.

Parameters:
None.
Returns:

None.

ADC_Enable()

void ADC_Enable (void )

Enables the ADC module and the clock system by setting the Enable bit in the ADC Control register.

Parameters:
None.
Returns:

None.

ADC_GetConversion()

adc_result_t ADC_GetConversion (adc_0_channel_t channel)

Starts a conversion and returns the result.

Parameters:
adc_0_channel_t

channel - The ADC channel to get the result of the conversion.

Returns:

adc_result_t - The result of the conversion read from the ADC module.

ADC_GetConversionResult()

adc_result_t ADC_GetConversionResult (void )

Reads the result of the A/D conversion.

Parameters:
None.
Returns:

adc_result_t - The result of the conversion read from the ADC module

ADC_GetResolution()

uint8_t ADC_GetResolution (void )

Returns the number of bits from the result of the conversion.

Parameters:
None.
Returns:

uint8_t - The number of bits in the result of the conversion.

ADC_Initialize()

int8_t ADC_Initialize (void )

Initializes the ADC interface. If the module is configured to the Disabled state, the clock is also disabled.

Parameters:
None.
Return values:
0

- The ADC initialization is successful.

1

- The ADC initialization is not successful.

Initializes the ADC interface. If the module is configured to the Disabled state, the clock is also disabled.

ADC_IsConversionDone()

bool ADC_IsConversionDone (void )

Checks if the A/D conversion is done.

Parameters:
channel

- None.

Return values:
true

- The ADC conversion is done.

false

- The ADC converison is not done.

ADC_RegisterCallback()

void ADC_RegisterCallback (adc_irq_cb_t callback)

Registers a callback function which is called if the conversion satisfies the window criteria.

Parameters:
adc_irq_cb_t

callback - Pointer to the function callback.

Returns:

None.

ADC_StartConversion()

void ADC_StartConversion (adc_0_channel_t channel)

Starts an Analog-to-Digital (A/D) conversion.

Parameters:
adc_0_channel_t

channel - The ADC channel to start a conversion on.

Returns:

None.

4.2.1.5 File Documentation

4.2.1.5.1 source/adc.c File Reference

This file contains the driver code for the ADC module.

#include <avr/io.h>
#include "../adc.h"

Functions

Detailed Description

This file contains the driver code for the ADC module.

ADC Generated Driver File

Version: ADC Driver Version 1.0.0

Variable Documentation

ADC_cb

adc_irq_cb_t ADC_cb = NULL

Section: Included FilesFunction pointer to the callback function called by the IRQ when operating in Normal mode. The default value is set to NULL, which means that no callback function will be used.

4.2.1.5.2 source/adc.h File Reference

#include "../system/utils/compiler.h"

Functions

Typedefs

  • typedef void(* adc_irq_cb_t) (void)

    Function pointer to the callback function called by the IRQ when operating in Normal mode. The default value is set to NULL, which means that no callback function will be used.

  • typedef uint16_t adc_result_t

    Data type for the result of the Analog-to-Digital Conversion (ADC).

  • typedef uint8_t adc_0_channel_t

    Data type for the ADC Input Selection.

Detailed Description

ADC Generated Driver API Header File