3.1.1.2 10-bit ADC with Auto Trigger
10-bit Analog-to-Digital Converter with Auto-conversion Trigger
3.1.1.2.1 Introduction
This ADC allows conversion of an analog input signal to a 10-bit binary representation of that signal. This device uses analog inputs, which are multiplexed into a single sample and hold circuit. The output of the sample and hold is connected to the input of the converter. The converter generates a 10-bit binary result via successive approximation and stores the conversion result into the ADC result registers. This ADC module also features an auto-conversion trigger which allows periodic ADC measurements without software intervention.
3.1.1.2.2 Supported Device Families
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3.1.1.2.3 Required Header Files:
#include "mcc_generated_files/adc/adc.h"
3.1.1.2.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.
Typedefs
typedef uint16_t adc_result_t
Used for the result of the Analog-to-Digital (A/D) conversion.
Enumerations
enum adc_channel_t { channel_AVSS = 0x3c, channel_Temp = 0x3d, channel_DAC1 = 0x3e, channel_FVR = 0x3f }
Contains the available ADC channels.
Functions
void ADC_Initialize (void)
Initializes the ADC module. This routine is called before any other ADC routine.
void ADC_SelectChannel (adc_channel_t channel)
Selects the channel for the A/D conversion.
void ADC_StartConversion (void)
Starts A/D conversion.
bool ADC_IsConversionDone (void)
Checks if ongoing A/D conversion is complete.
adc_result_t ADC_GetConversionResult (void)
Retrieves the result of the latest A/D conversion.
adc_result_t ADC_GetConversion (adc_channel_t channel)
Retrieves the result of a single A/D conversion on any given channel.
void ADC_TemperatureAcquisitionDelay (void)
Adds the acquisition delay for the temperature sensor.
void ADC_ISR (void)
Implements the ADC Interrupt(ADI) service routine for the interrupt-driven implementations.
void ADC_SetInterruptHandler (void(*InterruptHandler)(void))
Sets the callback for the ADC Interrupt(ADI).
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.
channel |
- Analog channel number on which the A/D conversion will be applied. Refer to adc_channel_t for the available channels. |
The result of 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.
None. |
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.
Section: ADC Module APIs
None. |
None. |
Section: ADC Module APIs
ADC_IsConversionDone()
bool ADC_IsConversionDone (void )
Checks if ongoing A/D conversion is complete.
None. |
True |
- A/D conversion is complete. |
False |
- A/D conversion is ongoing. |
ADC_ISR()
void ADC_ISR (void )
Implements the ADC Interrupt(ADI) service routine for the interrupt-driven implementations.
None. |
None. |
ADC_SelectChannel()
void ADC_SelectChannel (adc_channel_t channel)
Selects the channel for the A/D conversion.
channel |
- Analog channel number on which the A/D conversion will be applied. Refer to adc_channel_t for the available channels. |
None. |
ADC_SetInterruptHandler()
void ADC_SetInterruptHandler (void(*)(void) InterruptHandler)
Sets the callback for the ADC Interrupt(ADI).
InterruptHandler |
- Callback function to be called on the interrupt event. |
None. |
ADC_StartConversion()
void ADC_StartConversion (void )
Starts A/D conversion.
None. |
None. |
ADC_TemperatureAcquisitionDelay()
void ADC_TemperatureAcquisitionDelay (void )
Adds the acquisition delay for the temperature sensor.
This function is called when temperature sensor is used. |
None. |
None. |
Enumeration Type Documentation
adc_channel_t
enum adc_channel_t
Contains the available ADC channels.
channel_AVSS | |
channel_Temp | |
channel_DAC1 | |
channel_FVR |
3.1.1.2.5 Class Documentation
adc_sync_double_result_t Struct Reference
#include <adc.h>
Public Attributes
Member Data Documentation
adcResult1
adc_result_t adcResult1
adcResult2
adc_result_t adcResult2
Used Struct Reference
Detailed Description
result for a Double ADC conversion value.
The documentation for this struct was generated from the following file:
source/
3.1.1.2.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 ADC_SelectChannel (adc_channel_t channel)
Selects the channel for the A/D conversion.
void ADC_StartConversion (void)
Starts A/D conversion.
bool ADC_IsConversionDone (void)
Checks if ongoing A/D conversion is complete.
adc_result_t ADC_GetConversionResult (void)
Retrieves the result of the latest A/D conversion.
adc_result_t ADC_GetConversion (adc_channel_t channel)
Retrieves the result of a single A/D conversion on any given channel.
void ADC_TemperatureAcquisitionDelay (void)
Adds the acquisition delay for the temperature sensor.
void ADC_ISR (void)
Implements the ADC Interrupt(ADI) service routine for the interrupt-driven implementations.
void ADC_SetInterruptHandler (void(*InterruptHandler)(void))
Sets the callback for the ADC Interrupt(ADI).
Macros
#define ACQ_US_DELAY 5
Variables
void(* ADC_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
Section: Included Files Section: Macro Declarations
Variable Documentation
ADC_InterruptHandler
void(* ADC_InterruptHandler) (void)
source/adc.h File Reference
#include <xc.h> #include <stdint.h> #include <stdbool.h>
Data structures
struct adc_sync_double_result_t
Functions
void ADC_Initialize (void)
Initializes the ADC module. This routine is called before any other ADC routine.
void ADC_SelectChannel (adc_channel_t channel)
Selects the channel for the A/D conversion.
void ADC_StartConversion (void)
Starts A/D conversion.
bool ADC_IsConversionDone (void)
Checks if ongoing A/D conversion is complete.
adc_result_t ADC_GetConversionResult (void)
Retrieves the result of the latest A/D conversion.
adc_result_t ADC_GetConversion (adc_channel_t channel)
Retrieves the result of a single A/D conversion on any given channel.
void ADC_TemperatureAcquisitionDelay (void)
Adds the acquisition delay for the temperature sensor.
void ADC_ISR (void)
Implements the ADC Interrupt(ADI) service routine for the interrupt-driven implementations.
void ADC_SetInterruptHandler (void(*InterruptHandler)(void))
Sets the callback for the ADC Interrupt(ADI).
Typedefs
typedef uint16_t adc_result_t
Used for the result of the Analog-to-Digital (A/D) conversion.
Enumerations
enum adc_channel_t { channel_AVSS = 0x3c, channel_Temp = 0x3d, channel_DAC1 = 0x3e, channel_FVR = 0x3f }
Contains the available ADC channels.
Detailed Description
ADC Generated Driver API Header File