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.

TM4C123G Launchpad Configuring multiple ADC sequencer

Afternoon all, 

I am having difficulties configuring the ADCs on the launchpad. Here is my code:

// select reference positive
    #ifndef LAUNCHPAD
    ADCReferenceSet(ADC0_BASE,  ADC_REF_EXT_3V);
    ADCReferenceSet(ADC1_BASE,  ADC_REF_EXT_3V);
    #endif
    
    #ifdef LAUNCHPAD
    //Enable Pin inputs
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    GPIOPinTypeADC( GPIO_PORTE_BASE, GPIO_PIN_3 );
    GPIOPinTypeADC( GPIO_PORTE_BASE, GPIO_PIN_2 );

    // Enable the first sample sequencer to capture the value of channel 0 when
    // the processor trigger occurs.
    ADCSequenceConfigure(ADC0_BASE, SEQ1, ADC_TRIGGER_ALWAYS, PRIORITY0);
    ADCSequenceStepConfigure( ADC0_BASE, SEQ1, STEP0, ADC_CTL_IE | ADC_CTL_END | ADC_CTL_CH0);
    ADCSequenceStepConfigure( ADC0_BASE, SEQ1, STEP1, ADC_CTL_IE | ADC_CTL_END | ADC_CTL_CH1);

    #endif
    //setup interrupts
    ADCIntRegister(ADC0_BASE, SEQ1, ADCinterruptSequencer1);
    ADCIntEnable(ADC0_BASE, SEQ1);
    ADCIntClear(ADC0_BASE, SEQ1);

The issue I am seeing is the ADC on ADC0 is being mirrored in the value from ADC1 (and so on with more added in the chain). I can see voltage changes on the ADC0 input pin being reflected in the value displayed on the screen. However this is also reflected in the value I read back from ADC1. 

I am only using 0 and 3V3 from the board so I have no electronic issues. I am simply trying to reflect a voltage above 500 counts as a LED on using the onboard RGB LED. One colour for each channel. I can see intermediate values (ie floating values) through the UART interface. Otherwise the code performs as expected.

I suspect the issue lays in the configuration somewhere. Anyone any ideas? Thanks :)

  • Hello Andrew,

    On the Sample Sequencer you have enabled STEP-0 with END bit. Which means that after converting channel-0 it will stop and give you an interrupt. The actual sequence should be something like below

        SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
        GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
        GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2);
        ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_ALAWAYS, PRIORITY0);
        ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH0 );
        ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END);
        ADCIntClear(ADC0_BASE, 1);
        ADCSequenceEnable(ADC0_BASE, 1);

    The ADC Channels 0 and 1 are not coupled inside the design, so it is not possible for them to cross sample.

    Regards

    Amit

  • Hi,

       You, can learn from Jaspreet's ADC initialization at the link below.  

       Stellaris Launchpad 2 channel ADC working code needed

    - kel 

  • Thanks very much for the response. 

    The example (though not the documentation for each function) in the documentation is a little weak given how massively powerful the ADC sequencer is! It was easy to get lost in all the possible parameters. 

    Thanks to all who posted.