I'm currently designing a PCB at which I have an lithium ion battery (4.3V max) attached. The battery is charged via USB (5V).

The charging controller is enabled by a microcontroller which should detect when USB is attached. Due to power saving and money saving design considerations the plus-pole of the battery and the 5V-USB pole are connected to each other (diode is there for direct-charging-protection).

Anyway, before I had these design re-considerations I had a simple voltage divider at the 5V-USB (150k/100k) to detect a connected USB charging cable directly by the microcontroller via a simple GPIO interrupt.

Now I have to detect without an ADC (already used) if the voltage on the line is sourced by USB (5V) or by the lithium ion battery (4.3V). Is the microcontroller's analog comparator (ACMP, using SiLabs, EFM32G222 microcontroller) an option to use? Then I could just compare if the signal is below or above 4.3 V (or let's say 4.4 V to add some safety space)? I would use a voltage divider to scale down the 4.3 V/4.4 V to the voltage are of the microcontroller (2.1 V).

Is this a reasonable idea?

Many thanks in advance for your help!

EFM32G Reference Manual: https://www.silabs.com/documents/public/reference-manuals/EFM32G-RM.pdf

Used Specific MCU Datasheet: http://www.farnell.com/datasheets/2170296.pdf

  • \$\begingroup\$ Thanks for the tip! I've added the links to the datasheets. \$\endgroup\$ – Philipp Doublehammer Apr 19 '18 at 10:55
  • 4
    \$\begingroup\$ PCB=printed circuit board. PCB board= printed circuit board board. The message brought to you by the department of redundancies department. \$\endgroup\$ – JRE Apr 19 '18 at 11:13
  • 2
    \$\begingroup\$ Ah, the good old DRD department. \$\endgroup\$ – Colin Apr 19 '18 at 11:20

I would simply treat the 5V line as GPIO. Connect it via a divider so it does not go above MCU Vcc.

The "bottom" resistor will make sure that GPIO reads as zero when there is no voltage.

GPIO reads low = you're on battery power

GPIO reads high = you're on USB power

  • \$\begingroup\$ As described in my post, this is how it was before +5V (USB) and 4.3 V (battery) line were shorted. \$\endgroup\$ – Philipp Doublehammer Apr 20 '18 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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