2010-12-08 02:57 AM
How to check if STM32F105 is powered by USB
2011-05-17 05:17 AM
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)2011-05-17 05:17 AM
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