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.

TM4C1292NCPDT: Problems with the ADC test configuration.

Part Number: TM4C1292NCPDT
Hello everyone!

I have a problem regarding a TIVA ADC function. I configured the ADC sampling sequence to sample 12 channels, 
the data obtained is processed and saved individually in an array within a for loop, but I have a problem: the data obtained by channel 1 of the ADC (AIN0)
is not saved at position 0 of the array, but instead saves it at position 1. The for loop is programmed to configure the sampling sequence of channel 0 at iteration 0
and save the processed data at position 0 of my array; iteration 1 sets up the channel 1 sampling sequence and saves the processed data to position 1 of my array
and so on. How can I do so that the data from channel 0 of the ADC is stored in the corresponding position (position 0) of the array?

  • Hi,

      Can you show your code?

  • void STEP_ADC() //configura la secuencia de muestreo del adc
    {
       int i_adc;
         for(i_adc=0; i_adc<14; i_adc++)
        {
           ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR,0);
           ADCSequenceStepConfigure(ADC0_BASE, 0,0, i_adc|ADC_CTL_IE);//(paso 1)
           ADCSequenceStepConfigure(ADC0_BASE, 0,1, i_adc|ADC_CTL_IE);//(paso 2)
           ADCSequenceStepConfigure(ADC0_BASE, 0,2, i_adc|ADC_CTL_IE);//(paso 3)
           ADCSequenceStepConfigure(ADC0_BASE, 0,3, i_adc|ADC_CTL_IE);//(paso 4)
           ADCSequenceStepConfigure(ADC0_BASE, 0,4, i_adc|ADC_CTL_IE);//(paso 5)
           ADCSequenceStepConfigure(ADC0_BASE, 0,5, i_adc|ADC_CTL_IE);//(paso 6)
           ADCSequenceStepConfigure(ADC0_BASE, 0,6, i_adc|ADC_CTL_IE);//(paso 7)
           ADCSequenceStepConfigure(ADC0_BASE, 0,7, i_adc|ADC_CTL_IE|ADC_CTL_END);//(paso 8)
    
           ADCSequenceEnable(ADC0_BASE,0);
           ADCIntClear(ADC0_BASE,0); //limpia las banderas de interrupción del ADC
           ADCProcessorTrigger(ADC0_BASE,0); //indica que se usa el  _________ interno del micro
           while(!ADCIntStatus(ADC0_BASE,0,false))
             {
    
             }
           ADCSequenceDataGet(ADC0_BASE,0,buffer_ADC);//obtiene los datos capturados por el adc
    
            mu_T=(buffer_ADC[0]+buffer_ADC[1]+buffer_ADC[2]+buffer_ADC[3]+buffer_ADC[4]+buffer_ADC[5]+buffer_ADC[6]+buffer_ADC[7])/8;
            vol_T=mu_T*3.3/4096; //aqui hubo breakpoint
            RT=((3900*(3.3-vol_T))/vol_T);
            T=(1/(0.000634544+(0.000321866*log(RT))+(-0.000000306*pow(log(RT),3))))-273.15;//aqui hubo breakpoint
    
            arreglo[i_adc]=T; //aqui hubo breakpoint
         }
    }

  • Thanks for your reply. Yes, this is the function.
  • Hi,

     On your line 7 to 13 you have ADC_CTL_IE. You need to remove them. You only want the last step in the sequencer which is the step 7 to have the interrupt enabled. Otherwise, every channel after conversion is generating the interrupt and stepping on each other.

  • Hello!
    Thank you very much for your help, with your suggestion I was able to solve the problem :)
    
    If it's not too much to ask, could you explain a bit more about interrupts?