racemaniac wrote: ↑
Thu Oct 19, 2017 12:02 pm
Would the schematic of the usb then be like this?
yep pretty much - i'd strongly suggest losing the 1.5k resistor as it's not in the reference schematic / appendix of the datasheet. in fact.... if you look at page 128 of DocID022152, en.DM00037051.pdf, you'll see that in Table 58 there's *already* pull-up resistor characteristics of typically 1.8k on PA12.
not to mention the fact that the pull-up resistor will interfere with cases where PA12 is used for alternative functions.
btw... are the 22R resistors reaaally necessary? i mean, these are incredibly short traces: yes they're normally used on longer traces, but honestly... i feel that they're just... in the way, here. the only reason to consider keeping them would be so people could remove them and cut off the USB connector. but.. if they really want to do that they can just... cut the tracks, just as easily.
if i'm following correctly:
- a p-channel mosfet to bring power from the USB VBUS to the main 5V (picked the one seen in the schematic as it's small, p-channel, and can handle enough current, and has very low VGS, and can be found on aliexpress)
i've got the arduino due ref design here... let me open it... they use a FDN340P if that helps.
- the SY6280 for the reverse direction would it be needed, supply 5V to the usb and with limited current (set the current limit to 680mA, i think standard usb is 500mA, with a bit of headroom?)
the datasheet says you use 6.8k times current. so that's a 1 *amp* current limit. you want half that, so you want a 3.4k resistor - make sure it's marked as 1% - 3.4k/1%
it's a bit of an unusual value, which will make buying awkward, but hey, omelettes, eggs...
- tied the enable of the SY6280 to an unused pin (PC9), would be stupid to use a broken out pin for it.
is there any spare pin that can be used? actually you'll need two. one as an input on a resistor-divider like those two references i sent yesterday, and that will be used to DETECT the power coming in. then the other pin will be used to CONTROL power.
the reason for making it that quotes complex quotes is because sometimes you *really want* incoming power yet to have USB Host. yes, really. you get yourself one of those "USB OTG Host Power" 3-way splitters - they're a bitch to find the right ones btw, many of them don't connect the power properly - and you can plug in a USB Charger to power *BOTH* the device *AND* the down-stream USB client devices.
- now all i'm wondering is: should i tie VBUS to PA9 (VBUS sense of the stm32f4) via a big resistor (100k?) to the VBUS? (so the vbus sense can actually work? and it'll only act as a slight pullup on the serial connection?). or do we assume we'll never put powered usb devices onto it (but then the mosfet would also be unneeded as i think it's kind of a protection in case both usb & 5v are driven?)
it's best to assume that people will want to use all three possible power configurations: standard USB Host with external power, 3-way-power-splitter-OTG-Host "Charge" mode (power splits to both board *and* client device(s) and the board's OTG is put into HOST mode), and standard OTG "client".
to do that you need full software-control over the power as well as the ability to detect (on an IRQ-capable pin) when the board has incoming OTG Power.
so... two spare pins needed: one on a divider bridge like in those circuits, then the SY6280's EN pin wired to an output.... oh! yes, you've already got that
PC9 and a 100k resistor, yay! perfect. just the resistor-divider bridge is missing.
on the arduino reference designs they use an op-amp to compare 3.3v with the resistor-divider, which automatically and ALWAYS switches on/off the VBUS 5V power. personally i don't like that idea as it prohibits the use of 3-way OTG-Powered-Host cables.