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.

TM4C1294NCPDT: Initialization and configuration of ADC

Part Number: TM4C1294NCPDT


I'm having a hard time trying to get some data from ADC1 - Sample Sequencer 3 - AI2, of TM4C1294NCPDT. 

I followed every step in the datasheet.

But no data is get. I made the code bllow:

#include <TM4C129.h>

uint32_t valor = 0;

void ADC1SS3_Handler(void){  
		  valor = ADC1->SSFIFO3;
		  ADC1->ISC |= (1UL << 3);
}

int main(){
	
	//ADC1 - SS3
	//PE1 - AIN2 - Analog-to-digital converter input 2
	
	SYSCTL->RCGCGPIO |= (1UL << 5) | (1UL << 4); /* enable clock to PORT F, E */
	GPIOF_AHB->DIR |= (1UL << 4); /* make PORTF4 input for switch */
  GPIOF_AHB->DEN |= (1UL << 4); /* make PORTF4-0 digital pins */
	
	SYSCTL->RCGCADC |= (1UL << 1); //Enable clock to ADC 1
	
	GPIOE_AHB->AFSEL |= (1UL << 1); //Enable alternate function for this pin
	GPIOE_AHB->DEN &= ~(1UL << 1); //Make this pin an analog input
	GPIOE_AHB->AMSEL |= (1UL << 1); //Disable the analog isolation circuit
	
	
	ADC1->ACTSS &= ~(1UL << 3);  //Ensure that the sample sequencer is disable
	ADC1->EMUX = (0xF <<12);  //Selects the event (trigger)
	ADC1->SSEMUX3 = 0;	// Clear to SSMUX3 select AI[15:0]
	ADC1->SSMUX3 = 2;
	ADC1->SSCTL3 = 0x6;
	ADC1->IM |= (1UL << 3);
	ADC1->ACTSS = (1UL << 3);
	ADC1->ISC |= (1UL << 3);
		
		
	NVIC_EnableIRQ(ADC1SS3_IRQn);
	
	
	while(1){		
	}
	
}

I don't see where it's wrong. 

  • Hello Thiago,

    Comparing what you have done to our TivaWare sequence, you have a number of steps out of order, especially with the interrupt configuration.

    Per our forum guidelines (see https://e2e.ti.com/support/microcontrollers/other/f/908/t/695568) we don't support Direct Register programming on E2E. You should use TivaWare and it's provided API's for this application: http://www.ti.com/tool/SW-TM4C

    That said if you have to get this working with DRM, study the following API's to understand how they configure the ADC in sequence:

        IntDisable(INT_ADC0SS0);
        ADCIntDisable(ADC0_BASE, 0u);
        ADCSequenceDisable(ADC0_BASE,0u); // With sequence disabled, it is now safe to load the new configuration parameters
        ADCSequenceConfigure(ADC0_BASE, 0u, ADC_TRIGGER_TIMER, 0u);
        ADCSequenceStepConfigure(ADC0_BASE,0u,0u,ADC_CTL_CH0| ADC_CTL_END | ADC_CTL_IE);
        ADCSequenceEnable(ADC0_BASE,0u); //Once configuration is set, re-enable the sequencer
        ADCIntClear(ADC0_BASE,0u);
        ADCIntEnable(ADC0_BASE, 0u);
        IntEnable(INT_ADC0SS0);

    Of course you may not use ADC_TRIGGER_TIMER but you can treat that as what you are going to use which looks like ADC_TRIGGER_ALWAYS for TivaWare.

    You may also need to configure the ADC clock further as seen with:

    ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PIOSC | ADC_CLOCK_RATE_HALF, 1);

    If so, include a small delay after clock configuration - about 10 ms - to let the clock to settle before peripheral configuration.