4.2.1 Basic ADC
10-bit Basic 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"
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 data types for the ADC driver.
This header file provides the type definitions for the ADC module.
Typedefs
typedef int16_t adc_result_t
ADC conversion result type.
Definitions
#define IO_PA0 ADC_CHANNEL_ADC0
Defines the Custom Name pin mapping for channels in adc_channel_t.
#define CustomName_Initialize ADC_Initialize
Defines the Custom Name API mapping for ADC_Initialize.
#define CustomName_Deinitialize ADC_Deinitialize
Defines the Custom Name API mapping for ADC_Deinitialize.
#define CustomName_Enable ADC_Enable
Defines the Custom Name API mapping for ADC_Enable.
#define CustomName_Disable ADC_Disable
Defines the Custom Name API mapping for ADC_Disable.
#define CustomName_ConversionStart ADC_ConversionStart
Defines the Custom Name API mapping for ADC_ConversionStart.
#define CustomName_IsConversionDone ADC_IsConversionDone
Defines the Custom Name API mapping for ADC_IsConversionDone.
#define CustomName_ConversionResultGet ADC_ConversionResultGet
Defines the Custom Name API mapping for ADC_ConversionResultGet.
#define CustomName_ResolutionGet ADC_ResolutionGet
Defines the Custom Name API mapping for ADC_ResolutionGet.
#define CustomName_ConversionDoneCallbackRegister ADC_ConversionDoneCallbackRegister
Defines the Custom Name API mapping for ADC_ConversionDoneCallbackRegister.
#define CustomName_ChannelSelect ADC_ChannelSelect
Defines the Custom Name API mapping for ADC_ChannelSelect.
#define CustomName_ChannelSelectAndConvert ADC_ChannelSelectAndConvert
Defines the Custom Name API mapping for ADC_ChannelSelectAndConvert.
#define CustomName_ConversionDoneInterruptEnable ADC_ConversionDoneInterruptEnable
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptEnable.
#define CustomName_ConversionDoneInterruptDisable ADC_ConversionDoneInterruptDisable
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptDisable.
#define CustomName_AutoTriggerEnable ADC_AutoTriggerEnable
Defines the Custom Name API mapping for ADC_AutoTriggerEnable.
#define CustomName_AutoTriggerDisable ADC_AutoTriggerDisable
Defines the Custom Name API mapping for ADC_AutoTriggerDisable.
#define CustomName_AutoTriggerSourceSet ADC_AutoTriggerSourceSet
Defines the Custom Name API mapping for ADC_AutoTriggerSourceSet.
#define CustomName_IsConversionDoneInterruptFlagSet ADC_IsConversionDoneInterruptFlagSet
Defines the Custom Name API mapping for ADC_IsConversionDoneInterruptFlagSet.
#define CustomName_ConversionDoneInterruptFlagClear ADC_ConversionDoneInterruptFlagClear
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptFlagClear.
#define CustomName_DigitalInputDisable ADC_DigitalInputDisable
Defines the Custom Name API mapping for ADC_DigitalInputDisable.
#define ADC_RESOLUTION 10U
ADC 10-bit resolution value.
#define IO_PA0 ADC_CHANNEL_ADC0
Defines the Custom Name pin mapping for channels in adc_channel_t.
#define CustomName_Initialize ADC_Initialize
Defines the Custom Name API mapping for ADC_Initialize.
#define CustomName_Deinitialize ADC_Deinitialize
Defines the Custom Name API mapping for ADC_Deinitialize.
#define CustomName_Enable ADC_Enable
Defines the Custom Name API mapping for ADC_Enable.
#define CustomName_Disable ADC_Disable
Defines the Custom Name API mapping for ADC_Disable.
#define CustomName_ConversionStart ADC_ConversionStart
Defines the Custom Name API mapping for ADC_ConversionStart.
#define CustomName_IsConversionDone ADC_IsConversionDone
Defines the Custom Name API mapping for ADC_IsConversionDone.
#define CustomName_ConversionResultGet ADC_ConversionResultGet
Defines the Custom Name API mapping for ADC_ConversionResultGet.
#define CustomName_ResolutionGet ADC_ResolutionGet
Defines the Custom Name API mapping for ADC_ResolutionGet.
#define CustomName_ConversionDoneCallbackRegister ADC_ConversionDoneCallbackRegister
Defines the Custom Name API mapping for ADC_ConversionDoneCallbackRegister.
#define CustomName_ChannelSelect ADC_ChannelSelect
Defines the Custom Name API mapping for ADC_ChannelSelect.
#define CustomName_ChannelSelectAndConvert ADC_ChannelSelectAndConvert
Defines the Custom Name API mapping for ADC_ChannelSelectAndConvert.
#define CustomName_Tasks ADC_Tasks
Defines the Custom Name API mapping for ADC_Tasks.
#define CustomName_AutoTriggerEnable ADC_AutoTriggerEnable
Defines the Custom Name API mapping for ADC_AutoTriggerEnable.
#define CustomName_AutoTriggerDisable ADC_AutoTriggerDisable
Defines the Custom Name API mapping for ADC_AutoTriggerDisable.
#define CustomName_AutoTriggerSourceSet ADC_AutoTriggerSourceSet
Defines the Custom Name API mapping for ADC_AutoTriggerSourceSet.
#define CustomName_IsConversionDoneInterruptFlagSet ADC_IsConversionDoneInterruptFlagSet
Defines the Custom Name API mapping for ADC_IsConversionDoneInterruptFlagSet.
#define CustomName_ConversionDoneInterruptFlagClear ADC_ConversionDoneInterruptFlagClear
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptFlagClear.
#define CustomName_DigitalInputDisable ADC_DigitalInputDisable
Defines the Custom Name API mapping for ADC_DigitalInputDisable.
#define ADC_RESOLUTION 10U
ADC 10-bit resolution value.
Enumerations
enum adc_channel_t { ADC_CHANNEL_ADC0 = 0x0, ADC_CHANNEL_ADC1 = 0x1, ADC_CHANNEL_ADC2 = 0x2, ADC_CHANNEL_ADC3 = 0x3, ADC_CHANNEL_ADC4 = 0x4, ADC_CHANNEL_ADC5 = 0x5, ADC_CHANNEL_ADC6 = 0x6, ADC_CHANNEL_ADC7 = 0x7, ADC_CHANNEL_ADC0_ADC0_10X = 0x8, ADC_CHANNEL_ADC1_ADC0_10X = 0x9, ADC_CHANNEL_ADC0_ADC0_200X = 0xa, ADC_CHANNEL_ADC1_ADC0_200X = 0xb, ADC_CHANNEL_ADC2_ADC2_10X = 0xc, ADC_CHANNEL_ADC3_ADC2_10X = 0xd, ADC_CHANNEL_ADC2_ADC2_200X = 0xe, ADC_CHANNEL_ADC3_ADC2_200X = 0xf, ADC_CHANNEL_ADC0_ADC1_1X = 0x10, ADC_CHANNEL_ADC1_ADC1_1X = 0x11, ADC_CHANNEL_ADC2_ADC1_1X = 0x12, ADC_CHANNEL_ADC3_ADC1_1X = 0x13, ADC_CHANNEL_ADC4_ADC1_1X = 0x14, ADC_CHANNEL_ADC5_ADC1_1X = 0x15, ADC_CHANNEL_ADC6_ADC1_1X = 0x16, ADC_CHANNEL_ADC7_ADC1_1X = 0x17, ADC_CHANNEL_ADC0_ADC2_1X = 0x18, ADC_CHANNEL_ADC1_ADC2_1X = 0x19, ADC_CHANNEL_ADC2_ADC2_1X = 0x1a, ADC_CHANNEL_ADC3_ADC2_1X = 0x1b, ADC_CHANNEL_ADC4_ADC2_1X = 0x1c, ADC_CHANNEL_ADC5_ADC2_1X = 0x1d, ADC_CHANNEL_ADC_VBG = 0x1e, ADC_CHANNEL_ADC_GND = 0x1f, ADC_CHANNEL_ADC0 = 0x0, ADC_CHANNEL_ADC1 = 0x1, ADC_CHANNEL_ADC2 = 0x2, ADC_CHANNEL_ADC3 = 0x3, ADC_CHANNEL_ADC4 = 0x4, ADC_CHANNEL_ADC5 = 0x5, ADC_CHANNEL_ADC6 = 0x6, ADC_CHANNEL_ADC7 = 0x7, ADC_CHANNEL_ADC0_ADC0_10X = 0x8, ADC_CHANNEL_ADC1_ADC0_10X = 0x9, ADC_CHANNEL_ADC0_ADC0_200X = 0xa, ADC_CHANNEL_ADC1_ADC0_200X = 0xb, ADC_CHANNEL_ADC2_ADC2_10X = 0xc, ADC_CHANNEL_ADC3_ADC2_10X = 0xd, ADC_CHANNEL_ADC2_ADC2_200X = 0xe, ADC_CHANNEL_ADC3_ADC2_200X = 0xf, ADC_CHANNEL_ADC0_ADC1_1X = 0x10, ADC_CHANNEL_ADC1_ADC1_1X = 0x11, ADC_CHANNEL_ADC2_ADC1_1X = 0x12, ADC_CHANNEL_ADC3_ADC1_1X = 0x13, ADC_CHANNEL_ADC4_ADC1_1X = 0x14, ADC_CHANNEL_ADC5_ADC1_1X = 0x15, ADC_CHANNEL_ADC6_ADC1_1X = 0x16, ADC_CHANNEL_ADC7_ADC1_1X = 0x17, ADC_CHANNEL_ADC0_ADC2_1X = 0x18, ADC_CHANNEL_ADC1_ADC2_1X = 0x19, ADC_CHANNEL_ADC2_ADC2_1X = 0x1a, ADC_CHANNEL_ADC3_ADC2_1X = 0x1b, ADC_CHANNEL_ADC4_ADC2_1X = 0x1c, ADC_CHANNEL_ADC5_ADC2_1X = 0x1d, ADC_CHANNEL_ADC_VBG = 0x1e, ADC_CHANNEL_ADC_GND = 0x1f }
All available analog channels for the ADC conversion.
enum adc_trigger_source_t { ADC_FREE_RUNNING_MODE = 0x0, ADC_ANALOG_COMPARATOR = 0x1, ADC_EXTERNAL_INTERRUPT_REQUEST_0 = 0x2, ADC_TIMER_COUNTER0_COMPARE_MATCH_A = 0x3, ADC_TIMER_COUNTER0_OVERFLOW = 0x4, ADC_TIMER_COUNTER1_COMPARE_MATCH_B = 0x5, ADC_TIMER_COUNTER1_OVERFLOW = 0x6, ADC_TIMER_COUNTER1_CAPTURE_EVENT = 0x7, ADC_FREE_RUNNING_MODE = 0x0, ADC_ANALOG_COMPARATOR = 0x1, ADC_EXTERNAL_INTERRUPT_REQUEST_0 = 0x2, ADC_TIMER_COUNTER0_COMPARE_MATCH_A = 0x3, ADC_TIMER_COUNTER0_OVERFLOW = 0x4, ADC_TIMER_COUNTER1_COMPARE_MATCH_B = 0x5, ADC_TIMER_COUNTER1_OVERFLOW = 0x6, ADC_TIMER_COUNTER1_CAPTURE_EVENT = 0x7 }
Enumeration for the ADC auto-trigger sources.
Functions
void ADC_Initialize (void)
Initializes the registers based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI for the Analog-to-Digital Converter (ADC) operation.
void ADC_Deinitialize (void)
Deinitializes the registers to Power-on Reset values.
void ADC_Enable (void)
Sets the ADC Enabe (ADEN) bit to ‘1’.
void ADC_Disable (void)
Sets the ADC Enable (ADEN) bit to ‘0’.
void ADC_ChannelSelect (adc_channel_t channel)
Sets the channel to use for the ADC conversion.
void ADC_ConversionStart (void)
Starts the ADC conversion on a selected channel.
void ADC_ConversionDoneInterruptEnable (void)
Sets the ADC Interrupt Enable (ADIE) bit to ‘1’.
void ADC_ConversionDoneInterruptDisable (void)
Sets the ADC Interrupt Enable (ADIE) bit to ‘0’.
bool ADC_IsConversionDone (void)
Checks if the ongoing ADC conversion is complete.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Interrupt Flag (ADIF).
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of one conversion on the selected channel.
uint8_t ADC_ResolutionGet (void)
Returns the resolution of the ADC module.
void ADC_AutoTriggerEnable (void)
Sets the ADC Auto Trigger Enable (ADATE) bit to ‘1’.
void ADC_AutoTriggerDisable (void)
Sets the ADC Auto Trigger Enable (ADATE) bit to ‘0’.
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto-trigger source.
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Interrupt Flag (ADIF) status.
void ADC_ConversionDoneInterruptFlagClear (void)
Clears the ADC Interrupt (ADIF) flag.
void ADC_DigitalInputDisable (uint8_t disableValue)
Disables the digital input buffer on the corresponding ADC pin.
void ADC_Tasks (void)
Implements the Tasks routine for the polling implementation.
Definition Documentation
ADC_RESOLUTION[1/2]
#define ADC_RESOLUTION 10U
ADC 10-bit resolution value.
CustomName_AutoTriggerDisable[1/2]
#define CustomName_AutoTriggerDisable ADC_AutoTriggerDisable
Defines the Custom Name API mapping for ADC_AutoTriggerDisable.
CustomName_AutoTriggerEnable[1/2]
#define CustomName_AutoTriggerEnable ADC_AutoTriggerEnable
Defines the Custom Name API mapping for ADC_AutoTriggerEnable.
CustomName_AutoTriggerSourceSet[1/2]
#define CustomName_AutoTriggerSourceSet ADC_AutoTriggerSourceSet
Defines the Custom Name API mapping for ADC_AutoTriggerSourceSet.
CustomName_ChannelSelect[1/2]
#define CustomName_ChannelSelect ADC_ChannelSelect
Defines the Custom Name API mapping for ADC_ChannelSelect.
CustomName_ChannelSelectAndConvert[1/2]
#define CustomName_ChannelSelectAndConvert ADC_ChannelSelectAndConvert
Defines the Custom Name API mapping for ADC_ChannelSelectAndConvert.
CustomName_ConversionDoneCallbackRegister[1/2]
#define CustomName_ConversionDoneCallbackRegister ADC_ConversionDoneCallbackRegister
Defines the Custom Name API mapping for ADC_ConversionDoneCallbackRegister.
CustomName_ConversionDoneInterruptDisable
#define CustomName_ConversionDoneInterruptDisable ADC_ConversionDoneInterruptDisable
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptDisable.
CustomName_ConversionDoneInterruptEnable
#define CustomName_ConversionDoneInterruptEnable ADC_ConversionDoneInterruptEnable
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptEnable.
CustomName_ConversionDoneInterruptFlagClear[1/2]
#define CustomName_ConversionDoneInterruptFlagClear ADC_ConversionDoneInterruptFlagClear
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptFlagClear.
CustomName_ConversionResultGet[1/2]
#define CustomName_ConversionResultGet ADC_ConversionResultGet
Defines the Custom Name API mapping for ADC_ConversionResultGet.
CustomName_ConversionStart[1/2]
#define CustomName_ConversionStart ADC_ConversionStart
Defines the Custom Name API mapping for ADC_ConversionStart.
CustomName_Deinitialize[1/2]
#define CustomName_Deinitialize ADC_Deinitialize
Defines the Custom Name API mapping for ADC_Deinitialize.
CustomName_DigitalInputDisable[1/2]
#define CustomName_DigitalInputDisable ADC_DigitalInputDisable
Defines the Custom Name API mapping for ADC_DigitalInputDisable.
CustomName_Disable[1/2]
#define CustomName_Disable ADC_Disable
Defines the Custom Name API mapping for ADC_Disable.
CustomName_Enable[1/2]
#define CustomName_Enable ADC_Enable
Defines the Custom Name API mapping for ADC_Enable.
CustomName_Initialize[1/2]
#define CustomName_Initialize ADC_Initialize
Defines the Custom Name API mapping for ADC_Initialize.
CustomName_IsConversionDone[1/2]
#define CustomName_IsConversionDone ADC_IsConversionDone
Defines the Custom Name API mapping for ADC_IsConversionDone.
CustomName_IsConversionDoneInterruptFlagSet[1/2]
#define CustomName_IsConversionDoneInterruptFlagSet ADC_IsConversionDoneInterruptFlagSet
Defines the Custom Name API mapping for ADC_IsConversionDoneInterruptFlagSet.
CustomName_ResolutionGet[1/2]
#define CustomName_ResolutionGet ADC_ResolutionGet
Defines the Custom Name API mapping for ADC_ResolutionGet.
CustomName_Tasks
#define CustomName_Tasks ADC_Tasks
Defines the Custom Name API mapping for ADC_Tasks.
IO_PA0[1/2]
#define IO_PA0 ADC_CHANNEL_ADC0
Defines the Custom Name pin mapping for channels in adc_channel_t.
Typedef Documentation
adc_result_t
adc_result_t
ADC conversion result type.
Function Documentation
ADC_AutoTriggerDisable()
void ADC_AutoTriggerDisable (void )
Sets the ADC Auto Trigger Enable (ADATE) bit to ‘0’.
None. |
None. |
ADC_AutoTriggerEnable()
void ADC_AutoTriggerEnable (void )
Sets the ADC Auto Trigger Enable (ADATE) bit to ‘1’.
None. |
None. |
ADC_AutoTriggerSourceSet()
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto-trigger source.
triggerSource |
Desired auto-trigger source. Refer to the adc_trigger_source_t for the list of available trigger sources. |
None. |
ADC_ChannelSelect()
void ADC_ChannelSelect (adc_channel_t channel)
Sets the channel to use for the ADC conversion.
channel |
Desired analog channel. Refer to the adc_channel_t enum for the list of available analog channels. |
None. |
ADC_ChannelSelectAndConvert()
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of one conversion on the selected channel.
channel |
Desired analog channel. Refer to the adc_channel_t enum for the list of available analog channels. |
adc_result_t - The result of the conversion |
ADC_ConversionDoneCallbackRegister()
void ADC_ConversionDoneCallbackRegister (void(*)(void) callback)
Sets the callback function for the ADC Interrupt Flag (ADIF).
*callback |
The pointer to the function to be executed |
None. |
ADC_ConversionDoneInterruptDisable()
void ADC_ConversionDoneInterruptDisable (void )
Sets the ADC Interrupt Enable (ADIE) bit to ‘0’.
None. |
None. |
ADC_ConversionDoneInterruptEnable()
void ADC_ConversionDoneInterruptEnable (void )
Sets the ADC Interrupt Enable (ADIE) bit to ‘1’.
None. |
None. |
ADC_ConversionDoneInterruptFlagClear()
void ADC_ConversionDoneInterruptFlagClear (void )
Clears the ADC Interrupt (ADIF) flag.
None. |
None. |
ADC_ConversionResultGet()
adc_result_t ADC_ConversionResultGet (void )
Retrieves the result of the latest conversion.
None. |
adc_result_t - The result of the conversion |
ADC_ConversionStart()
void ADC_ConversionStart (void )
Starts the ADC conversion on a selected channel.
Select the channel using ADC_ChannelSelect and call ADC_Initialize(void) to initialize the ADC module before using this API. |
None. |
None. |
ADC_Deinitialize()
void ADC_Deinitialize (void )
Deinitializes the registers to Power-on Reset values.
None. |
None. |
ADC_DigitalInputDisable()
void ADC_DigitalInputDisable (uint8_t disableValue)
Disables the digital input buffer on the corresponding ADC pin.
disableValue |
Value for the disabled digital input |
None. |
ADC_Disable()
void ADC_Disable (void )
Disables the ADC module and the clock by clearing the Enable bit in the ADC Control register.
|
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.
|
None. |
ADC_Initialize()
void ADC_Initialize (void )
Initializes the registers based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI for the Analog-to-Digital Converter (ADC) operation.
None. |
None. |
ADC_IsConversionDone()
bool ADC_IsConversionDone (void )
Checks if the A/D conversion is done.
|
|
ADC_IsConversionDoneInterruptFlagSet()
bool ADC_IsConversionDoneInterruptFlagSet (void )
Checks the ADC Interrupt Flag (ADIF) status.
None. |
True |
- ADIF is set |
False |
- ADIF is not set |
ADC_ResolutionGet()
uint8_t ADC_ResolutionGet (void )
Returns the resolution of the ADC module.
None. |
uint8_t - Resolution value |
ADC_Tasks()
void ADC_Tasks (void )
Implements the Tasks routine for the polling implementation.
None. |
None. |
Ensure this function is invoked inside the service loop to maintain proper execution flow.
Enumeration Type Documentation
adc_channel_t
enum adc_channel_t
All available analog channels for the ADC conversion.
ADC_CHANNEL_ADC0 |
ADC Single Ended Input pin 0 |
ADC_CHANNEL_ADC1 |
ADC Single Ended Input pin 1 |
ADC_CHANNEL_ADC2 |
ADC Single Ended Input pin 2 |
ADC_CHANNEL_ADC3 |
ADC Single Ended Input pin 3 |
ADC_CHANNEL_ADC4 |
ADC Single Ended Input pin 4 |
ADC_CHANNEL_ADC5 |
ADC Single Ended Input pin 5 |
ADC_CHANNEL_ADC6 |
ADC Single Ended Input pin 6 |
ADC_CHANNEL_ADC7 |
ADC Single Ended Input pin 7 |
ADC_CHANNEL_ADC0_ADC0_10X |
ADC Differential Inputs Positive pin 0 Negative pin 0 10x Gain |
ADC_CHANNEL_ADC1_ADC0_10X |
ADC Differential Inputs Positive pin 1 Negative pin 0 10x Gain |
ADC_CHANNEL_ADC0_ADC0_200X |
ADC Differential Inputs Positive pin 0 Negative pin 0 200x Gain |
ADC_CHANNEL_ADC1_ADC0_200X |
ADC Differential Inputs Positive pin 1 Negative pin 0 200x Gain |
ADC_CHANNEL_ADC2_ADC2_10X |
ADC Differential Inputs Positive pin 2 Negative pin 2 10x Gain |
ADC_CHANNEL_ADC3_ADC2_10X |
ADC Differential Inputs Positive pin 3 Negative pin 2 10x Gain |
ADC_CHANNEL_ADC2_ADC2_200X |
ADC Differential Inputs Positive pin 2 Negative pin 2 200x Gain |
ADC_CHANNEL_ADC3_ADC2_200X |
ADC Differential Inputs Positive pin 3 Negative pin 2 200x Gain |
ADC_CHANNEL_ADC0_ADC1_1X |
ADC Differential Inputs Positive pin 0 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC1_ADC1_1X |
ADC Differential Inputs Positive pin 1 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC2_ADC1_1X |
ADC Differential Inputs Positive pin 2 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC3_ADC1_1X |
ADC Differential Inputs Positive pin 3 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC4_ADC1_1X |
ADC Differential Inputs Positive pin 4 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC5_ADC1_1X |
ADC Differential Inputs Positive pin 5 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC6_ADC1_1X |
ADC Differential Inputs Positive pin 6 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC7_ADC1_1X |
ADC Differential Inputs Positive pin 7 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC0_ADC2_1X |
ADC Differential Inputs Positive pin 0 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC1_ADC2_1X |
ADC Differential Inputs Positive pin 1 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC2_ADC2_1X |
ADC Differential Inputs Positive pin 2 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC3_ADC2_1X |
ADC Differential Inputs Positive pin 3 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC4_ADC2_1X |
ADC Differential Inputs Positive pin 4 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC5_ADC2_1X |
ADC Differential Inputs Positive pin 5 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC_VBG |
Internal Reference (VBG) |
ADC_CHANNEL_ADC_GND |
0V (GND) |
ADC_CHANNEL_ADC0 |
ADC Single Ended Input pin 0 |
ADC_CHANNEL_ADC1 |
ADC Single Ended Input pin 1 |
ADC_CHANNEL_ADC2 |
ADC Single Ended Input pin 2 |
ADC_CHANNEL_ADC3 |
ADC Single Ended Input pin 3 |
ADC_CHANNEL_ADC4 |
ADC Single Ended Input pin 4 |
ADC_CHANNEL_ADC5 |
ADC Single Ended Input pin 5 |
ADC_CHANNEL_ADC6 |
ADC Single Ended Input pin 6 |
ADC_CHANNEL_ADC7 |
ADC Single Ended Input pin 7 |
ADC_CHANNEL_ADC0_ADC0_10X |
ADC Differential Inputs Positive pin 0 Negative pin 0 10x Gain |
ADC_CHANNEL_ADC1_ADC0_10X |
ADC Differential Inputs Positive pin 1 Negative pin 0 10x Gain |
ADC_CHANNEL_ADC0_ADC0_200X |
ADC Differential Inputs Positive pin 0 Negative pin 0 200x Gain |
ADC_CHANNEL_ADC1_ADC0_200X |
ADC Differential Inputs Positive pin 1 Negative pin 0 200x Gain |
ADC_CHANNEL_ADC2_ADC2_10X |
ADC Differential Inputs Positive pin 2 Negative pin 2 10x Gain |
ADC_CHANNEL_ADC3_ADC2_10X |
ADC Differential Inputs Positive pin 3 Negative pin 2 10x Gain |
ADC_CHANNEL_ADC2_ADC2_200X |
ADC Differential Inputs Positive pin 2 Negative pin 2 200x Gain |
ADC_CHANNEL_ADC3_ADC2_200X |
ADC Differential Inputs Positive pin 3 Negative pin 2 200x Gain |
ADC_CHANNEL_ADC0_ADC1_1X |
ADC Differential Inputs Positive pin 0 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC1_ADC1_1X |
ADC Differential Inputs Positive pin 1 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC2_ADC1_1X |
ADC Differential Inputs Positive pin 2 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC3_ADC1_1X |
ADC Differential Inputs Positive pin 3 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC4_ADC1_1X |
ADC Differential Inputs Positive pin 4 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC5_ADC1_1X |
ADC Differential Inputs Positive pin 5 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC6_ADC1_1X |
ADC Differential Inputs Positive pin 6 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC7_ADC1_1X |
ADC Differential Inputs Positive pin 7 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC0_ADC2_1X |
ADC Differential Inputs Positive pin 0 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC1_ADC2_1X |
ADC Differential Inputs Positive pin 1 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC2_ADC2_1X |
ADC Differential Inputs Positive pin 2 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC3_ADC2_1X |
ADC Differential Inputs Positive pin 3 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC4_ADC2_1X |
ADC Differential Inputs Positive pin 4 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC5_ADC2_1X |
ADC Differential Inputs Positive pin 5 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC_VBG |
Internal Reference (VBG) |
ADC_CHANNEL_ADC_GND |
0V (GND) |
adc_trigger_source_t
enum adc_trigger_source_t
Enumeration for the ADC auto-trigger sources.
ADC_FREE_RUNNING_MODE |
Free Running mode |
ADC_ANALOG_COMPARATOR |
Analog Comparator |
ADC_EXTERNAL_INTERRUPT_REQUEST_0 |
External Interrupt Request 0 |
ADC_TIMER_COUNTER0_COMPARE_MATCH_A |
Timer/Counter0 Compare Match A |
ADC_TIMER_COUNTER0_OVERFLOW |
Timer/Counter0 Overflow |
ADC_TIMER_COUNTER1_COMPARE_MATCH_B |
Timer/Counter1 Compare Match B |
ADC_TIMER_COUNTER1_OVERFLOW |
Timer/Counter1 Overflow |
ADC_TIMER_COUNTER1_CAPTURE_EVENT |
Timer/Counter1 Capture Event |
ADC_FREE_RUNNING_MODE |
Free Running mode |
ADC_ANALOG_COMPARATOR |
Analog Comparator |
ADC_EXTERNAL_INTERRUPT_REQUEST_0 |
External Interrupt Request 0 |
ADC_TIMER_COUNTER0_COMPARE_MATCH_A |
Timer/Counter0 Compare Match A |
ADC_TIMER_COUNTER0_OVERFLOW |
Timer/Counter0 Overflow |
ADC_TIMER_COUNTER1_COMPARE_MATCH_B |
Timer/Counter1 Compare Match B |
ADC_TIMER_COUNTER1_OVERFLOW |
Timer/Counter1 Overflow |
ADC_TIMER_COUNTER1_CAPTURE_EVENT |
Timer/Counter1 Capture Event |
4.2.1.5 File Documentation
4.2.1.5.1 source/Single-Ended_Interrupts/adc.h File Reference
#include "../system/utils/compiler.h" #include "./adc_types.h"
Functions
void ADC_Initialize (void)
Initializes the registers based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI for the Analog-to-Digital Converter (ADC) operation.
void ADC_Deinitialize (void)
Deinitializes the registers to Power-on Reset values.
void ADC_Enable (void)
Sets the ADC Enabe (ADEN) bit to ‘1’.
void ADC_Disable (void)
Sets the ADC Enable (ADEN) bit to ‘0’.
void ADC_ChannelSelect (adc_channel_t channel)
Sets the channel to use for the ADC conversion.
void ADC_ConversionStart (void)
Starts the ADC conversion on a selected channel.
void ADC_ConversionDoneInterruptEnable (void)
Sets the ADC Interrupt Enable (ADIE) bit to ‘1’.
void ADC_ConversionDoneInterruptDisable (void)
Sets the ADC Interrupt Enable (ADIE) bit to ‘0’.
bool ADC_IsConversionDone (void)
Checks if the ongoing ADC conversion is complete.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Interrupt Flag (ADIF).
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of one conversion on the selected channel.
uint8_t ADC_ResolutionGet (void)
Returns the resolution of the ADC module.
void ADC_AutoTriggerEnable (void)
Sets the ADC Auto Trigger Enable (ADATE) bit to ‘1’.
void ADC_AutoTriggerDisable (void)
Sets the ADC Auto Trigger Enable (ADATE) bit to ‘0’.
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto-trigger source.
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Interrupt Flag (ADIF) status.
void ADC_ConversionDoneInterruptFlagClear (void)
Clears the ADC Interrupt (ADIF) flag.
void ADC_DigitalInputDisable (uint8_t disableValue)
Disables the digital input buffer on the corresponding ADC pin.
Macros
#define IO_PA0 ADC_CHANNEL_ADC0
Defines the Custom Name pin mapping for channels in adc_channel_t.
#define CustomName_Initialize ADC_Initialize
Defines the Custom Name API mapping for ADC_Initialize.
#define CustomName_Deinitialize ADC_Deinitialize
Defines the Custom Name API mapping for ADC_Deinitialize.
#define CustomName_Enable ADC_Enable
Defines the Custom Name API mapping for ADC_Enable.
#define CustomName_Disable ADC_Disable
Defines the Custom Name API mapping for ADC_Disable.
#define CustomName_ConversionStart ADC_ConversionStart
Defines the Custom Name API mapping for ADC_ConversionStart.
#define CustomName_IsConversionDone ADC_IsConversionDone
Defines the Custom Name API mapping for ADC_IsConversionDone.
#define CustomName_ConversionResultGet ADC_ConversionResultGet
Defines the Custom Name API mapping for ADC_ConversionResultGet.
#define CustomName_ResolutionGet ADC_ResolutionGet
Defines the Custom Name API mapping for ADC_ResolutionGet.
#define CustomName_ConversionDoneCallbackRegister ADC_ConversionDoneCallbackRegister
Defines the Custom Name API mapping for ADC_ConversionDoneCallbackRegister.
#define CustomName_ChannelSelect ADC_ChannelSelect
Defines the Custom Name API mapping for ADC_ChannelSelect.
#define CustomName_ChannelSelectAndConvert ADC_ChannelSelectAndConvert
Defines the Custom Name API mapping for ADC_ChannelSelectAndConvert.
#define CustomName_ConversionDoneInterruptEnable ADC_ConversionDoneInterruptEnable
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptEnable.
#define CustomName_ConversionDoneInterruptDisable ADC_ConversionDoneInterruptDisable
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptDisable.
#define CustomName_AutoTriggerEnable ADC_AutoTriggerEnable
Defines the Custom Name API mapping for ADC_AutoTriggerEnable.
#define CustomName_AutoTriggerDisable ADC_AutoTriggerDisable
Defines the Custom Name API mapping for ADC_AutoTriggerDisable.
#define CustomName_AutoTriggerSourceSet ADC_AutoTriggerSourceSet
Defines the Custom Name API mapping for ADC_AutoTriggerSourceSet.
#define CustomName_IsConversionDoneInterruptFlagSet ADC_IsConversionDoneInterruptFlagSet
Defines the Custom Name API mapping for ADC_IsConversionDoneInterruptFlagSet.
#define CustomName_ConversionDoneInterruptFlagClear ADC_ConversionDoneInterruptFlagClear
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptFlagClear.
#define CustomName_DigitalInputDisable ADC_DigitalInputDisable
Defines the Custom Name API mapping for ADC_DigitalInputDisable.
Detailed Description
ADC Generated Driver API Header File
4.2.1.5.2 source/Single-Ended_Tasks/adc.h File Reference
#include "../system/utils/compiler.h" #include "./adc_types.h"
Functions
void ADC_Initialize (void)
Initializes the registers based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI for the Analog-to-Digital Converter (ADC) operation.
void ADC_Deinitialize (void)
Deinitializes the registers to Power-on Reset values.
void ADC_Enable (void)
Sets the ADC Enabe (ADEN) bit to ‘1’.
void ADC_Disable (void)
Sets the ADC Enable (ADEN) bit to ‘0’.
void ADC_ChannelSelect (adc_channel_t channel)
Sets the channel to use for the ADC conversion.
void ADC_ConversionStart (void)
Starts the ADC conversion on a selected channel.
bool ADC_IsConversionDone (void)
Checks if the ongoing ADC conversion is complete.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Interrupt Flag (ADIF).
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of one conversion on the selected channel.
uint8_t ADC_ResolutionGet (void)
Returns the resolution of the ADC module.
void ADC_AutoTriggerEnable (void)
Sets the ADC Auto Trigger Enable (ADATE) bit to ‘1’.
void ADC_AutoTriggerDisable (void)
Sets the ADC Auto Trigger Enable (ADATE) bit to ‘0’.
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto-trigger source.
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Interrupt Flag (ADIF) status.
void ADC_ConversionDoneInterruptFlagClear (void)
Clears the ADC Interrupt (ADIF) flag.
void ADC_DigitalInputDisable (uint8_t disableValue)
Disables the digital input buffer on the corresponding ADC pin.
void ADC_Tasks (void)
Implements the Tasks routine for the polling implementation.
Macros
#define IO_PA0 ADC_CHANNEL_ADC0
Defines the Custom Name pin mapping for channels in adc_channel_t.
#define CustomName_Initialize ADC_Initialize
Defines the Custom Name API mapping for ADC_Initialize.
#define CustomName_Deinitialize ADC_Deinitialize
Defines the Custom Name API mapping for ADC_Deinitialize.
#define CustomName_Enable ADC_Enable
Defines the Custom Name API mapping for ADC_Enable.
#define CustomName_Disable ADC_Disable
Defines the Custom Name API mapping for ADC_Disable.
#define CustomName_ConversionStart ADC_ConversionStart
Defines the Custom Name API mapping for ADC_ConversionStart.
#define CustomName_IsConversionDone ADC_IsConversionDone
Defines the Custom Name API mapping for ADC_IsConversionDone.
#define CustomName_ConversionResultGet ADC_ConversionResultGet
Defines the Custom Name API mapping for ADC_ConversionResultGet.
#define CustomName_ResolutionGet ADC_ResolutionGet
Defines the Custom Name API mapping for ADC_ResolutionGet.
#define CustomName_ConversionDoneCallbackRegister ADC_ConversionDoneCallbackRegister
Defines the Custom Name API mapping for ADC_ConversionDoneCallbackRegister.
#define CustomName_ChannelSelect ADC_ChannelSelect
Defines the Custom Name API mapping for ADC_ChannelSelect.
#define CustomName_ChannelSelectAndConvert ADC_ChannelSelectAndConvert
Defines the Custom Name API mapping for ADC_ChannelSelectAndConvert.
#define CustomName_Tasks ADC_Tasks
Defines the Custom Name API mapping for ADC_Tasks.
#define CustomName_AutoTriggerEnable ADC_AutoTriggerEnable
Defines the Custom Name API mapping for ADC_AutoTriggerEnable.
#define CustomName_AutoTriggerDisable ADC_AutoTriggerDisable
Defines the Custom Name API mapping for ADC_AutoTriggerDisable.
#define CustomName_AutoTriggerSourceSet ADC_AutoTriggerSourceSet
Defines the Custom Name API mapping for ADC_AutoTriggerSourceSet.
#define CustomName_IsConversionDoneInterruptFlagSet ADC_IsConversionDoneInterruptFlagSet
Defines the Custom Name API mapping for ADC_IsConversionDoneInterruptFlagSet.
#define CustomName_ConversionDoneInterruptFlagClear ADC_ConversionDoneInterruptFlagClear
Defines the Custom Name API mapping for ADC_ConversionDoneInterruptFlagClear.
#define CustomName_DigitalInputDisable ADC_DigitalInputDisable
Defines the Custom Name API mapping for ADC_DigitalInputDisable.
Detailed Description
ADC Generated Driver API Header File
4.2.1.5.3 source/Single-Ended_Interrupts/adc_types.h File Reference
#include <stdint.h>
Macros
#define ADC_RESOLUTION 10U
ADC 10-bit resolution value.
Typedefs
typedef int16_t adc_result_t
ADC conversion result type.
Enumerations
enum adc_channel_t { ADC_CHANNEL_ADC0 = 0x0, ADC_CHANNEL_ADC1 = 0x1, ADC_CHANNEL_ADC2 = 0x2, ADC_CHANNEL_ADC3 = 0x3, ADC_CHANNEL_ADC4 = 0x4, ADC_CHANNEL_ADC5 = 0x5, ADC_CHANNEL_ADC6 = 0x6, ADC_CHANNEL_ADC7 = 0x7, ADC_CHANNEL_ADC0_ADC0_10X = 0x8, ADC_CHANNEL_ADC1_ADC0_10X = 0x9, ADC_CHANNEL_ADC0_ADC0_200X = 0xa, ADC_CHANNEL_ADC1_ADC0_200X = 0xb, ADC_CHANNEL_ADC2_ADC2_10X = 0xc, ADC_CHANNEL_ADC3_ADC2_10X = 0xd, ADC_CHANNEL_ADC2_ADC2_200X = 0xe, ADC_CHANNEL_ADC3_ADC2_200X = 0xf, ADC_CHANNEL_ADC0_ADC1_1X = 0x10, ADC_CHANNEL_ADC1_ADC1_1X = 0x11, ADC_CHANNEL_ADC2_ADC1_1X = 0x12, ADC_CHANNEL_ADC3_ADC1_1X = 0x13, ADC_CHANNEL_ADC4_ADC1_1X = 0x14, ADC_CHANNEL_ADC5_ADC1_1X = 0x15, ADC_CHANNEL_ADC6_ADC1_1X = 0x16, ADC_CHANNEL_ADC7_ADC1_1X = 0x17, ADC_CHANNEL_ADC0_ADC2_1X = 0x18, ADC_CHANNEL_ADC1_ADC2_1X = 0x19, ADC_CHANNEL_ADC2_ADC2_1X = 0x1a, ADC_CHANNEL_ADC3_ADC2_1X = 0x1b, ADC_CHANNEL_ADC4_ADC2_1X = 0x1c, ADC_CHANNEL_ADC5_ADC2_1X = 0x1d, ADC_CHANNEL_ADC_VBG = 0x1e, ADC_CHANNEL_ADC_GND = 0x1f, ADC_CHANNEL_ADC0 = 0x0, ADC_CHANNEL_ADC1 = 0x1, ADC_CHANNEL_ADC2 = 0x2, ADC_CHANNEL_ADC3 = 0x3, ADC_CHANNEL_ADC4 = 0x4, ADC_CHANNEL_ADC5 = 0x5, ADC_CHANNEL_ADC6 = 0x6, ADC_CHANNEL_ADC7 = 0x7, ADC_CHANNEL_ADC0_ADC0_10X = 0x8, ADC_CHANNEL_ADC1_ADC0_10X = 0x9, ADC_CHANNEL_ADC0_ADC0_200X = 0xa, ADC_CHANNEL_ADC1_ADC0_200X = 0xb, ADC_CHANNEL_ADC2_ADC2_10X = 0xc, ADC_CHANNEL_ADC3_ADC2_10X = 0xd, ADC_CHANNEL_ADC2_ADC2_200X = 0xe, ADC_CHANNEL_ADC3_ADC2_200X = 0xf, ADC_CHANNEL_ADC0_ADC1_1X = 0x10, ADC_CHANNEL_ADC1_ADC1_1X = 0x11, ADC_CHANNEL_ADC2_ADC1_1X = 0x12, ADC_CHANNEL_ADC3_ADC1_1X = 0x13, ADC_CHANNEL_ADC4_ADC1_1X = 0x14, ADC_CHANNEL_ADC5_ADC1_1X = 0x15, ADC_CHANNEL_ADC6_ADC1_1X = 0x16, ADC_CHANNEL_ADC7_ADC1_1X = 0x17, ADC_CHANNEL_ADC0_ADC2_1X = 0x18, ADC_CHANNEL_ADC1_ADC2_1X = 0x19, ADC_CHANNEL_ADC2_ADC2_1X = 0x1a, ADC_CHANNEL_ADC3_ADC2_1X = 0x1b, ADC_CHANNEL_ADC4_ADC2_1X = 0x1c, ADC_CHANNEL_ADC5_ADC2_1X = 0x1d, ADC_CHANNEL_ADC_VBG = 0x1e, ADC_CHANNEL_ADC_GND = 0x1f }
All available analog channels for the ADC conversion.
enum adc_trigger_source_t { ADC_FREE_RUNNING_MODE = 0x0, ADC_ANALOG_COMPARATOR = 0x1, ADC_EXTERNAL_INTERRUPT_REQUEST_0 = 0x2, ADC_TIMER_COUNTER0_COMPARE_MATCH_A = 0x3, ADC_TIMER_COUNTER0_OVERFLOW = 0x4, ADC_TIMER_COUNTER1_COMPARE_MATCH_B = 0x5, ADC_TIMER_COUNTER1_OVERFLOW = 0x6, ADC_TIMER_COUNTER1_CAPTURE_EVENT = 0x7, ADC_FREE_RUNNING_MODE = 0x0, ADC_ANALOG_COMPARATOR = 0x1, ADC_EXTERNAL_INTERRUPT_REQUEST_0 = 0x2, ADC_TIMER_COUNTER0_COMPARE_MATCH_A = 0x3, ADC_TIMER_COUNTER0_OVERFLOW = 0x4, ADC_TIMER_COUNTER1_COMPARE_MATCH_B = 0x5, ADC_TIMER_COUNTER1_OVERFLOW = 0x6, ADC_TIMER_COUNTER1_CAPTURE_EVENT = 0x7 }
Enumeration for the ADC auto-trigger sources.
Detailed Description
ADC Type Definitions Header File
4.2.1.5.4 source/Single-Ended_Tasks/adc_types.h File Reference
#include <stdint.h>
Macros
#define ADC_RESOLUTION 10U
ADC 10-bit resolution value.
Typedefs
typedef int16_t adc_result_t
Enumerations
enum adc_channel_t { ADC_CHANNEL_ADC0 = 0x0, ADC_CHANNEL_ADC1 = 0x1, ADC_CHANNEL_ADC2 = 0x2, ADC_CHANNEL_ADC3 = 0x3, ADC_CHANNEL_ADC4 = 0x4, ADC_CHANNEL_ADC5 = 0x5, ADC_CHANNEL_ADC6 = 0x6, ADC_CHANNEL_ADC7 = 0x7, ADC_CHANNEL_ADC0_ADC0_10X = 0x8, ADC_CHANNEL_ADC1_ADC0_10X = 0x9, ADC_CHANNEL_ADC0_ADC0_200X = 0xa, ADC_CHANNEL_ADC1_ADC0_200X = 0xb, ADC_CHANNEL_ADC2_ADC2_10X = 0xc, ADC_CHANNEL_ADC3_ADC2_10X = 0xd, ADC_CHANNEL_ADC2_ADC2_200X = 0xe, ADC_CHANNEL_ADC3_ADC2_200X = 0xf, ADC_CHANNEL_ADC0_ADC1_1X = 0x10, ADC_CHANNEL_ADC1_ADC1_1X = 0x11, ADC_CHANNEL_ADC2_ADC1_1X = 0x12, ADC_CHANNEL_ADC3_ADC1_1X = 0x13, ADC_CHANNEL_ADC4_ADC1_1X = 0x14, ADC_CHANNEL_ADC5_ADC1_1X = 0x15, ADC_CHANNEL_ADC6_ADC1_1X = 0x16, ADC_CHANNEL_ADC7_ADC1_1X = 0x17, ADC_CHANNEL_ADC0_ADC2_1X = 0x18, ADC_CHANNEL_ADC1_ADC2_1X = 0x19, ADC_CHANNEL_ADC2_ADC2_1X = 0x1a, ADC_CHANNEL_ADC3_ADC2_1X = 0x1b, ADC_CHANNEL_ADC4_ADC2_1X = 0x1c, ADC_CHANNEL_ADC5_ADC2_1X = 0x1d, ADC_CHANNEL_ADC_VBG = 0x1e, ADC_CHANNEL_ADC_GND = 0x1f, ADC_CHANNEL_ADC0 = 0x0, ADC_CHANNEL_ADC1 = 0x1, ADC_CHANNEL_ADC2 = 0x2, ADC_CHANNEL_ADC3 = 0x3, ADC_CHANNEL_ADC4 = 0x4, ADC_CHANNEL_ADC5 = 0x5, ADC_CHANNEL_ADC6 = 0x6, ADC_CHANNEL_ADC7 = 0x7, ADC_CHANNEL_ADC0_ADC0_10X = 0x8, ADC_CHANNEL_ADC1_ADC0_10X = 0x9, ADC_CHANNEL_ADC0_ADC0_200X = 0xa, ADC_CHANNEL_ADC1_ADC0_200X = 0xb, ADC_CHANNEL_ADC2_ADC2_10X = 0xc, ADC_CHANNEL_ADC3_ADC2_10X = 0xd, ADC_CHANNEL_ADC2_ADC2_200X = 0xe, ADC_CHANNEL_ADC3_ADC2_200X = 0xf, ADC_CHANNEL_ADC0_ADC1_1X = 0x10, ADC_CHANNEL_ADC1_ADC1_1X = 0x11, ADC_CHANNEL_ADC2_ADC1_1X = 0x12, ADC_CHANNEL_ADC3_ADC1_1X = 0x13, ADC_CHANNEL_ADC4_ADC1_1X = 0x14, ADC_CHANNEL_ADC5_ADC1_1X = 0x15, ADC_CHANNEL_ADC6_ADC1_1X = 0x16, ADC_CHANNEL_ADC7_ADC1_1X = 0x17, ADC_CHANNEL_ADC0_ADC2_1X = 0x18, ADC_CHANNEL_ADC1_ADC2_1X = 0x19, ADC_CHANNEL_ADC2_ADC2_1X = 0x1a, ADC_CHANNEL_ADC3_ADC2_1X = 0x1b, ADC_CHANNEL_ADC4_ADC2_1X = 0x1c, ADC_CHANNEL_ADC5_ADC2_1X = 0x1d, ADC_CHANNEL_ADC_VBG = 0x1e, ADC_CHANNEL_ADC_GND = 0x1f }
enum adc_trigger_source_t { ADC_FREE_RUNNING_MODE = 0x0, ADC_ANALOG_COMPARATOR = 0x1, ADC_EXTERNAL_INTERRUPT_REQUEST_0 = 0x2, ADC_TIMER_COUNTER0_COMPARE_MATCH_A = 0x3, ADC_TIMER_COUNTER0_OVERFLOW = 0x4, ADC_TIMER_COUNTER1_COMPARE_MATCH_B = 0x5, ADC_TIMER_COUNTER1_OVERFLOW = 0x6, ADC_TIMER_COUNTER1_CAPTURE_EVENT = 0x7, ADC_FREE_RUNNING_MODE = 0x0, ADC_ANALOG_COMPARATOR = 0x1, ADC_EXTERNAL_INTERRUPT_REQUEST_0 = 0x2, ADC_TIMER_COUNTER0_COMPARE_MATCH_A = 0x3, ADC_TIMER_COUNTER0_OVERFLOW = 0x4, ADC_TIMER_COUNTER1_COMPARE_MATCH_B = 0x5, ADC_TIMER_COUNTER1_OVERFLOW = 0x6, ADC_TIMER_COUNTER1_CAPTURE_EVENT = 0x7 }
Detailed Description
ADC Type Definitions Header File
Typedef Documentation
adc_result_t
typedef int16_t adc_result_t
Enumeration Type Documentation
adc_channel_t
enum adc_channel_t
ADC_CHANNEL_ADC0 |
ADC Single Ended Input pin 0 |
ADC_CHANNEL_ADC1 |
ADC Single Ended Input pin 1 |
ADC_CHANNEL_ADC2 |
ADC Single Ended Input pin 2 |
ADC_CHANNEL_ADC3 |
ADC Single Ended Input pin 3 |
ADC_CHANNEL_ADC4 |
ADC Single Ended Input pin 4 |
ADC_CHANNEL_ADC5 |
ADC Single Ended Input pin 5 |
ADC_CHANNEL_ADC6 |
ADC Single Ended Input pin 6 |
ADC_CHANNEL_ADC7 |
ADC Single Ended Input pin 7 |
ADC_CHANNEL_ADC0_ADC0_10X |
ADC Differential Inputs Positive pin 0 Negative pin 0 10x Gain |
ADC_CHANNEL_ADC1_ADC0_10X |
ADC Differential Inputs Positive pin 1 Negative pin 0 10x Gain |
ADC_CHANNEL_ADC0_ADC0_200X |
ADC Differential Inputs Positive pin 0 Negative pin 0 200x Gain |
ADC_CHANNEL_ADC1_ADC0_200X |
ADC Differential Inputs Positive pin 1 Negative pin 0 200x Gain |
ADC_CHANNEL_ADC2_ADC2_10X |
ADC Differential Inputs Positive pin 2 Negative pin 2 10x Gain |
ADC_CHANNEL_ADC3_ADC2_10X |
ADC Differential Inputs Positive pin 3 Negative pin 2 10x Gain |
ADC_CHANNEL_ADC2_ADC2_200X |
ADC Differential Inputs Positive pin 2 Negative pin 2 200x Gain |
ADC_CHANNEL_ADC3_ADC2_200X |
ADC Differential Inputs Positive pin 3 Negative pin 2 200x Gain |
ADC_CHANNEL_ADC0_ADC1_1X |
ADC Differential Inputs Positive pin 0 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC1_ADC1_1X |
ADC Differential Inputs Positive pin 1 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC2_ADC1_1X |
ADC Differential Inputs Positive pin 2 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC3_ADC1_1X |
ADC Differential Inputs Positive pin 3 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC4_ADC1_1X |
ADC Differential Inputs Positive pin 4 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC5_ADC1_1X |
ADC Differential Inputs Positive pin 5 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC6_ADC1_1X |
ADC Differential Inputs Positive pin 6 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC7_ADC1_1X |
ADC Differential Inputs Positive pin 7 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC0_ADC2_1X |
ADC Differential Inputs Positive pin 0 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC1_ADC2_1X |
ADC Differential Inputs Positive pin 1 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC2_ADC2_1X |
ADC Differential Inputs Positive pin 2 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC3_ADC2_1X |
ADC Differential Inputs Positive pin 3 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC4_ADC2_1X |
ADC Differential Inputs Positive pin 4 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC5_ADC2_1X |
ADC Differential Inputs Positive pin 5 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC_VBG |
Internal Reference (VBG) |
ADC_CHANNEL_ADC_GND |
0V (GND) |
ADC_CHANNEL_ADC0 |
ADC Single Ended Input pin 0 |
ADC_CHANNEL_ADC1 |
ADC Single Ended Input pin 1 |
ADC_CHANNEL_ADC2 |
ADC Single Ended Input pin 2 |
ADC_CHANNEL_ADC3 |
ADC Single Ended Input pin 3 |
ADC_CHANNEL_ADC4 |
ADC Single Ended Input pin 4 |
ADC_CHANNEL_ADC5 |
ADC Single Ended Input pin 5 |
ADC_CHANNEL_ADC6 |
ADC Single Ended Input pin 6 |
ADC_CHANNEL_ADC7 |
ADC Single Ended Input pin 7 |
ADC_CHANNEL_ADC0_ADC0_10X |
ADC Differential Inputs Positive pin 0 Negative pin 0 10x Gain |
ADC_CHANNEL_ADC1_ADC0_10X |
ADC Differential Inputs Positive pin 1 Negative pin 0 10x Gain |
ADC_CHANNEL_ADC0_ADC0_200X |
ADC Differential Inputs Positive pin 0 Negative pin 0 200x Gain |
ADC_CHANNEL_ADC1_ADC0_200X |
ADC Differential Inputs Positive pin 1 Negative pin 0 200x Gain |
ADC_CHANNEL_ADC2_ADC2_10X |
ADC Differential Inputs Positive pin 2 Negative pin 2 10x Gain |
ADC_CHANNEL_ADC3_ADC2_10X |
ADC Differential Inputs Positive pin 3 Negative pin 2 10x Gain |
ADC_CHANNEL_ADC2_ADC2_200X |
ADC Differential Inputs Positive pin 2 Negative pin 2 200x Gain |
ADC_CHANNEL_ADC3_ADC2_200X |
ADC Differential Inputs Positive pin 3 Negative pin 2 200x Gain |
ADC_CHANNEL_ADC0_ADC1_1X |
ADC Differential Inputs Positive pin 0 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC1_ADC1_1X |
ADC Differential Inputs Positive pin 1 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC2_ADC1_1X |
ADC Differential Inputs Positive pin 2 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC3_ADC1_1X |
ADC Differential Inputs Positive pin 3 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC4_ADC1_1X |
ADC Differential Inputs Positive pin 4 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC5_ADC1_1X |
ADC Differential Inputs Positive pin 5 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC6_ADC1_1X |
ADC Differential Inputs Positive pin 6 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC7_ADC1_1X |
ADC Differential Inputs Positive pin 7 Negative pin 1 1x Gain |
ADC_CHANNEL_ADC0_ADC2_1X |
ADC Differential Inputs Positive pin 0 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC1_ADC2_1X |
ADC Differential Inputs Positive pin 1 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC2_ADC2_1X |
ADC Differential Inputs Positive pin 2 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC3_ADC2_1X |
ADC Differential Inputs Positive pin 3 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC4_ADC2_1X |
ADC Differential Inputs Positive pin 4 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC5_ADC2_1X |
ADC Differential Inputs Positive pin 5 Negative pin 2 1x Gain |
ADC_CHANNEL_ADC_VBG |
Internal Reference (VBG) |
ADC_CHANNEL_ADC_GND |
0V (GND) |
adc_trigger_source_t
enum adc_trigger_source_t
ADC_FREE_RUNNING_MODE |
Free Running mode |
ADC_ANALOG_COMPARATOR |
Analog Comparator |
ADC_EXTERNAL_INTERRUPT_REQUEST_0 |
External Interrupt Request 0 |
ADC_TIMER_COUNTER0_COMPARE_MATCH_A |
Timer/Counter0 Compare Match A |
ADC_TIMER_COUNTER0_OVERFLOW |
Timer/Counter0 Overflow |
ADC_TIMER_COUNTER1_COMPARE_MATCH_B |
Timer/Counter1 Compare Match B |
ADC_TIMER_COUNTER1_OVERFLOW |
Timer/Counter1 Overflow |
ADC_TIMER_COUNTER1_CAPTURE_EVENT |
Timer/Counter1 Capture Event |
ADC_FREE_RUNNING_MODE |
Free Running mode |
ADC_ANALOG_COMPARATOR |
Analog Comparator |
ADC_EXTERNAL_INTERRUPT_REQUEST_0 |
External Interrupt Request 0 |
ADC_TIMER_COUNTER0_COMPARE_MATCH_A |
Timer/Counter0 Compare Match A |
ADC_TIMER_COUNTER0_OVERFLOW |
Timer/Counter0 Overflow |
ADC_TIMER_COUNTER1_COMPARE_MATCH_B |
Timer/Counter1 Compare Match B |
ADC_TIMER_COUNTER1_OVERFLOW |
Timer/Counter1 Overflow |
ADC_TIMER_COUNTER1_CAPTURE_EVENT |
Timer/Counter1 Capture Event |
4.2.1.5.5 source/Single-Ended_Interrupts/src/adc.c File Reference
This file contains the API implementations for the ADC driver.
#include "../adc.h"
Functions
void ADC_Initialize (void)
Initializes the registers based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI for the Analog-to-Digital Converter (ADC) operation.
void ADC_Deinitialize (void)
Deinitializes the registers to Power-on Reset values.
void ADC_Enable (void)
Sets the ADC Enabe (ADEN) bit to ‘1’.
void ADC_Disable (void)
Sets the ADC Enable (ADEN) bit to ‘0’.
void ADC_ChannelSelect (adc_channel_t channel)
Sets the channel to use for the ADC conversion.
void ADC_ConversionStart (void)
Starts the ADC conversion on a selected channel.
void ADC_ConversionDoneInterruptEnable (void)
Sets the ADC Interrupt Enable (ADIE) bit to ‘1’.
void ADC_ConversionDoneInterruptDisable (void)
Sets the ADC Interrupt Enable (ADIE) bit to ‘0’.
bool ADC_IsConversionDone (void)
Checks if the ongoing ADC conversion is complete.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Interrupt Flag (ADIF).
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of one conversion on the selected channel.
uint8_t ADC_ResolutionGet (void)
Returns the resolution of the ADC module.
void ADC_AutoTriggerEnable (void)
Sets the ADC Auto Trigger Enable (ADATE) bit to ‘1’.
void ADC_AutoTriggerDisable (void)
Sets the ADC Auto Trigger Enable (ADATE) bit to ‘0’.
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto-trigger source.
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Interrupt Flag (ADIF) status.
void ADC_ConversionDoneInterruptFlagClear (void)
Clears the ADC Interrupt (ADIF) flag.
void ADC_DigitalInputDisable (uint8_t disableValue)
Disables the digital input buffer on the corresponding ADC pin.
ISR (ADC_vect)
Variables
static void(* ADC_ConversionDoneCallback )(void) = NULL
Detailed Description
This file contains the API implementations for the ADC driver.
ADC Generated Driver File
Function Documentation
ISR()
ISR (ADC_vect )
Variable Documentation
ADC_ConversionDoneCallback
void(* ADC_ConversionDoneCallback) (void) = NULL[static]
4.2.1.5.6 source/Single-Ended_Tasks/src/adc.c File Reference
This file contains the API implementations for the ADC driver.
#include "../adc.h"
Functions
void ADC_Initialize (void)
Initializes the registers based on the configurable options in the MPLAB® Code Configurator (MCC) Melody UI for the Analog-to-Digital Converter (ADC) operation.
void ADC_Deinitialize (void)
Deinitializes the registers to Power-on Reset values.
void ADC_Enable (void)
Sets the ADC Enabe (ADEN) bit to ‘1’.
void ADC_Disable (void)
Sets the ADC Enable (ADEN) bit to ‘0’.
void ADC_ChannelSelect (adc_channel_t channel)
Sets the channel to use for the ADC conversion.
void ADC_ConversionStart (void)
Starts the ADC conversion on a selected channel.
bool ADC_IsConversionDone (void)
Checks if the ongoing ADC conversion is complete.
adc_result_t ADC_ConversionResultGet (void)
Retrieves the result of the latest conversion.
void ADC_ConversionDoneCallbackRegister (void(*callback)(void))
Sets the callback function for the ADC Interrupt Flag (ADIF).
adc_result_t ADC_ChannelSelectAndConvert (adc_channel_t channel)
Starts the conversion and retrieves the result of one conversion on the selected channel.
uint8_t ADC_ResolutionGet (void)
Returns the resolution of the ADC module.
void ADC_AutoTriggerEnable (void)
Sets the ADC Auto Trigger Enable (ADATE) bit to ‘1’.
void ADC_AutoTriggerDisable (void)
Sets the ADC Auto Trigger Enable (ADATE) bit to ‘0’.
void ADC_AutoTriggerSourceSet (adc_trigger_source_t triggerSource)
Sets the auto-trigger source.
bool ADC_IsConversionDoneInterruptFlagSet (void)
Checks the ADC Interrupt Flag (ADIF) status.
void ADC_ConversionDoneInterruptFlagClear (void)
Clears the ADC Interrupt (ADIF) flag.
void ADC_DigitalInputDisable (uint8_t disableValue)
Disables the digital input buffer on the corresponding ADC pin.
void ADC_Tasks (void)
Implements the Tasks routine for the polling implementation.
Variables
static void(* ADC_ConversionDoneCallback )(void) = NULL
Detailed Description
This file contains the API implementations for the ADC driver.
ADC Generated Driver File
Variable Documentation
ADC_ConversionDoneCallback
void(* ADC_ConversionDoneCallback) (void) = NULL[static]