3.1.1.3 10-bit ADC with HW CVD
10-bit Analog-to-Digital-Converter with Hardware Capacitive Voltage Detection (CVD)
3.1.1.3.1 Introduction
This ADC module allows conversion of an analog input signal 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. This ADC module also feature an auto-conversion trigger which allows periodic ADC measurements without software intervention and a hardware capacitive module divider (CVD) which can perform a relative capacitance measurement on any ADC channel using the internal ADC sample and hold capacitance as a reference.
3.1.1.3.2 Supported Device Families
PIC12/16LF155x | PIC16LF156x |
3.1.1.3.3 Required Header Files:
#include "mcc_generated_files/adc/adc.h"
3.1.1.3.4 Module Documentation
ADC
This file contains the API prototypes and data types for the Analog-to-Digital Converter ADC driver.
Module description
This file contains the API prototypes and data types for the Analog-to-Digital Converter ADC driver.
Typedefs
typedef uint16_t adc_result_t
Used for the result of the Analog-to-Digital (A/D) conversion.
Definitions
#define ADC_Initialize ADC_Initialize
Defines the Custom Name for the ADC_Initialize API.
#define ADC1_StartConversion ADC1_StartConversion
Defines the Custom Name for the ADC1_StartConversion API.
#define ADC2_StartConversion ADC2_StartConversion
Defines the Custom Name for the ADC2_StartConversion API.
#define ADC_StartSyncConversion ADC_StartSyncConversion
Defines the Custom Name for the ADC_StartSyncConversion API.
#define ADC1_IsConversionDone ADC1_IsConversionDone
Defines the Custom Name for the ADC1_IsConversionDone API.
#define ADC2_IsConversionDone ADC2_IsConversionDone
Defines the Custom Name for the ADC2_IsConversionDone API.
#define ADC_IsSyncConversionDone ADC_IsSyncConversionDone
Defines the Custom Name for the ADC_IsSyncConversionDone API.
#define ADC1_GetConversionResult ADC1_GetConversionResult
Defines the Custom Name for the ADC1_GetConversionResult API.
#define ADC2_GetConversionResult ADC2_GetConversionResult
Defines the Custom Name for the ADC2_GetConversionResult API.
#define ADC_GetSyncConversionResult ADC_GetSyncConversionResult
Defines the Custom Name for the ADC_GetSyncConversionResult API.
#define ADC1_GetConversion ADC1_GetConversion
Defines the Custom Name for the ADC1_GetConversion API.
#define ADC2_GetConversion ADC2_GetConversion
Defines the Custom Name for the ADC2_GetConversion API.
#define ADC_GetSyncConversion ADC_GetSyncConversion
Defines the Custom Name for the ADC_GetSyncConversion API.
#define ADC_TemperatureAcquisitionDelay ADC_TemperatureAcquisitionDelay
Defines the Custom Name for the ADC_TemperatureAcquisitionDelay API.
#define ADC1_EnableDoubleSampling ADC1_EnableDoubleSampling
Defines the Custom Name for the ADC1_EnableDoubleSampling API.
#define ADC2_EnableDoubleSampling ADC2_EnableDoubleSampling
Defines the Custom Name for the ADC2_EnableDoubleSampling API.
#define ADC1_GetDoubleConversionResult ADC1_GetDoubleConversionResult
Defines the Custom Name for the ADC1_GetDoubleConversionResult API.
#define ADC2_GetDoubleConversionResult ADC2_GetDoubleConversionResult
Defines the Custom Name for the ADC2_GetDoubleConversionResult API.
#define ADC1_GetStageStatus ADC1_GetStageStatus
Defines the Custom Name for the ADC1_GetStageStatus API.
#define ADC2_GetStageStatus ADC2_GetStageStatus
Defines the Custom Name for the ADC2_GetStageStatus API.
#define ADC1_GetConversionStatus ADC1_GetConversionStatus
Defines the Custom Name for the ADC1_GetConversionStatus API.
#define ADC2_GetConversionStatus ADC2_GetConversionStatus
Defines the Custom Name for the ADC2_GetConversionStatus API.
#define ADC1_SetPrechargeTime ADC1_SetPrechargeTime
Defines the Custom Name for the ADC1_SetPrechargeTime API.
#define ADC2_SetPrechargeTime ADC2_SetPrechargeTime
Defines the Custom Name for the ADC2_SetPrechargeTime API.
#define ADC1_SetAcquisitionTime ADC1_SetAcquisitionTime
Defines the Custom Name for the ADC1_SetAcquisitionTime API.
#define ADC2_SetAcquisitionTime ADC2_SetAcquisitionTime
Defines the Custom Name for the ADC2_SetAcquisitionTime API.
#define ADC1_SetInterruptHandler ADC1_SetInterruptHandler
Defines the Custom Name for the ADC1_SetInterruptHandler API.
#define ADC2_SetInterruptHandler ADC2_SetInterruptHandler
Defines the Custom Name for the ADC2_SetInterruptHandler API.
Enumerations
enum adc1_channel_t { channel_VREFH_adc1 = 0x3b, channel_Temp_adc1 = 0x3d, channel_FVR_adc1 = 0x3f }
Contains the available ADC1 channels.
enum adc2_channel_t { channel_VREFH_adc2 = 0x2b, channel_Temp_adc2 = 0x2d, channel_FVR_adc2 = 0x2f }
Contains the available ADC2 channels.
Functions
void ADC_Initialize (void)
Initializes the ADC module. This routine is called before any other ADC routine.
void ADC1_StartConversion (adc1_channel_t channel)
Allows the selection of an ADC1 channel for conversion. This routine starts the A/D conversion.
void ADC2_StartConversion (adc2_channel_t channel)
Allows the selection of an ADC2 channel for conversion. This routine starts the A/D conversion.
void ADC_StartSyncConversion (adc1_channel_t channelADC1, adc2_channel_t channelADC2)
Allows the selection of two channels for synchronized conversion. This routine starts the A/D synchronized conversion.
bool ADC1_IsConversionDone (void)
Checks if the ongoing ADC1 conversion is complete.
bool ADC2_IsConversionDone (void)
Checks if the ongoing ADC2 conversion is complete.
bool ADC_IsSyncConversionDone (void)
Checks if the ongoing synchronized conversion is complete.
adc_result_t ADC1_GetConversionResult (void)
Retrieves the result of the latest ADC1 conversion.
adc_result_t ADC2_GetConversionResult (void)
Retrieves the result of the latest ADC2 conversion.
adc_sync_result_t ADC_GetSyncConversionResult (void)
Retrieves the result of the latest synchronized conversion.
adc_result_t ADC1_GetConversion (adc1_channel_t channel)
Retrieves the result of a single ADC1 conversion on any given channel.
adc_result_t ADC2_GetConversion (adc2_channel_t channel)
Retrieves the result of a single ADC2 conversion on any given channel.
adc_sync_result_t ADC_GetSyncConversion (adc1_channel_t adc1Channel, adc2_channel_t adc2Channel)
Retrieves the result of a synchronized conversion on any given channel.
void ADC_TemperatureAcquisitionDelay (void)
Adds the acquisition delay for the temperature sensor.
void ADC1_EnableDoubleSampling (void)
This routine is used to enable a double conversion on the same channel on the ADC1. The converted result result will be stored in two different 10-bit result registers.
void ADC2_EnableDoubleSampling (void)
This routine is used to enable a double conversion on the same channel on the ADC2. The converted result result will be stored in two different 10-bit result registers.
adc1_double_result_t ADC1_GetDoubleConversionResult (void)
Returns the ADC1 double conversion result. This routine is used to get the analog-to-digital converted values. The converted result will be stored in two different 10-bit result registers.
adc2_double_result_t ADC2_GetDoubleConversionResult (void)
Returns the ADC2 double conversion result. This routine is used to get the analog-to-digital converted values. The converted result will be stored in two different 10-bit result registers.
uint8_t ADC1_GetStageStatus (void)
Returns the ADC1 conversion stage.
uint8_t ADC2_GetStageStatus (void)
Returns the ADC2 conversion stage.
uint8_t ADC1_GetConversionStatus (void)
Returns the ADC1 conversion status.
uint8_t ADC2_GetConversionStatus (void)
Returns the ADC2 conversion status.
void ADC1_SetPrechargeTime (uint8_t prechargeTime)
Loads the ADC1 Precharge register by the 8-bit value sent as argument. This routine sets the desired precharge time to charge.
void ADC2_SetPrechargeTime (uint8_t prechargeTime)
Loads the ADC2 Precharge register by the 8-bit value sent as argument. This routine sets the desired precharge time to charge.
void ADC1_SetAcquisitionTime (uint8_t acquisitionValue)
Loads the ADC1 Acquisition time by the 8-bit value sent as argument. This routine sets the desired Acquisition time.
void ADC2_SetAcquisitionTime (uint8_t acquisitionValue)
Loads the ADC2 Acquisition time by the 8-bit value sent as argument. This routine sets the desired Acquisition time.
void ADC1_ISR (void)
Implements the ADC interrupt (AD1I) service routine for the interrupt-driven implementations.
void ADC1_SetInterruptHandler (void(*InterruptHandler)(void))
Sets the callback for the ADC interrupt (AD1I).
void ADC2_ISR (void)
Implements the ADC interrupt (AD2I) service routine for the interrupt-driven implementations.
void ADC2_SetInterruptHandler (void(*InterruptHandler)(void))
Sets the callback for the ADC interrupt (AD2I).
Definition Documentation
ADC1_EnableDoubleSampling
#define ADC1_EnableDoubleSampling ADC1_EnableDoubleSampling
Defines the Custom Name for the ADC1_EnableDoubleSampling API.
ADC1_GetConversion
#define ADC1_GetConversion ADC1_GetConversion
Defines the Custom Name for the ADC1_GetConversion API.
ADC1_GetConversionResult
#define ADC1_GetConversionResult ADC1_GetConversionResult
Defines the Custom Name for the ADC1_GetConversionResult API.
ADC1_GetConversionStatus
#define ADC1_GetConversionStatus ADC1_GetConversionStatus
Defines the Custom Name for the ADC1_GetConversionStatus API.
ADC1_GetDoubleConversionResult
#define ADC1_GetDoubleConversionResult ADC1_GetDoubleConversionResult
Defines the Custom Name for the ADC1_GetDoubleConversionResult API.
ADC1_GetStageStatus
#define ADC1_GetStageStatus ADC1_GetStageStatus
Defines the Custom Name for the ADC1_GetStageStatus API.
ADC1_IsConversionDone
#define ADC1_IsConversionDone ADC1_IsConversionDone
Defines the Custom Name for the ADC1_IsConversionDone API.
ADC1_SetAcquisitionTime
#define ADC1_SetAcquisitionTime ADC1_SetAcquisitionTime
Defines the Custom Name for the ADC1_SetAcquisitionTime API.
ADC1_SetInterruptHandler
#define ADC1_SetInterruptHandler ADC1_SetInterruptHandler
Defines the Custom Name for the ADC1_SetInterruptHandler API.
ADC1_SetPrechargeTime
#define ADC1_SetPrechargeTime ADC1_SetPrechargeTime
Defines the Custom Name for the ADC1_SetPrechargeTime API.
ADC1_StartConversion
#define ADC1_StartConversion ADC1_StartConversion
Defines the Custom Name for the ADC1_StartConversion API.
ADC2_EnableDoubleSampling
#define ADC2_EnableDoubleSampling ADC2_EnableDoubleSampling
Defines the Custom Name for the ADC2_EnableDoubleSampling API.
ADC2_GetConversion
#define ADC2_GetConversion ADC2_GetConversion
Defines the Custom Name for the ADC2_GetConversion API.
ADC2_GetConversionResult
#define ADC2_GetConversionResult ADC2_GetConversionResult
Defines the Custom Name for the ADC2_GetConversionResult API.
ADC2_GetConversionStatus
#define ADC2_GetConversionStatus ADC2_GetConversionStatus
Defines the Custom Name for the ADC2_GetConversionStatus API.
ADC2_GetDoubleConversionResult
#define ADC2_GetDoubleConversionResult ADC2_GetDoubleConversionResult
Defines the Custom Name for the ADC2_GetDoubleConversionResult API.
ADC2_GetStageStatus
#define ADC2_GetStageStatus ADC2_GetStageStatus
Defines the Custom Name for the ADC2_GetStageStatus API.
ADC2_IsConversionDone
#define ADC2_IsConversionDone ADC2_IsConversionDone
Defines the Custom Name for the ADC2_IsConversionDone API.
ADC2_SetAcquisitionTime
#define ADC2_SetAcquisitionTime ADC2_SetAcquisitionTime
Defines the Custom Name for the ADC2_SetAcquisitionTime API.
ADC2_SetInterruptHandler
#define ADC2_SetInterruptHandler ADC2_SetInterruptHandler
Defines the Custom Name for the ADC2_SetInterruptHandler API.
ADC2_SetPrechargeTime
#define ADC2_SetPrechargeTime ADC2_SetPrechargeTime
Defines the Custom Name for the ADC2_SetPrechargeTime API.
ADC2_StartConversion
#define ADC2_StartConversion ADC2_StartConversion
Defines the Custom Name for the ADC2_StartConversion API.
ADC_GetSyncConversion
#define ADC_GetSyncConversion ADC_GetSyncConversion
Defines the Custom Name for the ADC_GetSyncConversion API.
ADC_GetSyncConversionResult
#define ADC_GetSyncConversionResult ADC_GetSyncConversionResult
Defines the Custom Name for the ADC_GetSyncConversionResult API.
ADC_Initialize
#define ADC_Initialize ADC_Initialize
Defines the Custom Name for the ADC_Initialize API.
ADC_IsSyncConversionDone
#define ADC_IsSyncConversionDone ADC_IsSyncConversionDone
Defines the Custom Name for the ADC_IsSyncConversionDone API.
ADC_StartSyncConversion
#define ADC_StartSyncConversion ADC_StartSyncConversion
Defines the Custom Name for the ADC_StartSyncConversion 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
ADC1_EnableDoubleSampling()
void ADC1_EnableDoubleSampling (void )
This routine is used to enable a double conversion on the same channel on the ADC1. The converted result result will be stored in two different 10-bit result registers.
None. |
None. |
ADC1_GetConversion()
adc_result_t ADC1_GetConversion (adc1_channel_t channel)
Retrieves the result of a single ADC1 conversion on any given channel.
channel |
- Analog channel number on which the ADC1 conversion will be applied. Refer to adc1_channel_t for the available channels |
The result of the ADC1 conversion. Refer to the adc_result_t |
ADC1_GetConversionResult()
adc_result_t ADC1_GetConversionResult (void )
Retrieves the result of the latest ADC1 conversion.
None. |
The result of the ADC1 conversion. Refer to the adc_result_t |
ADC1_GetConversionStatus()
uint8_t ADC1_GetConversionStatus (void )
Returns the ADC1 conversion status.
None. |
The result of the ADC1 conversion status |
ADC1_GetDoubleConversionResult()
adc1_double_result_t ADC1_GetDoubleConversionResult (void )
Returns the ADC1 double conversion result. This routine is used to get the analog-to-digital converted values. The converted result will be stored in two different 10-bit result registers.
None. |
The result of the ADC1 double conversion. Refer to the adc1_double_result_t |
ADC1_GetStageStatus()
uint8_t ADC1_GetStageStatus (void )
Returns the ADC1 conversion stage.
None. |
The result of the ADC1 conversion stage |
ADC1_IsConversionDone()
bool ADC1_IsConversionDone (void )
Checks if the ongoing ADC1 conversion is complete.
None. |
True |
- A/D conversion is complete |
False |
- A/D conversion is ongoing |
ADC1_ISR()
void ADC1_ISR (void )
Implements the ADC interrupt (AD1I) service routine for the interrupt-driven implementations.
None. |
None. |
ADC1_SetAcquisitionTime()
void ADC1_SetAcquisitionTime (uint8_t acquisitionValue)
Loads the ADC1 Acquisition time by the 8-bit value sent as argument. This routine sets the desired Acquisition time.
acquisitionValue |
- 8-bit value to be set in the Acquisition register |
None. |
ADC1_SetInterruptHandler()
void ADC1_SetInterruptHandler (void(*)(void) InterruptHandler)
Sets the callback for the ADC interrupt (AD1I).
InterruptHandler |
- Callback function to be called on the interrupt event |
None. |
ADC1_SetPrechargeTime()
void ADC1_SetPrechargeTime (uint8_t prechargeTime)
Loads the ADC1 Precharge register by the 8-bit value sent as argument. This routine sets the desired precharge time to charge.
prechargeTime |
- 8-bit value to be set in the Precharge register |
None. |
ADC1_StartConversion()
void ADC1_StartConversion (adc1_channel_t channel)
Allows the selection of an ADC1 channel for conversion. This routine starts the A/D conversion.
channel |
- Analog channel number on which the A/D conversion will be applied. Refer to adc1_channel_t for the available channels |
None. |
ADC2_EnableDoubleSampling()
void ADC2_EnableDoubleSampling (void )
This routine is used to enable a double conversion on the same channel on the ADC2. The converted result result will be stored in two different 10-bit result registers.
None. |
None. |
ADC2_GetConversion()
adc_result_t ADC2_GetConversion (adc2_channel_t channel)
Retrieves the result of a single ADC2 conversion on any given channel.
channel |
- Analog channel number on which the ADC2 conversion will be applied. Refer to adc2_channel_t for the available channels |
The result of the ADC2 conversion. Refer to the adc_result_t |
ADC2_GetConversionResult()
adc_result_t ADC2_GetConversionResult (void )
Retrieves the result of the latest ADC2 conversion.
None. |
The result of the ADC2 conversion. Refer to the adc_result_t |
ADC2_GetConversionStatus()
uint8_t ADC2_GetConversionStatus (void )
Returns the ADC2 conversion status.
None. |
The result of the ADC2 conversion status |
ADC2_GetDoubleConversionResult()
adc2_double_result_t ADC2_GetDoubleConversionResult (void )
Returns the ADC2 double conversion result. This routine is used to get the analog-to-digital converted values. The converted result will be stored in two different 10-bit result registers.
None. |
The result of the ADC2 double conversion. Refer to the adc2_double_result_t |
ADC2_GetStageStatus()
uint8_t ADC2_GetStageStatus (void )
Returns the ADC2 conversion stage.
None. |
The result of ADC2 conversion stage |
ADC2_IsConversionDone()
bool ADC2_IsConversionDone (void )
Checks if the ongoing ADC2 conversion is complete.
None. |
True |
- A/D conversion is complete |
False |
- A/D conversion is ongoing |
ADC2_ISR()
void ADC2_ISR (void )
Implements the ADC interrupt (AD2I) service routine for the interrupt-driven implementations.
None. |
None. |
ADC2_SetAcquisitionTime()
void ADC2_SetAcquisitionTime (uint8_t acquisitionValue)
Loads the ADC2 Acquisition time by the 8-bit value sent as argument. This routine sets the desired Acquisition time.
acquisitionValue |
- 8-bit value to be set in the Acquisition register |
None. |
ADC2_SetInterruptHandler()
void ADC2_SetInterruptHandler (void(*)(void) InterruptHandler)
Sets the callback for the ADC interrupt (AD2I).
InterruptHandler |
- Callback function to be called on the interrupt event |
None. |
ADC2_SetPrechargeTime()
void ADC2_SetPrechargeTime (uint8_t prechargeTime)
Loads the ADC2 Precharge register by the 8-bit value sent as argument. This routine sets the desired precharge time to charge.
prechargeTime |
- 8-bit value to be set in the Precharge register |
None. |
ADC2_StartConversion()
void ADC2_StartConversion (adc2_channel_t channel)
Allows the selection of an ADC2 channel for conversion. This routine starts the A/D conversion.
channel |
- Analog channel number on which the A/D conversion will be applied. Refer to adc2_channel_t for the available channels |
None. |
ADC_GetSyncConversion()
adc_sync_result_t ADC_GetSyncConversion (adc1_channel_t adc1Channel, adc2_channel_t adc2Channel)
Retrieves the result of a synchronized conversion on any given channel.
adc1Channel |
- Analog channel number on which the ADC1 conversion will be applied. Refer to adc1_channel_t for the available channels |
adc2Channel |
- Analog channel number on which the ADC2 conversion will be applied. Refer to adc2_channel_t for the available channels |
The result of synchronized conversion. Refer to the adc_sync_result_t |
ADC_GetSyncConversionResult()
adc_sync_result_t ADC_GetSyncConversionResult (void )
Retrieves the result of the latest synchronized conversion.
None. |
The result of the synchronized conversion. Refer to the adc_sync_result_t |
ADC_Initialize()
void ADC_Initialize (void )
Initializes the ADC module. This routine is called before any other ADC routine.
None. |
None. |
ADC_IsSyncConversionDone()
bool ADC_IsSyncConversionDone (void )
Checks if the ongoing synchronized conversion is complete.
None. |
True |
- synchronized conversion is complete |
False |
- synchronized conversion is ongoing |
ADC_StartSyncConversion()
void ADC_StartSyncConversion (adc1_channel_t channelADC1, adc2_channel_t channelADC2)
Allows the selection of two channels for synchronized conversion. This routine starts the A/D synchronized conversion.
channelADC1 |
- ADC1 analog channel number on which the A/D conversion will be applied. Refer to adc1_channel_t for the available channels |
channelADC2 |
- ADC2 analog channel number on which the A/D conversion will be applied. Refer to adc2_channel_t for the available channels |
None. |
ADC_TemperatureAcquisitionDelay()
void ADC_TemperatureAcquisitionDelay (void )
Adds the acquisition delay for the temperature sensor.
This function is called when a temperature sensor is used. |
None. |
None. |
Enumeration Type Documentation
adc1_channel_t
enum adc1_channel_t
Contains the available ADC1 channels.
channel_VREFH_adc1 | |
channel_Temp_adc1 | |
channel_FVR_adc1 |
adc2_channel_t
enum adc2_channel_t
Contains the available ADC2 channels.
channel_VREFH_adc2 | |
channel_Temp_adc2 | |
channel_FVR_adc2 |
3.1.1.3.5 Class Documentation
adc1_double_result_t Struct Reference
#include <adc.h>
Public Attributes
Member Data Documentation
adc1Result1
adc_result_t adc1Result1
adc1Result2
adc_result_t adc1Result2
adc2_double_result_t Struct Reference
#include <adc.h>
Public Attributes
Member Data Documentation
adc2Result1
adc_result_t adc2Result1
adc2Result2
adc_result_t adc2Result2
adc_sync_result_t Struct Reference
#include <adc.h>
Public Attributes
Member Data Documentation
adc1Result
adc_result_t adc1Result
adc2Result
adc_result_t adc2Result
Used Struct Reference
Detailed Description
result for a synchronized ADC conversion value.
result for a Double ADC1 conversion value.
result for a Double ADC2 conversion value.
The documentation for this struct was generated from the following file:
source/
3.1.1.3.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
static void ADC_DefaultInterruptHandler (void)
void ADC_Initialize (void)
Initializes the ADC module. This routine is called before any other ADC routine.
void ADC1_StartConversion (adc1_channel_t channel)
Allows the selection of an ADC1 channel for conversion. This routine starts the A/D conversion.
void ADC2_StartConversion (adc2_channel_t channel)
Allows the selection of an ADC2 channel for conversion. This routine starts the A/D conversion.
void ADC_StartSyncConversion (adc1_channel_t channelADC1, adc2_channel_t channelADC2)
Allows the selection of two channels for synchronized conversion. This routine starts the A/D synchronized conversion.
bool ADC1_IsConversionDone (void)
Checks if the ongoing ADC1 conversion is complete.
bool ADC2_IsConversionDone (void)
Checks if the ongoing ADC2 conversion is complete.
bool ADC_IsSyncConversionDone (void)
Checks if the ongoing synchronized conversion is complete.
adc_result_t ADC1_GetConversionResult (void)
Retrieves the result of the latest ADC1 conversion.
adc_result_t ADC2_GetConversionResult (void)
Retrieves the result of the latest ADC2 conversion.
adc_sync_result_t ADC_GetSyncConversionResult (void)
Retrieves the result of the latest synchronized conversion.
adc_result_t ADC1_GetConversion (adc1_channel_t channel)
Retrieves the result of a single ADC1 conversion on any given channel.
adc_result_t ADC2_GetConversion (adc2_channel_t channel)
Retrieves the result of a single ADC2 conversion on any given channel.
adc_sync_result_t ADC_GetSyncConversion (adc1_channel_t adc1Channel, adc2_channel_t adc2Channel)
Retrieves the result of a synchronized conversion on any given channel.
void ADC_TemperatureAcquisitionDelay (void)
Adds the acquisition delay for the temperature sensor.
void ADC1_EnableDoubleSampling (void)
This routine is used to enable a double conversion on the same channel on the ADC1. The converted result result will be stored in two different 10-bit result registers.
void ADC2_EnableDoubleSampling (void)
This routine is used to enable a double conversion on the same channel on the ADC2. The converted result result will be stored in two different 10-bit result registers.
adc1_double_result_t ADC1_GetDoubleConversionResult (void)
Returns the ADC1 double conversion result. This routine is used to get the analog-to-digital converted values. The converted result will be stored in two different 10-bit result registers.
adc2_double_result_t ADC2_GetDoubleConversionResult (void)
Returns the ADC2 double conversion result. This routine is used to get the analog-to-digital converted values. The converted result will be stored in two different 10-bit result registers.
uint8_t ADC1_GetStageStatus (void)
Returns the ADC1 conversion stage.
uint8_t ADC2_GetStageStatus (void)
Returns the ADC2 conversion stage.
uint8_t ADC1_GetConversionStatus (void)
Returns the ADC1 conversion status.
uint8_t ADC2_GetConversionStatus (void)
Returns the ADC2 conversion status.
void ADC1_SetPrechargeTime (uint8_t prechargeTime)
Loads the ADC1 Precharge register by the 8-bit value sent as argument. This routine sets the desired precharge time to charge.
void ADC2_SetPrechargeTime (uint8_t prechargeTime)
Loads the ADC2 Precharge register by the 8-bit value sent as argument. This routine sets the desired precharge time to charge.
void ADC1_SetAcquisitionTime (uint8_t acquisitionValue)
Loads the ADC1 Acquisition time by the 8-bit value sent as argument. This routine sets the desired Acquisition time.
void ADC2_SetAcquisitionTime (uint8_t acquisitionValue)
Loads the ADC2 Acquisition time by the 8-bit value sent as argument. This routine sets the desired Acquisition time.
void ADC1_ISR (void)
Implements the ADC interrupt (AD1I) service routine for the interrupt-driven implementations.
void ADC1_SetInterruptHandler (void(*InterruptHandler)(void))
Sets the callback for the ADC interrupt (AD1I).
void ADC2_ISR (void)
Implements the ADC interrupt (AD2I) service routine for the interrupt-driven implementations.
void ADC2_SetInterruptHandler (void(*InterruptHandler)(void))
Sets the callback for the ADC interrupt (AD2I).
Macros
#define ACQ_US_DELAY 5
Variables
void(* ADC1_InterruptHandler )(void)
void(* ADC2_InterruptHandler )(void)
Detailed Description
This file contains the API implementations for the ADC module.
ADC Generated Driver File
Function Documentation
ADC_DefaultInterruptHandler()
static void ADC_DefaultInterruptHandler (void )[static]
Macro Definition Documentation
ACQ_US_DELAY
#define ACQ_US_DELAY 5
Variable Documentation
ADC1_InterruptHandler
void(* ADC1_InterruptHandler) (void)
ADC2_InterruptHandler
void(* ADC2_InterruptHandler) (void)
source/adc.h File Reference
#include <xc.h> #include <stdint.h> #include <stdbool.h>
Data structures
struct adc_sync_result_t
struct adc1_double_result_t
struct adc2_double_result_t
Functions
void ADC_Initialize (void)
Initializes the ADC module. This routine is called before any other ADC routine.
void ADC1_StartConversion (adc1_channel_t channel)
Allows the selection of an ADC1 channel for conversion. This routine starts the A/D conversion.
void ADC2_StartConversion (adc2_channel_t channel)
Allows the selection of an ADC2 channel for conversion. This routine starts the A/D conversion.
void ADC_StartSyncConversion (adc1_channel_t channelADC1, adc2_channel_t channelADC2)
Allows the selection of two channels for synchronized conversion. This routine starts the A/D synchronized conversion.
bool ADC1_IsConversionDone (void)
Checks if the ongoing ADC1 conversion is complete.
bool ADC2_IsConversionDone (void)
Checks if the ongoing ADC2 conversion is complete.
bool ADC_IsSyncConversionDone (void)
Checks if the ongoing synchronized conversion is complete.
adc_result_t ADC1_GetConversionResult (void)
Retrieves the result of the latest ADC1 conversion.
adc_result_t ADC2_GetConversionResult (void)
Retrieves the result of the latest ADC2 conversion.
adc_sync_result_t ADC_GetSyncConversionResult (void)
Retrieves the result of the latest synchronized conversion.
adc_result_t ADC1_GetConversion (adc1_channel_t channel)
Retrieves the result of a single ADC1 conversion on any given channel.
adc_result_t ADC2_GetConversion (adc2_channel_t channel)
Retrieves the result of a single ADC2 conversion on any given channel.
adc_sync_result_t ADC_GetSyncConversion (adc1_channel_t adc1Channel, adc2_channel_t adc2Channel)
Retrieves the result of a synchronized conversion on any given channel.
void ADC_TemperatureAcquisitionDelay (void)
Adds the acquisition delay for the temperature sensor.
void ADC1_EnableDoubleSampling (void)
This routine is used to enable a double conversion on the same channel on the ADC1. The converted result result will be stored in two different 10-bit result registers.
void ADC2_EnableDoubleSampling (void)
This routine is used to enable a double conversion on the same channel on the ADC2. The converted result result will be stored in two different 10-bit result registers.
adc1_double_result_t ADC1_GetDoubleConversionResult (void)
Returns the ADC1 double conversion result. This routine is used to get the analog-to-digital converted values. The converted result will be stored in two different 10-bit result registers.
adc2_double_result_t ADC2_GetDoubleConversionResult (void)
Returns the ADC2 double conversion result. This routine is used to get the analog-to-digital converted values. The converted result will be stored in two different 10-bit result registers.
uint8_t ADC1_GetStageStatus (void)
Returns the ADC1 conversion stage.
uint8_t ADC2_GetStageStatus (void)
Returns the ADC2 conversion stage.
uint8_t ADC1_GetConversionStatus (void)
Returns the ADC1 conversion status.
uint8_t ADC2_GetConversionStatus (void)
Returns the ADC2 conversion status.
void ADC1_SetPrechargeTime (uint8_t prechargeTime)
Loads the ADC1 Precharge register by the 8-bit value sent as argument. This routine sets the desired precharge time to charge.
void ADC2_SetPrechargeTime (uint8_t prechargeTime)
Loads the ADC2 Precharge register by the 8-bit value sent as argument. This routine sets the desired precharge time to charge.
void ADC1_SetAcquisitionTime (uint8_t acquisitionValue)
Loads the ADC1 Acquisition time by the 8-bit value sent as argument. This routine sets the desired Acquisition time.
void ADC2_SetAcquisitionTime (uint8_t acquisitionValue)
Loads the ADC2 Acquisition time by the 8-bit value sent as argument. This routine sets the desired Acquisition time.
void ADC1_ISR (void)
Implements the ADC interrupt (AD1I) service routine for the interrupt-driven implementations.
void ADC1_SetInterruptHandler (void(*InterruptHandler)(void))
Sets the callback for the ADC interrupt (AD1I).
void ADC2_ISR (void)
Implements the ADC interrupt (AD2I) service routine for the interrupt-driven implementations.
void ADC2_SetInterruptHandler (void(*InterruptHandler)(void))
Sets the callback for the ADC interrupt (AD2I).
Macros
#define ADC_Initialize ADC_Initialize
Defines the Custom Name for the ADC_Initialize API.
#define ADC1_StartConversion ADC1_StartConversion
Defines the Custom Name for the ADC1_StartConversion API.
#define ADC2_StartConversion ADC2_StartConversion
Defines the Custom Name for the ADC2_StartConversion API.
#define ADC_StartSyncConversion ADC_StartSyncConversion
Defines the Custom Name for the ADC_StartSyncConversion API.
#define ADC1_IsConversionDone ADC1_IsConversionDone
Defines the Custom Name for the ADC1_IsConversionDone API.
#define ADC2_IsConversionDone ADC2_IsConversionDone
Defines the Custom Name for the ADC2_IsConversionDone API.
#define ADC_IsSyncConversionDone ADC_IsSyncConversionDone
Defines the Custom Name for the ADC_IsSyncConversionDone API.
#define ADC1_GetConversionResult ADC1_GetConversionResult
Defines the Custom Name for the ADC1_GetConversionResult API.
#define ADC2_GetConversionResult ADC2_GetConversionResult
Defines the Custom Name for the ADC2_GetConversionResult API.
#define ADC_GetSyncConversionResult ADC_GetSyncConversionResult
Defines the Custom Name for the ADC_GetSyncConversionResult API.
#define ADC1_GetConversion ADC1_GetConversion
Defines the Custom Name for the ADC1_GetConversion API.
#define ADC2_GetConversion ADC2_GetConversion
Defines the Custom Name for the ADC2_GetConversion API.
#define ADC_GetSyncConversion ADC_GetSyncConversion
Defines the Custom Name for the ADC_GetSyncConversion API.
#define ADC_TemperatureAcquisitionDelay ADC_TemperatureAcquisitionDelay
Defines the Custom Name for the ADC_TemperatureAcquisitionDelay API.
#define ADC1_EnableDoubleSampling ADC1_EnableDoubleSampling
Defines the Custom Name for the ADC1_EnableDoubleSampling API.
#define ADC2_EnableDoubleSampling ADC2_EnableDoubleSampling
Defines the Custom Name for the ADC2_EnableDoubleSampling API.
#define ADC1_GetDoubleConversionResult ADC1_GetDoubleConversionResult
Defines the Custom Name for the ADC1_GetDoubleConversionResult API.
#define ADC2_GetDoubleConversionResult ADC2_GetDoubleConversionResult
Defines the Custom Name for the ADC2_GetDoubleConversionResult API.
#define ADC1_GetStageStatus ADC1_GetStageStatus
Defines the Custom Name for the ADC1_GetStageStatus API.
#define ADC2_GetStageStatus ADC2_GetStageStatus
Defines the Custom Name for the ADC2_GetStageStatus API.
#define ADC1_GetConversionStatus ADC1_GetConversionStatus
Defines the Custom Name for the ADC1_GetConversionStatus API.
#define ADC2_GetConversionStatus ADC2_GetConversionStatus
Defines the Custom Name for the ADC2_GetConversionStatus API.
#define ADC1_SetPrechargeTime ADC1_SetPrechargeTime
Defines the Custom Name for the ADC1_SetPrechargeTime API.
#define ADC2_SetPrechargeTime ADC2_SetPrechargeTime
Defines the Custom Name for the ADC2_SetPrechargeTime API.
#define ADC1_SetAcquisitionTime ADC1_SetAcquisitionTime
Defines the Custom Name for the ADC1_SetAcquisitionTime API.
#define ADC2_SetAcquisitionTime ADC2_SetAcquisitionTime
Defines the Custom Name for the ADC2_SetAcquisitionTime API.
#define ADC1_SetInterruptHandler ADC1_SetInterruptHandler
Defines the Custom Name for the ADC1_SetInterruptHandler API.
#define ADC2_SetInterruptHandler ADC2_SetInterruptHandler
Defines the Custom Name for the ADC2_SetInterruptHandler API.
Typedefs
typedef uint16_t adc_result_t
Used for the result of the Analog-to-Digital (A/D) conversion.
Enumerations
enum adc1_channel_t { channel_VREFH_adc1 = 0x3b, channel_Temp_adc1 = 0x3d, channel_FVR_adc1 = 0x3f }
Contains the available ADC1 channels.
enum adc2_channel_t { channel_VREFH_adc2 = 0x2b, channel_Temp_adc2 = 0x2d, channel_FVR_adc2 = 0x2f }
Contains the available ADC2 channels.
Detailed Description
ADC Generated Driver API Header File