This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TM4C129XKCZAD: problem using adc in Tiva microcontroller TM4C129X

Part Number: TM4C129XKCZAD

Tool/software: Code Composer Studio

I'm quite new using Ti Tiva microcontrroller series.

I'm the demo board DK-TM4C129x and I'm trying to perform an analog to digital conversion using TivaWare API.

I followed the example found on the pack but my ADC module perform only one conversion then stop warking and microprocessor wait forever for the next conversion complete.

I attached my code in the fallowing.

Thanks for all

int
main(void)
{

unsigned long ulADC0Value;
volatile unsigned long ulTempAvg;
volatile unsigned long ulTempValueC;
volatile unsigned long ulTempValueF;

SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |SYSCTL_CFG_VCO_480), 120000000);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

ADCSequenceDisable(ADC0_BASE, 3);
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);

ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);
while(1)
{

ADCProcessorTrigger(ADC0_BASE, 3);
while(!ADCIntStatus(ADC0_BASE, 3, false)){}
ADCIntClear(ADC0_BASE, 3);
ADCSequenceDataGet(ADC0_BASE, 3, ulADC0Value);
ulTempAvg = (ulADC0Value + 2);

}


}

  • Two things I see. Most important is that the third argument of ADCSequencyDataGet() needs to be a pointer to a 32 bit integer. You are passing ulADC0Value which is an unsigned long.
    The second is that since you are running at 120MHz, I think you need a call to ADCClockConfigSet() to make sure the ADC clock is not faster than 20MHz.