cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F042: voltage sourced by pin in analog mode

tomasz2399
Associate II
Posted on February 15, 2015 at 14:15

Hello,

I've found strange problem with voltage sourced by pin in analog mode, I don't recall noticing this with STM32F1 nor F3.

Attached file contains very basic project with code copied from ADC/DMA circular mode example from STM32F0 snippets, but stripped little further (i.e. no DMA). I'm running this on minimal board with STM32F042F4. It's clocked with HSI48 and uses PA0 as analog input. Input pin is connected to the ground with 51k resistor.

When ADC is running (and it seems to measure voltage correctly, I'm streaming samples via USB) I'm observing unexpected voltage on its input. Voltage value depends roughly on sampling frequency - with 500kSps I'm measuring ~220mV (as averaged by multimeter). Lowering sampling frequency by increasing sampling time or increasing bits/sample lowers this voltage (e.g. when I'll change SMP to maximum value voltage is lowered to ~20mV). If ADC is not started there is (as far as I can measure) no voltage on this pin.

Am I missing something with GPIO configuration?

Would there be any workaround?
4 REPLIES 4
Posted on February 17, 2015 at 09:06

And do you multiplex the ADC input?

JW

tomasz2399
Associate II
Posted on February 17, 2015 at 19:47

> And do you multiplex the ADC input?

No, this is continuous sampling from single input. I would suspect that with multiplexing effect would be less visible.

Uwe Bonnes
Principal II
Posted on February 18, 2015 at 11:05

Hello,

I've found strange problem with voltage sourced by pin in analog mode, I don't recall noticing this with STM32F1 nor F3.

Attached file contains very basic project with code copied from ADC/DMA circular mode example from STM32F0 snippets, but stripped little further (i.e. no DMA). I'm running this on minimal board with STM32F042F4. It's clocked with HSI48 and uses PA0 as analog input. Input pin is connected to the ground with 51k resistor.

When ADC is running (and it seems to measure voltage correctly, I'm streaming samples via USB) I'm observing unexpected voltage on its input. Voltage value depends roughly on sampling frequency - with 500kSps I'm measuring ~220mV (as averaged by multimeter). Lowering sampling frequency by increasing sampling time or increasing bits/sample lowers this voltage (e.g. when I'll change SMP to maximum value voltage is lowered to ~20mV). If ADC is not started there is (as far as I can measure) no voltage on this pin.

Am I missing something with GPIO configuration?

Would there be any workaround?

The ADC charges a sample capacitor with the input voltage and discharges this capacitor during conversion. Probaby this discharge ist towards Vref/2 and so with the next sampling phase the Vref/2 charged capacitor is discharge in your resistor from ADC input to ground. As a result you measure some voltage, the higher the higher your conversion frequency is.

tomasz2399
Associate II
Posted on February 18, 2015 at 18:53

> The ADC charges a sample capacitor with the input voltage and discharges this capacitor during conversion. Probaby this discharge ist towards Vref/2 and so with the next sampling phase the Vref/2 charged capacitor is discharge in your resistor from ADC input to ground.

This is true for integrating converters, for SAR it would be at least unusual.