A typical digital pin of a microcontroller usually has 4 possible states:
- output, logical 0
- output, logical 1
- input, tri-state (high impedance)
- 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.