While building some code and a bit of hardware to do unit testing on the Tiny Core I realized that it is possible to roughly measure the load (current flow) on an analog pin used for digital I/O. Is doing that at all useful?
You mean by selecting it for output with pinMode (A0, OUTPUT) and then
doing analogRead (A0) ?? Never tried that - does it work? Nice if so (from
what I remember of the datasheet there's no reason it shouldn't).
I do remember that the datasheet figures suggest the output transistors are about 30
to 40 ohms.
MarkT:
You mean by selecting it for output with pinMode (A0, OUTPUT) and then doing analogRead (A0) ??
Exactly.
Never tried that - does it work?
Yes.
Nice if so (from what I remember of the datasheet there's no reason it shouldn't).
Exactly.
Even nicer, the datasheet provides a voltage-drop-versus-current graph. Just search for "Pin Driver Strength" or "Output Driver Strength". There is typically a chart for every combination of sink, source and Vcc=1.8, Vcc=3, Vcc=5.
I do remember that the datasheet figures suggest the output transistors are about 30 to 40 ohms.
Eyeballing Figure 31-355.ATmega328P: I/O Pin Output Voltage vs. Source Current (VCC = 5V) it looks like...
(5.000 - 4.875) / 0.005 = 25
(5.000 - 4.750) / 0.010 = 25
(5.000 - 4.625) / 0.015 = 25
...about 25 ohms at room temperature.
Obviously, if any accuracy is needed calibration is in order.