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.

ADC Channels data affecting other ADC Channels

Other Parts Discussed in Thread: TEST2

Hello All,

I am trying to interface 3 different potentiometer for 3 ADC Channel (Channel 0, Channel 1 and Channel 2).

I am getting an exact data if i work with single channel but when I try and use multiple ADC, Data of one channel starts affecting data of other channel.

I have tried and printed data of three different ADC value on UART at 9600 Baudrate.

Please help me out in rectify my code below if it has different issue:

#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "driverlib/adc.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"

void InitConsole(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTStdioConfig(0, 9600, 16000000);
}

int main(void)
{
uint32_t ADC0Val[3];
SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
InitConsole();

SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);

ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH2);
ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_CH1);
ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 1);

int test = 0;
int test1 = 0;
int test2 = 0;
while(1)
{

ADCIntClear(ADC0_BASE, 1);
ADCProcessorTrigger(ADC0_BASE, 1);
while(!ADCIntStatus(ADC0_BASE, 1, false))
{
}
ADCIntClear(ADC0_BASE, 1);
ADCSequenceDataGet(ADC0_BASE, 1, ADC0Val);
test = ADC0Val[0];
test1 = ADC0Val[1];
test2 = ADC0Val[2];
UARTprintf("ADC:%d\t\t",test);
UARTprintf("ADC1:%d\t",test1);
UARTprintf("ADC2:%d\n",test2);
SysCtlDelay(SysCtlClockGet() / 12);
}
}

  • This "channel-bleed/cross-talk" has long - and often - been noted right here! Clearly you've not exercised forum's "search" feature.

    The effect is a limitation of the MCUs hardware - suffered by most all MCU ADCs (not a vendor liability) - and while software may "lessen" the issue - your presentation of signal to the ADC is (usually) highly suspect.

    You must attempt to match the output impedance of your signal (pots, your case) to the specified input impedance of the ADC. (find that w/in the ADC specs - ending pages of MCU manual.)

    Small value, ceramic caps, placed near the ADC pins - also assist.

    The combination of these 2 HW recommendations - and the use of, "back to back" ADC channel reads (read the same channel twice - process "only" that 2nd reading) are likely to provide relief...

    MCU's ADC employs (just one) small value input capacitor which must (both) "fully charge and then discharge" w/each/every ADC channel's signal arrival.   That's not easy to achieve - thus your plight.   "Real" ADCs exist (this vendor & others) which - by being more specialized - avoid this effect. Today's "kitchen sink" design of MCUs incurs (usual) trade-offs - choice is yours...

  • Actually, even external multiplexed A/Ds suffer from this effect.

    Single input A/Ds show it as a rather more subtle phase error.

    Robert
  • Hello Mitesh,

    Did you check the errata. It seems PE3 has an effect on other channels.

    Regards
    Amit
  • Hello All,

    I have solved my problem. I had used higher value of capacitors in the my ADC Circuits. I corrected my capacitor value and now my values are stable.

    Thank you all.
  • cb1_mobile said:
    Small value, ceramic caps, placed near the ADC pins - also assist.

    Might you have "missed" that "exact" guidance (above) - provided w/in TEN Minutes of your posting?   (at least "splash" a 2nd (deserved) GREEN!)