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.

EK-TM4C129EXL: EK-TM4C129EXL

Part Number: EK-TM4C129EXL


How can I continually read data from adc ch0, ch1, ch2, ch3, ch4, ch5, ch6. Is it possible ? If it is possible in EK-TM4C129EXL board  . Then, how can I read data?

Regards,

Imtiaj Hossain  

  • Hi,

      Yes, you can first assign these 7 channels to Sequencer SS0. SS0 supports up to 8 channels. 

    Once you assign your channels to the sequencer, it is just a matter to provide a trigger to ADC to start sampling. There are multiple ways to provide triggers. The simplest way to to use the processor to a software trigger. Other trigger sources can be GPIO, Comparator, PWM and timer. Please refer to the datasheet for details. 

    Below is an example for three channels using processor trigger to read the three channels continuously. Please also go to C:\ti\TivaWare_C_Series-2.2.0.295\examples\peripherals\adc\single_ended.c for a single-ended channel example. 

        //
        // Display the setup on the console.
        //
        UARTprintf("ADC ->\n");
        UARTprintf("  Type: Single Ended\n");
    
        //
        // The ADC0 peripheral must be enabled for use.
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    
    
        GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1);
    
        ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
    
        ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0 );
    
        ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH1 );
    
        ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH2 | ADC_CTL_IE |
                                 ADC_CTL_END);
    
        ADCSequenceEnable(ADC0_BASE, 0);
    
        ADCIntClear(ADC0_BASE, 0);
    
    
        while(1)
        {
    
            //
            // Trigger the ADC conversion.
            //
    
            ADCProcessorTrigger(ADC0_BASE, 0);
    
            //
            // Wait for conversion to be completed.
            //
            while(!ADCIntStatus(ADC0_BASE, 0, false))
            {
            }
    
            //
            // Clear the ADC interrupt flag.
            //
            ADCIntClear(ADC0_BASE, 0);
    
            //
            // Read ADC Value.
            //
            ADCSequenceDataGet(ADC0_BASE, 0, pui32ADC0Value);
    
            //
            // Display the AIN0 (PE3) digital value on the console.
            //
            UARTprintf("AIN0 = %4d\n", pui32ADC0Value[0]);
            UARTprintf("AIN1 = %4d\n", pui32ADC0Value[1]);
            UARTprintf("AIN2 = %4d\n", pui32ADC0Value[2]);
    
        }

  • Many thanks Charles for giving me sample code. But there is a problem when I change the value in ch0 then automatically change the value in ch1 and ch2.

    Which was not be? How can I solve this problem?

    Thanks 

    Imtiaj Hossain

  • Please see the below .

    Thanks

    Imtiaj  Hossain

  • But there is a problem when I change the value in ch0 then automatically change the value in ch1 and ch2.

    What do you mean ch1 and ch2 are changing? How are you connecting ch0, ch1 and ch2 on your board? Why don't you tied ch0 to 3.3V and ch1 and ch2 to GND and try again? You cannot just leave the inputs floating. 

  • Dear Charles

    Yaa, thanks Charles. I just leave the inputs floating that's why reading from ch1 and ch2 is garbage. Now I check the result is ok . 

    Sorry I ask another question I want show only the changes of ADC value in terminal . I mean I just show like this

    ANI0= 0

    ANI1= 2008

    ANI2=0 

    Thanks & regards 

    Imtiaj Hossain