Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I'd like to interface the STAT line a MCP73831 lithium ion charge manager IC to a microcontroller to read the current charging status of it.

The datasheet explains in the section 5.2.1 that the STAT line is tristate output and have the following status: High, Low and High-Impedance, and a table is provided that explains how each level represents each charging states of the battery.

How can I connect this pin to a microcontroller I/O and read these three distinct states?

Reading High and Low is quite straightforward, but detecting a input is high impedance I've not done before.

share|improve this question
add comment

3 Answers 3

You could tie it to ground and Vcc with two 10k resistors, and use an A/D input to read the level.

If you don't have an A/D to spare connect it to another pin of your uC with a 10k resistor. If the pin is either high or low it will of course read as high resp. low (assuming it can drive a 10k load). If it is high impedance it will read equal to what you output on the other pin.

share|improve this answer
+I like the 2nd idea. Read with output high and output low, four possibilities, of which only three are sensible. –  Spehro Pefhany Jul 14 at 23:09
add comment

Many microcontrollers allow you to select between either weak pullup and weak pulldown resistor on a GPIO input - in the order of about 50k-100k Ohm. If the input is high-z, a read with weak pulldown enabled will read low and a following read with weak pullup will be a high.

Remember to wait a few µs between the resistor toggle and the GPIO read to allow the voltage on the pin to settle.

Note that older AVR and 8051's may only have weak pullup but no weak pulldown resistors.

share|improve this answer
+1 ... For MPUs that do not have weak pullup & weak pulldown capability, you could add a single external resistor to another GPIO pin and use it to drive the resistor high or low. –  Tut Jul 14 at 20:17
add comment

If you read the document - section 3.3 you see that it is intended to be used with a pull up resistor.

In fact with any open-drain or tri-state signal you're not meant to be reading it when it is in tri-state mode, it is designed that way so that the signal can be shared across multiple devices. Where it gets confusing is that if you are reading the signal and it is in tri-state mode (and you don't know it) you can get spurious readings. the best way is to then apply a weak pull up so that if the signal is in a ambiguous state, then the the signal is read appropriately. Since this signal is meant to be driving a LED to indicate a charge status (i.e. low is charging) then with a pull-up and it reads high, means that it is not charging.

enter image description here

share|improve this answer
The table in section 5.2.1 indicates that (for the MCP73831) that a "HIGH Z" output indicates "Shutdown" or "No Battery Present", while a "H" (high) output indicates "Charge Complete - Standby". A pull-up resistor alone will not allow the MCU to tell the difference. –  Tut Jul 14 at 20:47
With a pull up then the modes of "shutdown", "no battery present" and "Charge-complete - standby" all map to the same reading of High. This all maps to the action of "don't do anything" looks like the datasheet is consistent. –  placeholder Jul 14 at 20:56
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.