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.

Questions on ADC and tivaware with TM4C1230E6PM

Other Parts Discussed in Thread: TM4C1230E6PM

Hi all, I am having a few issues with the ADC in an existing project (initial code works great but am having issues with adding another ADC input).  I am inclined to work a bit more on the issue on my own before posting code here.  But I do have a few questions on the ADC that I haven't had clarified in the reading and searching I've done.

1.  Is it necessary to have an ISR for the ADC if I am only using the ADC interrupt in the while statement in the adc read function?

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

It has worked fine before adding my second ADC input.

2.  Can the ADC inputs set up with ADCSequenceStepConfigure be out of order, i.e.

ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0);

ADCSequenceStepConfigure(ADC0_BASE, 3, 1, ADC_CTL_CH2);

ADCSequenceStepConfigure(ADC0_BASE, 3, 2, ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END);

3.  Does single use ADC input pins (such as PE3/AIN0 pin 6 on the TM4C1230E6PM) have to be declared with a GPIOPinTypeADC in setup?

4.  Can the ADC input pins be configured with GPIOPinTypeADC prior to executing SysCtlPeripheralEnable for the ADC?

Thanks for the help, if I continue to stay stuck I will start another thread.

  • Hello Mark

    1. No, If it is not in an ISR then you can use ADCintStatus in the main code and loop on it for conversion
    2. Yes they can be. However, Sequencer 3 has only 1step for conversion so you cannot add 3 channels in Sequencer 3. You would have to use 0,1 or 2 which have 8,4 and 4 steps
    3. Yes, it has to be declared as GPIOPinTypeADC for configuring the pin's Analog Mode
    4. Yes, it can. The basic idea is to have it in ADC mode before Conversion can be started

    Regards
    Amit
  • Thanks Amit, this has been a great help.  The lockup was due to my configuring more than one sequence step with sequence 3, changed that to 2 and it works well now.  Another rookie mistake.  However, as a side note, there seems to be sample code on the net that does not set GPIOPinTypeADC on single use pins, which is why I didn't set it and asked the question.   But I will be sure and do so from now on.

    Thanks again!

  • Hello Mark,

    No, that cannot be the case. The AMSEL configuration is required for the analog pin function selection. You may see somevalue without configuring them but then that would be some noise on the pin

    Regards
    Amit