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 is incorrect

Hello,

My customer has problem about ADC of TM4C123GH6PGEI.
Here is his code for the ADC. This code uses same analog input for easy explanation.

uint32_t ui32Value[8] = {};

void
initADC{

//Port enable
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);

// Configure the pins to be used as analog inputs.
ROM_GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2 | GPIO_PIN_3));
ROM_GPIOPinTypeADC(GPIO_PORTK_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3);

//ADC clock speed = 1MSPS
ROM_SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS);

// Enable the ADC peripherals
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

//Reset the ADC peripherals
ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_ADC0);

//Wait "READY"
while(!ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_ADC0));

// Select the external reference for greatest accuracy.
ROM_ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V);

// Initialize both ADC peripherals using sequencer 0 and processor trigger.
ROM_ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);

ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH2);
ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH2);
ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH2);
ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_CH2);
ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 4, (ADC_CTL_IE | ADC_CTL_END | ADC_CTL_CH2));
ROM_ADCSequenceEnable(ADC0_BASE, 0);

ROM_ADCIntClear(ADC0_BASE, 0);
}

void
Acquire(){

// Trigger the sample sequence.
ROM_ADCProcessorTrigger(ADC0_BASE, 0);

// Wait until the sample sequence has completed.
while(!ROM_ADCIntStatus(ADC0_BASE, 0, false));

ROM_ADCIntClear(ADC0_BASE, 0);

// Read the value from the ADC.
ROM_ADCSequenceDataGet(ADC0_BASE, 0, ui32Value);

}

void
SysTickIntHandler(void)
{
Acquire();
}

void
main{

ROM_FPUEnable();
ROM_FPULazyStackingEnable();

//80MHz PLL Clock
ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_20MHZ | SYSCTL_OSC_MAIN);

//ADC Configuration
initADC();

//SysTick Configuration
ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / 100);
ROM_SysTickIntEnable();
ROM_SysTickEnable();

ROM_IntMasterEnable();

while(true)
{

}
}


Problem is similar to errata ADC#14 of below.
http://www.tij.co.jp/jp/lit/er/spmz849b/spmz849b.pdf
The first two ADC samples are lower than expected.
We expect 0x24E for VADCIN which is DC signal.
But First two are 0x230 and the third ~ the fifth are almost 0x24E.
He uses External voltage reference (VREF+ = 2.5V,VREFA- = GNDA).
External reference decoupling capacitors are 1.0μF and 0.01μF in parallel.

I hope you can help us.

Best regards,

Sugita

  • Hi,

    Your client is close to a good result. What he gets is almost perfect - it is normal to see the transitory response, due to analogic circuits. To improve, he must lower the time constant due to external and internal DC resistances and capacitances. The user manual has an equivalent circuit of the ADC input.

    The second problem is while he configured for an external reference, then he used one of 2.5V, which is not allowed by the data sheet - the minimum value is 2.97V. Use an 3.0V reference is mandatory.

    Check also the clock value.

    Petrei

  • Hi Petrei,

    Thank you for reply.
    My client removed resistance from ADC input circuit.
    Then he can get correct data. Thank you!

    Best regards,

    Sugita

  • Might you "reward" many others here - and describe if Petrei's further guidance (i.e. removal of 2V5 reference - replacement w/ 3V3) was adopted, as well?

  • Hi cb1_mobile,

    Do you want detail report? If yes, I can do that, of course.
    My client is using 2.5v external voltage reference and his code.
    He removed resistances from ADC input circuit. that's all.
    Those resistances (10K-ohm ) were connected between ADC input pins.
    I asked him about Rs (Analog source resistance).
    But I didn't know about resistance between ADC input pins.
    "The time constant" solved our problem.

    Best regards,

    Sugita

  • @ Sugita,

    Thank you - the details you've supplied are now sufficient - we're in your debt - much appreciated.

    Believe I see how friend Petrei made his 2V97 recommendation - suspect others may benefit as well.  (Petrei may wish to edit his "Verified" post in regards to his 2V97 as minimum VRef recommendation - which I believe will be revealed as incorrect...) 

    Below is the pertinent part of the ADC spec for those MCUs which accommodate external VRef.  (most smaller pin count MCUs do not!)   Note that the 2V97 (2.97V) is the prescribed min for VDDA and that 2V4 is the min for VRefA+, thus your choice of 2V5 is indeed w/in spec. (and some w/in my group (moi?) thought as did Petrei - but no longer...)

    You must bear in mind that while your ADC resolution has increased w/use of this lowered V reference - you have "surrendered" some V_ADC input signal range - and must now limit your input signal V to 2V5. Input signals - reaching to VDDA will "cause no harm" - but your ADC will saturate @ 2V5 - thus signals beyond that level will not be properly registered...  (i.e. input signals between 2V5 & 3V3 will all register the same {0x0FFF, or 4095)

  • Hi,

    @cb1_mobile, mea culpa! - thanks for warning me about. This comes from my habits to supply the VDDA from the reference voltage (although the current from VDDA pin is not specified…), and maybe because I never used a reference smaller than VDDA - besides the implication shown by you, (saturation) also the board design should be more careful in minimizing the electrical noise. 

    Regards,

    Petrei

  • @ Petrei,

    You are so smart, so convincing yet I "thought" VRefA could be reduced - thus seized the opportunity to, "gain free/eased knowledge."  (always good - mais non?)

    When op came back w/ "all is well" - even w/lowered VRefA - staff dug out that detail - I posted here to the benefit of many.  (one hopes)

    "Mea culpa" - dying languages live on!  "Non compos mentis," often my best/only defense.  How about, Venditor Emptor? (everyone knows Caveat Emptor - you/I have - perhaps - kicked some water upon death's-flame...)  (law school is rich in such, "perfectly defining phrases")