AnsweredAssumed Answered

ADUCM360 Eval ADC input range & offset setup

Question asked by analog_mama on Aug 10, 2016
Latest reply on Sep 2, 2016 by ABuda

I am trying to test the ADC and DAC configurations in ADUCM360 Evaluation Board. I have downloaded the code given below into the ADUCM360 Evaluation Board. I have noticed that on providing any periodic signal (sin, ramp, square wave using function generator), having maximum peak-to-peak amplitude of 350mV with an Offset of 4.5V, correct waveform is obtained at the DAC end. However for all other offset values, either distorted waveform or only noise voltage is obtained at the DAC end. Why is that so? As per Hardware Reference Manual, absolute input range cannot be greater that AVDD i.e 3.6V (max). But in our case, the input signal is varying from 4.5-(0.35/2) V to 4.5+(0.35/2) V which is way beyond 3.6V. So, what is happening? I want to be clear about the calculations for the maximum input range available, offset required etc. required for ADC setup. 


          Screenshots of DAC Output for sin and ramp i/p respectively::




#include <stdio.h>

#include <string.h>

#include <aducm360.h>

#include <..\common\AdcLib.h>

#include <..\common\AdcLib.c>

#include <..\common\IexcLib.h>

#include <..\common\DacLib.h>

#include <..\common\UrtLib.h>

#include <..\common\ClkLib.h>

#include <..\common\WutLib.h>

#include <..\common\WdtLib.h>

#include <..\common\GptLib.h>

#include <..\common\I2cLib.h>

#include <..\common\IntLib.h>

#include <..\common\PwmLib.h>

#include <..\common\DioLib.h>

#include <..\common\FeeLib.h>

void ADC0INIT(void);

void DACINIT(void);

void UARTINIT (void);

void delay(long int);

volatile unsigned char bSendResultToUART = 0;   // Flag used to indicate ADC0 result ready to send to UART    

const unsigned int TempDataLen = 1;

unsigned char szTemp[TempDataLen] = "";                                  // Used to store ADC0 result before printing to UART

unsigned char ucTxBufferEmpty  = 0;                             // Used to indicate that the UART Tx buffer is empty



int ulADC0Result = 0;                        // Variable that ADC0DAT is read into in ADC0 IRQ

volatile unsigned char ucComRx = 0;

volatile unsigned char ucADC0ERR = 0;


unsigned long RangeMin=0x02980000;

unsigned long RangeMax=0x0FFF0000;

unsigned int Range;

unsigned long Daccode;

float scale;


int main (void)




   unsigned char i = 0;

   unsigned char nLen = 0;

  unsigned int SAMPLE_LENGTH = 1;

  unsigned long uRes_ULong = (unsigned long ) ulADC0Result;



   pADI_WDT ->T3CON = 0;

   //DioOen(pADI_GP1,0x8);                        // Set P1.3 as an output for test purposes

   WdtCfg(T3CON_PRE_DIV1,T3CON_IRQ_EN,T3CON_PD_DIS); // Disable Watchdog timer resets

   //Disable clock to unused peripherals


   ClkCfg(CLK_CD0,CLK_HF,CLKSYSDIV_DIV2EN_DIS,CLK_UCLKCG);            // Select CD0 for CPU clock

   ClkSel(CLK_CD6,CLK_CD7,CLK_CD0,CLK_CD7);     // Select CD0 for UART System clock



  AdcGo(pADI_ADC0,ADCMDE_ADCMD_IDLE);                  // Place ADC0 in Idle mode

   //UARTINIT();                                                                 // Init Uart

   DACINIT();                                   // Configure DAC output

   ADC0INIT();                                                                  // Setup ADC1

   AdcGo(pADI_ADC0,ADCMDE_ADCMD_CONT);                  // Start ADC0 for continuous conversions

   NVIC_EnableIRQ(ADC0_IRQn);                                   // Enable ADC0 and UART interrupt sources

//   NVIC_EnableIRQ(UART_IRQn);

   while (1)


      if (bSendResultToUART == 1)                               // ADC result ready to be sent to UART


          bSendResultToUART = 0; 


           uRes_ULong =  ulADC0Result;


        } // END if

   DacWr(0, (uRes_ULong)*Range);

  } // END while





void UARTINIT (void)


   //Select IO pins for UART.

   //pADI_GP0->GPCON |= 0x3C;                     // Configure P0.1/P0.2 for UART

   pADI_GP0->GPCON |= 0x9000;                   // Configure P0.6/P0.7 for UART

   UrtCfg(pADI_UART,B9600,COMLCR_WLS_8BITS,0);  // setup baud rate for 9600, 8-bits

   UrtMod(pADI_UART,COMMCR_DTR,0);              // Setup modem bits



void ADC0INIT(void)


   AdcMski(pADI_ADC0,ADCMSKI_RDY,1);              // Enable ADC ready interrupt source         

   AdcFlt(pADI_ADC0,16,14,FLT_NORMAL|ADCFLT_NOTCH2|ADCFLT_CHOP); // ADC filter set for 120Hz update rate                                                                                                                                           //   with chop on enabled


AdcRng(pADI_ADC0,ADCCON_ADCREF_INTREF,ADCMDE_PGA_G1,ADCCON_ADCCODE_INT); // Internal reference selected, Gain of 1, Signed integer output



AdcPin(pADI_ADC0,ADCCON_ADCCN_AIN11,ADCCON_ADCCP_AIN8); // Select AIN8 as postive input and AIN11 as                                                                                                                                //negative input




void DACINIT(void)


   // Configure DAC output for 0-1.2V output range, Normal 12-bit mode and immediate update.




void ADC0_Int_Handler()


   volatile unsigned int uiADCSTA = 0;


   uiADCSTA = pADI_ADC0->STA;               // read ADC status register

   ulADC0Result = AdcRd(pADI_ADC0);            // read ADC result register

   bSendResultToUART = 1;                  // Set flag to indicate ready to send result to UART



void UART_Int_Handler ()


   volatile unsigned char ucCOMSTA0 = 0;

   volatile unsigned char ucCOMIID0 = 0;

   volatile unsigned int uiUartCapTime = 0;


   ucCOMSTA0 = UrtLinSta(pADI_UART);         // Read Line Status register

   ucCOMIID0 = UrtIntSta(pADI_UART);         // Read UART Interrupt ID register        

   if ((ucCOMIID0 & 0x2) == 0x2)             // Transmit buffer empty


      ucTxBufferEmpty = 1;


   if ((ucCOMIID0 & 0x4) == 0x4)             // Receive byte


      ucComRx   = UrtRx(pADI_UART);