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-TM4C123GXL: Other non-initialized ADC channels affected by one ADC channel

Part Number: EK-TM4C123GXL

I currently have just Port E Pins 0,1,2,3 enabled for ADC. I plan to use PE1 to PE3 later, but currently I only read with PE0. I noticed the other three pins and all the non-enabled ADC sampling pins are affected by my reading on PE0. For example, I set up PD0 and PD1 as GPIO pins, but they were sampling as ADC pins instead when I read their output on the scope. Am I initializing something wrong? My evaluation board is brand new, I don't see how it could be broken already.

Below is my initialization  for the ADC.

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); 
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); 
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0); //must have enabled ADC first
    TimerDisable(TIMER0_BASE, TIMER_A);
    TimerControlTrigger(TIMER0_BASE, TIMER_A, true); //enable TIMER0A trigger to ADC
    TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); 
    TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()/SAMPLES_PER_SEC); 
		TimerIntDisable(TIMER0_BASE, 0xFFFFFFFF ); //disable all interrupts for this timer
    TimerEnable(TIMER0_BASE, TIMER_A);
		
    ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_RATE_EIGHTH , 1);
    ADCSequenceDisable(ADC0_BASE, ADC_SEQUENCE2); 
    ADCSequenceConfigure(ADC0_BASE, ADC_SEQUENCE2, ADC_TRIGGER_TIMER, 0);
    ADCSequenceStepConfigure(ADC0_BASE, ADC_SEQUENCE2, 0, ADC_CTL_CH3 );
    ADCSequenceStepConfigure(ADC0_BASE, ADC_SEQUENCE2, 1, ADC_CTL_CH2 );
    ADCSequenceStepConfigure(ADC0_BASE, ADC_SEQUENCE2, 2, ADC_CTL_CH1 );
    ADCSequenceStepConfigure(ADC0_BASE, ADC_SEQUENCE2, 3, ADC_CTL_CH0 | ADC_CTL_END | ADC_CTL_IE); //adc_base, Sequence Number, Step, set flag and end after first
    ADCSequenceEnable(ADC0_BASE, ADC_SEQUENCE2); //adc_base, sequence 
    ADCIntEnable(ADC0_BASE, ADC_SEQUENCE2);
    ADCIntRegister(ADC0_BASE, ADC_SEQUENCE2, &ADC0Seq2_Handler);
    IntPrioritySet(INT_ADC0SS2, ADC_SEQUENCE2_PRIORITY);
    IntEnable(INT_ADC0SS2);
    ADCIntClear(ADC0_BASE, ADC_SEQUENCE2);

//Here is my initialization code for the GPIO


SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); 
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); 
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_0);
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_1);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);
GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_2); 

configureTimer1A();

  • Hello Oriana,
    I am not sure what you are telling me. Are you saying that when you look with a scope to the pins PE2, PE1, PE0, PD0 and PD1 they have the same voltage as PE3? Are the other pins being driven by some source or are they floating? It makes sense that if PE1, PE2 and PE3 are left floating, they will eventually migrate to the voltage of the one ADC input pin that is being driven. When an A to D sample is taken, the voltage on the pin is stored in an internal sample capacitor. When the next channel is sampled, the voltage on the sample capacitor is "shared" with the voltage on the new sample pin. There needs to be a source (and a long enough sample time) to charge or discharge the sample capacitor to match the voltage on the new pin. Otherwise, the pin will eventually (after many times running the "conversion") match the voltage on the sample capacitor.

    Explaining PD0 and PD1 is not so clear. Are these pins used as inputs or outputs? If inputs, is there something external driving the pins? If not, they will "float" to some level based on the leakage current out of (or into) the pin. The analog mux will be part of that leakage current.

    If the scenario I have described is indeed the case, nothing is wrong. Once the pins are driven, they will have the proper voltages.
  • Thank you for your explanation Bob! The floating voltage makes sense to me for the other pins when I don't drive them. However, when I drive PE0 with a sine wave and PE2 with ground, I still see a changing voltage reading with PE2 instead of it being driven to ground. I don't see why PE2 wouldn't be at 0 V if I connect PE2 to ground or am I missing something?  

    For the PD0 and PD1, the pins are being used as outputs. However, I notice that they're not outputting as expected. I use the same code but with PD2 and PD3 and the pins output as expected.

    Below is my program to demonstrate what I mean. I wanted to test if my GPIO was switching at the frequency I set my timer to be. It worked as expected with PD2 and PD3, but If I change the GPIO pins to PD1 and PD0, they don't output at the frequency of this timer interrupt. Instead they output a constant square wave at the sampling frequency of my ADC. However, I didn't configure my PD0 and PD1 as ADC pins, or so I believe. 

    void Timer1IntHandler(void){
    			GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_2, GPIO_PIN_2);
    		        GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_2, 0x00);
    			GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_3, GPIO_PIN_3);
    GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_3, 0x00);
    }

  • If you are seeing a changing voltage on PE2 when it is tied to ground, check the ground on your scope lead. You are likely picking up an induced voltage on the scope lead.
  • And perhaps - beyond "Checking the scope's ground lead" - employ the "Shortest possible" (even lead-less) Ground connection to the probe's "circular body terminal."    (usually achieved via a strategically placed - "Wire Loop" (tied to Gnd) - which encircles & contacts the probe's ground connection.)    I've a hi-res photo - illustrating - if required...

    You and I are "assuming" that a "proper ground" IS being applied to PE2 - that SHOULD (really) - be tested & confirmed.

    It should also be asked if ANY "offending" Noise or RF Sources are nearby - which may be inducing such (strange) signal effects upon PE2.

  • For the changing voltage on PE2, I'm using a UART to echo back what the ADC sees as well as the probe. They both don't say 0 V when PE2 is tied to the TM4c board ground.

    Also, I'm curious how the floating voltage will cause PD0 and PD1 not output correctly either.
  • Your '123 LPad has LONG "directly tied" PD0/PD1 to PB6/PB7!      This has been well & long known - we've protested - and vendor has never altered.    (corrected - imho)    If you look (very) closely - the schematic does reveal that (unfortunate) cross connect - yet  "most all" will miss that (mice-type).

    You may break those (universally unwanted) cross connects by removing "R9/R10."     (just beneath the user MCU.)     My firm "tombstones" those Rs (solders one end - standing them up) - which BEST DENOTES that pcb - as FIXED!

    Might you describe - with some detail - just how you've "Tied PE2 to board ground?"      Is it possible that you've tied an "adjacent pin?"      (No offense meant - such DOES happen!)     And - have you probed (directly) - and (very) carefully - right at the MCU's PE2 pin?      Not at the "far more accessible" board header.

    Two here have suggested that you "shorten" or (even) disconnect your scope's ground probe lead (passing the probe thru a grounded/contacting wire loop) - so that a "superior/purer" voltage measurement may be achieved.     No response/confirmation has been detected...

  • Thank you. I have been using PB6 and PB7 for a PWM, so that explains it. What do you mean by removing R9/R10? scratch the trace with a small knife?

    I tied PE2 ground by using a female-female wire from the TM4C ground to PE2 directly. I then measured by echoing the value seen on PE2 with a UART. 

  • Oriana Wong said:
    I have been using PB6 and PB7 for a PWM, so that explains it.

    Good that - the "infamous pair" have "claimed yet ANOTHER Victim!"     One of your "ills" solved!

    Oriana Wong said:
    What do you mean by removing R9/R10?

    I meant "just that" component removal.     Desolder & remove each resistor (again, R9/R10) - that's not too hard - and proves superior to (any) "trace cutting."   (soldering iron applied to (even) one side of the resistor - along w/"gentle" force - should "pop it free."    (Wear protective eyeware!)

    Oriana Wong said:
    I tied PE2 ground by using a female-female wire from the TM4C ground to PE2 directly.

    May I challenge your use of  "tied PE2 to ground, "directly?"    Your use of a "likely" 3 inch, female-female jumper - and the rather LONG, circuitous, pcb routing between PE2's (left side, header) and (right side, MCU pin) CANNOT QUALIFY as DIRECT!    Such LONG - and INDIRECT connection - does not prove adequately resistant to unwanted, "Signal Pick-Up."    (add to this the "extra length" of the pcb's ground trace - you have created an "antenna" - have you not?)     A direct Ground must be applied,  "As close to the MCU's ADC pin as possible!"     Pin "PE2" may "disallow" such direct ground - thus my (change) suggestion...

    Rather than "battle further" over "direct vs. indirect" - cannot you choose another Analog pin - and employ it?    I believe that your MCU provides "10-12 such ADC capable pins" - it should be possible to (quickly/easily) switch to another...