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/EK-TM4C1294XL: ADC Busy

Part Number: EK-TM4C1294XL


Tool/software: Code Composer Studio

Good day everyone,

The code below should Set the led when the result of the ADC is more than 2048, but the problem is the code stuck at this line READBIT(ADC1->RIS,3) and the BUSY bit in ADCACTSS register is always on after initialing the SS3 bit in the ADCPSSI register.

So why is that happening ?

#include "GPIO.h"
#include "ADC.h"

uint16_t result = 5;
int main(void){
        GPIO_c LED(PORTN,1,GPIO_OUTPUT_MODE);

        GPIO_n::SetSysClock(PORTE);   /* enable clock to GPIOE (AIN0 is on PE3) */
        ADC_n::SetSysClock(ADC1_MODULE);       /* enable clock to ADC1 */
        for(int i = 0;i<1200;i++); // delay


        /* initialize ADC1 */
        ADC1->ACTSS &= ~8;        /* disable SS3 during configuration */
        /* initialize PE3 for AIN0 input  */
        GPIOE->AFSEL |= 0x8;       /* enable alternate function */
        GPIOE->DEN &= ~0x8;        /* disable digital function */
        GPIOE->AMSEL |= 0x8;       /* enable analog function */

        ADC1->SSPRI=0x123;   // priority
        ADC1->EMUX &= ~0xF000;      /* software trigger conversion */
        ADC1->SSMUX3 = 0x0;         /* get input from channel 0 */
        ADC1->SSCTL3 |= 0x6;        /* take one sample at a time, set flag at 1st sample */
        ADC1->ACTSS |= 0x8;         /* enable ADC1 sequencer 3 */
        ADC1->ISC |= 0x8;
        while(1)
        {
            if(result >2048)
               {
                   LED.Clear();
               }
               else{
                   LED.Set();
                               }
            ADC1->PSSI |= 0x8;        /* start a conversion sequence 3 */
            while(READBIT(ADC1->RIS,3) == 0) ;   /* wait for conversion complete */
            result = ADC1->SSFIFO3; /* read conversion result */
            ADC1->ISC |= 0x8;          /* clear completion flag */

        }


  • Hi Mohamed,

      We don't support DRM (direct register manipulation) style of coding. Please use TivaWare which contains all the API and drivers to develop your application if possible. If you must use DRM then please first follow the TivaWare example and look at the source code of the API to see how the module is configured. You can download TivaWare from http://www.ti.com/tool/SW-TM4C.

  • Hi Charles,

    Thank you for your consideration.

    Actually I've also tried using TivaWare and it gives me the same result ADC Busy is always on.

    /**
     * main.c
     */
    
    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/adc.h"
    #include "driverlib/gpio.h"
    
    uint32_t ui32Value;
    //
    // Enable the ADC0 module.
    //
    
    int main(){
        SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
        //
        // Wait for the ADC0 module to be ready.
        //
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_ADC0))
        {
        }
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
        //
        // Wait for the GPIOE module to be ready.
        //
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOE))
        {
        }
    
        GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
    
    
    
        //
        // Enable the first sample sequencer to capture the value of channel 0 when
        // the processor trigger occurs.
        //
        ADCSequenceDisable(ADC0_BASE, 0);
        ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
        ADCSequenceStepConfigure(ADC0_BASE, 0, 0,ADC_CTL_IE | ADC_CTL_END | ADC_CTL_CH0);
        ADCSequenceEnable(ADC0_BASE, 0);
        //
        while(1){
            // Trigger the sample sequence.
            //
            ADCProcessorTrigger(ADC0_BASE, 0);
            //
            // Wait until the sample sequence has completed.
            //
    
            while(!ADCIntStatus(ADC0_BASE, 0, false))
            {
            }
            //
            // Read the value from the ADC.
            //
            ADCSequenceDataGet(ADC0_BASE, 0, &ui32Value);
    
            ADCIntClear(ADC0_BASE, 0);
        }
    }
    

  • Hi,

      Which line are you stuck? I don't see you setup the processor clock. Can you run the TivaWare ADC example under <TivaWare_Installation>/examples/peripherals/adc/single_ended.c as is? Do you see different result?

  • Hi,

    It stuck at this line  

     while(!ADCIntStatus(ADC0_BASE, 0, false))
            {
            }
    

    the single_ended code worked perfectly but it uses the PLL as the ADC clock source , but in my code I use the POISC clock as it the default , I think it should work also as it runs in 16 Mhz which is sufficient for ADC ,shouldn't it?

  • Hi,

      I think you missed the below line to use PIOSC as the clock source for the ADC. 

    ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL, 1);

  • Hi Charles,

    Thank you for helping.

    I think you mean this line to activate the PIOSC

    ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PIOSC | ADC_CLOCK_RATE_FULL, 1);

  • Hi,

     You are correct. I meant ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PIOSC | ADC_CLOCK_RATE_FULL, 1);. Sorry for typo. Glad your problem is resolved.