I have been playing with STM32F2 (probably the most advanced ARM Cortex M3 in the market). This is not a processor specific question nonetheless.

I have a set up where I have 0V sampled by several ADC pins. I read and dump the values. When I examine the values, I expect to see all zeros, instead I see mostly zeros but bunch of values up to 100. (i.e. this is a 12 bit ADC with 4096 levels, so 100 is roughly means ~3.3/4096*100 = 80mV)

I know for a fact, my 0 volt is really 0V (i.e. ground).. So, 100 out of 4096.. Is this expected? I have never fiddled with other ADC enabled chips so I cannot gauge this much error is expected or not. Any insights?

  • 1
    \$\begingroup\$ LPC1769 from NXP is a pretty great Cortex M3 too \$\endgroup\$ Jul 8 '11 at 13:39
  • \$\begingroup\$ What does the waveform look like? \$\endgroup\$
    – endolith
    Jul 8 '11 at 14:04
  • \$\begingroup\$ Once I have measured cheap Hi-Fi USB stereo soundcard ADC. Both channels were coupled together electrically in coax T connector. With no signal and 50 ohm terminator. The data from 2 channels was subracted from each other to cancel common mode noise of PC/USB/Power/Reference. The result for 24 bit ADC was a perfect histogram with about 300 LSB wide base. So effectively it was a 15-16 bit differential ADC with zero noise. If you have 2 identical channels, try differential approach to make it immune to many typical sources of noise. \$\endgroup\$
    – user924
    Jul 8 '11 at 15:35
  • \$\begingroup\$ @hexa I agree. I used to work for both ST and NXP in the past.. Both good companies, NXP being the better one. However in this case STM32 is a more diverse and better family. I have done considerable research in the matter and compared TI/NXP and ST. ST has the most diversity and compatibility (move the size of ram/flash easily) most comprehensive peripherals etc. TI has the best software. NXP comes second on all categories \$\endgroup\$
    – Frank
    Jul 11 '11 at 10:37

In addition to what stevenvh said, make sure you are running the A/D correctly inside the processor. I am not familiar with that processor, but the ones I have seen all have a sample and hold in front of the internal A/D. Often there is one or a small number of actual A/D converters, with a mux in front of the sample and hold to select the single channel to read that time. The sample and hold takes some finite time to settle. You have to make sure it has been given sufficient time after the mux is changed before the sample and hold goes into hold mode and the A/D does the conversion.

Another possible error is the impedance of the signal driving the A/D pin. The datasheet should have a spec for that, and it might be a lot lower than you think. To avoid offset errors, there is generally no amplifier in the chip. The sample and hold is just a capacitor with a FET that connects it to the input pin in sample mode. The impedance driving the pin needs to be below some value to get the specified accuracy and minimum sample time.

Also check what exactly the A/D is using for its voltage references, particularly the low side reference in your case. The default is probably the regular processor ground. However, it could also have a separate analog ground pin, and sometimes a separate analog input pin can be used as the negative reference. Check to make sure this is all set up as you intended it.

As stevenvh said, 80mV is way too high for any normal error. At most you would expect one count or maybe two when it really should be reading 0. Something is definitely wrong with your setup. Keep in mind this includes the setup of use of the A/D by the firmware.

  • \$\begingroup\$ For the first part, sample time is 3 cycles, conversation time is (I forgot the exact number, I guess 12 cycles) All together they add up to 0.5usec. I respect this timings. \$\endgroup\$
    – Frank
    Jul 11 '11 at 10:29
  • \$\begingroup\$ YOur ground comment is very very valuable. I will check that.. I didn't considered that when I was doing the design and now it seems I will regret that.. \$\endgroup\$
    – Frank
    Jul 11 '11 at 10:30
  • \$\begingroup\$ @Frank: Are you sure the sample plus conversion time is really 500ns. That's not impossible, but unusual to find it integrated with a micro. Is the A/D really rated for 2 MHz sample rate? In any case, you could try running it slower and see if that changes anything. \$\endgroup\$ Jul 11 '11 at 13:28

How is your ADC input connected to ground? The 80mV may come from the noise of the preceding components. If the ADC is connected directly to ground, you shouldn't get this high readings. (But even then not necessarily all zeros either. An occasional 1 or 2 is possible.)

  1. Check if your power is decently decoupled: caps 100nF close to the power pins.
  2. Check if the ADC's reference voltage is decently decoupled. Don't just connect to \$V_{DD}\$, but decouple via an RC filter, or, even better an LC filter.
  3. Make sure you have a solid ground: preferably a ground plane, in any case short and wide traces.
  4. Keep the ADC input's trace short, and low impedance. A high impedance trace will work as an antenna, and pick up all kinds of noise. (Probably not much of a problem: ADCs usually have a low impedance input). Don't use a looping test lead to connect the ADC input to ground.

If you're sure you paid attention to these points the reading should never be 80mV. Could you post a picture of the board?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.