cancel
Showing results for 
Search instead for 
Did you mean: 

ADC input and GPIO output on the same pin

CObn.1
Associate II

Does anybody have any experience in using exactly the same pin as an ADC input and a communication GPIO (out), as two alternating functions? Would it be possible to switch between them? If so,can the GPIO drive the small capacitor that is typically needed for an SAR ADC?

Many thanks!

5 REPLIES 5
LCE
Principal

It depends on how "small" that capacitor is, BUT even more which source is driving the ADC pin.

Output to output might be a very bad idea.

So check also the ADC's signal source if that has high enough impedance to not kill or get killed.

CObn.1
Associate II

Thanks for coming back to me. Output to output is not an issue, since the ADC signal source would be switched between in/out using yet another pin. By default, there would be a safe in-out combination.

The capacitor is typically in the range of 1 - 4.7 nF.

LCE
Principal

Is open drain output mode an option? That would be the safest way.

I have no experience with the STM32 GPIOs using them that way, but as they can usually drive some mA these 4.7nF should work. But expect some ringing / overshoot.

TDK
Guru

GPIO will have no issue driving a cap that small, only rise/fall time will be affected.

It is an odd and undesirable situation to use the same pin for input and output, but yes, it can work just fine and you can switch between input and output at will.

If you feel a post has answered your question, please click "Accept as Solution".
Paul1
Lead

Suggest a small resistor on the pin incase software bug causes a clash during development, maybe 100ohm. (You can always swap it to 0ohm later, but real hassle if the pin gets toasted on your dev board)

Paul