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-TM4C1294XL: ADC is not working

Part Number: EK-TM4C1294XL

Hello Team,

I've been trying to use the ADC on a Tiva RM4C1294 but everytime I try to measure AN0, the USTAT bits are set after enabling Sample Sequencer 3. I used this basic demo and commented out SystemInit from system_TM4C129.c; when debugging, the execution is stucked in "while((ADC0->RIS & 8) == 0) ;" :

#include <TM4C129.h>

int main(void)
{
  unsigned int adc_value;
    
  /* Enable Clock to ADC0 and GPIO pins*/
  SYSCTL->RCGCGPIO |= (1<<4);   /* Enable Clock to GPIOE or PE3/AN0 */
  SYSCTL->RCGCADC  |= (1<<0);    /* AD0 clock enable*/
    
  /* initialize PE3 for AIN0 input  */
  GPIOE_AHB->AFSEL |= (1<<3);       /* enable alternate function */
  GPIOE_AHB->DEN   &= ~(1<<3);        /* disable digital function */
  GPIOE_AHB->AMSEL |= (1<<3);       /* enable analog function */
    
  /* initialize sample sequencer3 */
  ADC0->ACTSS  &= ~(1<<3);        /* disable SS3 during configuration */
  ADC0->EMUX   &= ~0xF000;    /* software trigger conversion */
  ADC0->SSMUX3  = 0;         /* get input from channel 0 */
  ADC0->SSCTL3 |= (1<<1)|(1<<2);        /* take one sample at a time, set flag at 1st sample */
  ADC0->ACTSS  |= (1<<3);         /* enable ADC0 sequencer 3 */
    
  SYSCTL->RCGCGPIO |= 0x20; // turn on bus clock for GPIOF
  GPIOF_AHB->DIR   |= 0x08; // set GREEN pin as a digital output pin
  GPIOF_AHB->DEN   |= 0x08; // Enable PF3 pin as a digital pin

  while(1)
  {
    ADC0->PSSI |= (1<<3);        /* Enable SS3 conversion or start sampling data from AN0 */
    while((ADC0->RIS & 8) == 0) ;   /* Wait untill sample conversion completed*/

    adc_value = ADC0->SSFIFO3; /* read adc coversion result from SS3 FIFO*/
    ADC0->ISC = 8;          /* clear coversion clear flag bit*/

    /*control Green PF3->LED */
    if(adc_value >= 2048)
      GPIOF_AHB->DATA  = 0x08; /* turn on green LED*/
    else if(adc_value < 2048)
      GPIOF_AHB->DATA  = 0x00; /* turn off green LED*/
  }
}

void SystemInit(void)
{
  SCB->CPACR |= 0x00f00000;
}

 

Regards,

Renan

  • Hello Experts,

    Any update?

    Regards,

    Renan

  • Hi Renan,

    The steps to configure the ADC appear correct. I would suggest referring to one of the existing examples that use the higher level driverlib functions to ensure there aren't any missing configuration steps.

    Thanks,

    -Eric Rentschler

  • Hello Eric,

    I tried a demo from the set provided by TI, and I had no luck. Same behavior as of the steps I originally sent in the customer support portal until I force this call from the demo:

    SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                           SYSCTL_OSC_MAIN |
                                           SYSCTL_USE_PLL |
                                           SYSCTL_CFG_VCO_240), 20000000);
    Looks like something was wrong with the clock because after confirming that the demo was working, I downloaded the first program(the steps I sent at the beginning) without any additional changes to the board and now the ADC is working fine.
    Regards,
    Renan