cancel
Showing results for 
Search instead for 
Did you mean: 

ADC and pullup/pulldown

DetlefS
Associate III

Hi, for a STM32F303RE I configured a pin as an ADC input. I want to use the pullup/pulldown resistors as a voltage divider for an offset voltage. I tried to switch on both in ADC mode, that did not work. Everything is fine with the pin configured as an input. 

Is there a solution to this?

THX 

Cheers 

Detlef 

1 ACCEPTED SOLUTION

Accepted Solutions
Nikita91
Lead II

Yes you can configure the GPIO as input with pull-up, then use the ADC on this pin. (The analog path go straight from the pin to the ADC input). But the schmitt trigger is activated so the ADC quality is altered (digital noise injected). 

This was already discussed here: https://community.st.com/t5/stm32-mcu-products/adc-and-gpio-input-modes/td-p/529797 

View solution in original post

8 REPLIES 8
Nikita91
Lead II

GPIO pull up/down is not allowed in analog mode.

Have look in the reference manual "11.3 GPIO functional description". Pull up/down is only mentioned for input and output mode.

It is not a good idea to use the internal pull up for a voltage divisor as the resistor value margin is large: 25 to 55 KOhms.

The solution: use an external divisor...

 

Hi Nikita, so I can toggel the mosfet switches for pull up/down resistors only in input/output mode of the pin? Not in ADC mode? No workarounds, no hidden and secret bits? I do not care about any volatile DC offset. 2 saved Rs for hundred million devices makes a nice beach villa. 

Thx

Cheers

Detlef 

In "Analog" mode you are not able to activate internal pullup or pulldown.
In "input" mode you can activate pulldown or pullup, but not both of them at the same time and you are still able use pin as source for ADC. But you have to count with some small injection currents (up to 100nA ?). These will most likely be negligible compared to the variance of pullup/pulldown resistance... you can save one resistor.

Hi, in input mode I can use the same pin as ADC, no? How that? Sure you can switch on both pull up/down in input mode. You have two bits for that, fourth case is marked as " reserved" but it switches on both resistors.

Nikita91
Lead II

Yes you can configure the GPIO as input with pull-up, then use the ADC on this pin. (The analog path go straight from the pin to the ADC input). But the schmitt trigger is activated so the ADC quality is altered (digital noise injected). 

This was already discussed here: https://community.st.com/t5/stm32-mcu-products/adc-and-gpio-input-modes/td-p/529797 

Hi Nikita, I got it.

THX

Cheers

Detlef

I've tested this "reserved" combination (0b11) at STM32F042 with negative result (both resistors were disabled in that state)... did you succefuly tested that ? 

Hi, I tried the 'reserved' case and the voltage at the pin was 3.3V/2 . You should measure a higher supply current as well,  but I did not check that. How did you know that both resistors were disabled? Cheers Detlef