cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if STM32F105 is powered by USB

g_giacomello
Associate II
Posted on December 08, 2010 at 11:57

How to check if STM32F105 is powered by USB

2 REPLIES 2
js23
Associate III
Posted on May 17, 2011 at 14:17

The easiest thing is to check CIDSTS in the GOTCTL register. This will tell you, if there is a USB cable attached. But unfortunately it will not tell you, if there is power on the cable.

 

I would suggest to take a look at chapter 27.16.8 in the Reference Manual. It describes the dual role device, but some information can be used for normal device mode, too. Especially the VBUSBSEN bit in GCCFG should be usefull for your case. (I never used it by myself, so I can not tell for sure)
stuartl
Associate II
Posted on May 17, 2011 at 14:17

Hi, tried posting this three times thus far, not sure what I'm doing wrong but anyway, hopefully it gets out this time.

A thought: why not use some diodes and a voltage divider to separate the two voltage sources and enable detection?

When USB is plugged in, the attached schematic should produce 3V (logic high) on its output.  When USB is unpluggged, the MCU should see a logic low since the voltage divider will pull to 0V.  This should work with both USB power supplies and real USB hosts.

Regards,

Stuart Longland