cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 Curious ADC behaviour

srdjan
Associate II
Posted on October 11, 2015 at 15:07

This is relation to my previous forum post [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F030F4%20ADC%20strange%20behaviour&currentviews=31]here:

I tried to simplify the test case as much as possible and here are the results.

I'm sampling a single channel PA4 with clock set to ADC_CLOCK_SYNC_PCLK_DIV4 and sample time of ADC_SAMPLETIME_71CYCLES_5

GPIO is set in ''ANALOG'' mode and no pullups.

Input signal is a voltage of 0.3V.

Here is what I get on the scope when I'm measuring directly on the PA4 pin. (See attached image).

It looks like that during the sample stage, the input it pulled up to 0.7V. My input circuit is given also in the attached image.

What am I missing here?

#adc #stm32f0 #dma
10 REPLIES 10
Posted on October 12, 2015 at 06:27

What happens if you disconnect the opamp (i.e. remove the series 500R resistor)?

JW

srdjan
Associate II
Posted on October 22, 2015 at 10:17

The input pin floats up to VCC, and the ADC measures 0xFFF value. But I don't have pullups enabled on the input pin (they are defined as Analog mode, no pull up or pull down)

Posted on October 22, 2015 at 12:14

So there's something which overcomes the 1kOhm pulldown... Either short on your board (check short to neighbouring pins first, then to any track which would come close to the track carrying the signal in question); or you don't have properly set GPIO (post the GPIO registers content).

JW

srdjan
Associate II
Posted on October 26, 2015 at 16:04

My GPIO register is set properly

    GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4;

    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

I unsoldered the resistors which form an input divider, and left PA4 pin floating. When I do this, the pin floats up to 3.8V during sample phase when ADC is running, and dips to 3.3V during conversion phase. I only have a 3.3V supply on the board, and I'm baffled how can this be true...

When I set this pin to be output, it correctly goes between 0 and 3.3V when I toggle output states. The pin also works completely normal when used as a digital input.

Posted on October 26, 2015 at 16:13

3.8V ?? Are you sure you have everything using the same ground potential?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
srdjan
Associate II
Posted on October 26, 2015 at 16:44

I only have one GND plane on the entire board..

I just realized that there are two pins PA9 and PA10 that are used in I2C mode, that are connected externally to a 5V I2C bus, using 10K pullups, but these two are defined as OD pins. Can this somehow create issues? Other than this there is no obvious problem on the board. I don't know where this voltage of 3.8V comes from. It definitely ONLY appears during sampling phase when the sampling CAP is connected to a sampling PIN. This happens on ALL analog pins, not just one.

Posted on October 26, 2015 at 17:03

Not sufficiently familiar with the F0 to know the FT status of those pins. But basically if you put higher voltages on the pins, it will float the internal power ring via the ESD protection diodes.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
srdjan
Associate II
Posted on October 26, 2015 at 17:13

Quick update.

I removed the two 10K pull-ups for the I2C to 5V, and now I have perfectly running ADC peripheral. 

Wow, I have to figure out how to make the I2C to work, but I don't know why is this a problem if the I2C pins are defined as OD. It shouldn't matter at all...

Posted on October 26, 2015 at 23:12

How is VDDIO2 connected?

JW