AM64x MCU+ SDK  08.02.00
ADC

The ADC driver provides API to configure the ADC module. Below are the high level features supported by the ADC driver.

Features Supported

  • Configuration of parameters: mode, open delay etc
  • Configuration of FIFO threshold levels
  • Configuration of range of data for the ADC conversion result
  • Generation of interrupt when the the conversion result exceeds the range
  • Programmable averaging of input samples. The number of samples taken for averaging can be configured
  • Support for getting the number of words present in the FIFO and also reading the FIFO data
  • Support for enabling/disabling various interrupts
  • Get ADC interrupt status register to determine the source of interrupt

SysConfig Features

Note
It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.
  • Selection of input channels.

Features NOT Supported

  • Big Endian

Important Usage Guidelines

  • Global initialization of surrounding modules must be done after a device reset (Please refer TRM)
  • A minimum wait for 4 us is required before starting a conversion to provide time for AFE to power up. The user needs to ensure this.

Example Usage

Include the below file to access the APIs

#include <drivers/adc.h>

Initialize ADC

/* Use internal calibration */
uint32_t errOffset = 1;
/* Starts internal calibration */
uint32_t calibration = 1;
ADCInit(adcBaseAddr, TRUE, errOffset, calibration);

Get FIFO threshold level

/* Get threshold level for FIFO 0 */
uint32_t level = ADCGetCPUFIFOThresholdLevel(adcBaseAddr, ADC_FIFO_NUM_0);
DebugP_log("Number of words after which interrupt to CPU will be generated for FIFO0 is : %i\r\n", level);

Check if ADC is powered up or not

/* Check if ADC is powered up or not */
uint32_t status = AdcIsPoweredUp(adcBaseAddr);
if(TRUE == status)
{
DebugP_log("ADC is powered up\r\n");
}
else
{
DebugP_log("ADC is not powered up\r\n");
}

API

APIs for ADC

ADCInit
void ADCInit(uint32_t baseAddr, uint32_t errCorrection, uint32_t errOffset, uint32_t calibration)
This API is used to initialize the ADC module.
adc.h
DebugP_log
#define DebugP_log(format,...)
Function to log a string to the enabled console.
Definition: DebugP.h:211
ADCGetCPUFIFOThresholdLevel
uint32_t ADCGetCPUFIFOThresholdLevel(uint32_t baseAddr, uint32_t fifoNum)
This API will read and return threshold level for a FIFO.
ADC_FIFO_NUM_0
#define ADC_FIFO_NUM_0
Definition: adc/v0/adc.h:246
AdcIsPoweredUp
uint32_t AdcIsPoweredUp(uint32_t baseAddr)
This function checks if the ADC module is powered up.