# What is the best way to safely verify the state of a digital pin on a live circuit by external means?

A typical digital pin of a microcontroller usually has 4 possible states:

1. output, logical 0
2. output, logical 1
3. input, tri-state (high impedance)
4. input, internal pull-up resistor

On a live circuit, what is the simplest safe method to verify which of the above 4 states a specific pin is in? Assume we have a simple multimeter and basic passive components, if necessary. The ground (GND) and power (Vcc) pins are known.

#1 is the simplest to identify. If I measure the voltage between Vcc and the pin, and it's the same as between Vcc and GND, we found it.

#3 should also be obvious, because in theory it neither sources nor sinks any significant current, so I shouldn't measure any significant voltage, neither between the pin and GND, nor between the pin and Vcc. However, due to the characteristics of digital multimeters, and that tri-state doesn't have literally infinite resistance, can this method go wrong? I wouldn't want to measure resistance on a live circuit.

What about differentiating #2 and #4? Both would result in the same: the pin will have the same potential as Vcc. As pins in the output configuration can typically source more current, I guess I could put higher and higher loads on it, but I find this not being without risks. Also, this might highly depend on the type of circuit we want to test.

Edit: Let's assume the pin doesn't change states while the measurement is performed.

• What exactly is your definition of "safe" in this case? not hurt yourself? not blow up everything? Jan 11 '16 at 13:24
• Why "internal" pullup? Is that different to an external pullup? What about pull-down? What about open drain outputs? What is it that you want to do with this information? Jan 11 '16 at 13:27
• I doubt I could hurt myself by playing with a microcontroller, typically supplied with 3.3 or 5 Volt, and being able to produce at most a few dozen or a few hundred milliamps. I think we all can assume that "safe" means avoiding any permanent damage to the test object.
– vsz
Jan 11 '16 at 13:27
• @RogerRowland : if the pullup is external, I could identify it visually. About the other possibilities, a good point. If you have an answer also covering those, feel free to include them.
– vsz
Jan 11 '16 at 13:28
• To distinguish between 2 and 4, a resistor producing a current draw of about 10ma should tell you whether it's a strong output or a weak pullup. Jan 11 '16 at 13:35