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.

problem using adc in Tiva microcontroller TM4C129X

Dear all

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

M

//-----------------------------------------------------------------------------------------

//*****************************************************************************
// ADC0 init
//*****************************************************************************


void InitADC0(void)
{

    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);              //Enable ADC0
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);            // enable PORTE
    
    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2);     
  
    ADCSequenceConfigure(ADC0_BASE,3,ADC_TRIGGER_PROCESSOR,0);
    
    ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_IE |
                             ADC_CTL_END| ADC_CTL_CH1);                 
                                                                                                      
    ADCSequenceEnable(ADC0_BASE,3);                                   //Enables sequence
                                               
}


//*****************************************************************************
// main
//*****************************************************************************


int main(void)
{
   
  
    SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_25MHZ);

    while(1)
    {
            ADCProcessorTrigger(ADC0_BASE, 3);
        
            while(!ROM_ADCIntStatus(ADC0_BASE, 3, false)){}    // firmare stop here
                
             ADCIntClear(ADC0_BASE, 3);//clears interrupt flag
                    
            ADCSequenceDataGet(ADC0_BASE, 3, &ADC0Value);         

              SysCtlDelay(1000000);

        }

}


            
                
           

  • Hello Messori,

    On TM4C129 the function to set system clock is SysCtlClockFreqSet and not SysCtlClockSet. Pleas refer to the examples in TIVAWare. It would be

        ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                               SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
                                               SYSCTL_CFG_VCO_480), 120000000);

    Also where in main is the Init Function for ADC being called?

    Regards

    Amit