2016-03-19 02:19 PM
Hi:
On an STM32F405, I am using ports PA9 through PA12 connected through to a USB Mini B connector. The intention is to use the port so I can plug in a USB stick and transfer data to it. To drive USB power, I have a STMPS2141STR switch. I don't want the switch to be enabled unless the USB stick is plugged in. I do not understand the USB interface mechanism that would allow this detection to happen so the STMPS2141STR switch should be enabled only when the USB has a stick installed. Can someone please explain? Thank you. #usb #stm32f4 #host #host #usb #usb #power2016-03-20 12:16 PM
2016-03-21 12:33 PM
Or perhaps EXTI?
2016-03-21 01:34 PM
thanks for the responses guys.
clive1, does the ST USB library somewhere in the code do this already, or does it need to be set up by the user? I'm asking because it seems odd that this feature would not be included (in a written library) for a device that is usually set up for lowest possible power consumption, or when switching on external device power. Thanks, Gary2016-03-22 03:01 AM
It is not something I have dwelled upon.
2016-03-22 03:19 AM
> On an STM32F405, I am using ports PA9 through PA12 connected through to a USB Mini B connector. The intention is to use the port so I can plug in a USB stick and transfer data to it.
You should have an adaptor, which connects the ''Mini B connector'' on board to your USB stick, mini-B plug <--> standard A receptacle. Is the ID pin wired to GND at the mini-B plug end of this adaptor? As some Android phones/tablets wrongly mount micro-B receptacle for OTG, like Nexus 7, adaptors of microB plug <--> standard A receptacle are popular on the market. ''Working'' adaptors of this kind drop ID pin into GND at the microB plug. I'm not sure, if this theory would be applied to your adaptor, but it's feasible. If the ID pin would be dropped in GND, plug-in of this adaptor to your STM32F board is detected at the ID port (PA10). When PA10 is assigned to OTG_FS_ID function, this port is internally pulled up. OTG_FS_GINTSTS.CIDSCHG (USB_OTG_GINTSTS_CIDSCHG) To detect the change on ID pin, you may poll on (or assign interrupt to) this bit. To clear this bit, write 1 to the CIDSCHG bit (rc_w1). OTG_FS_GINTMSK.CIDSCHGM (USB_OTG_GINTMSK_CIDSCHGM) The mask bit of above change bit. OTG_FS_GOTGCTL.CIDSTS (USB_OTG_GOTGCTL_CIDSTS) Current ID pin status is read from this bit. While the ID port is kept in low, ie. while the adaptor is plugged in, enable VBUS power. Tsuneo2016-03-22 09:58 AM
hi,
thanks for the information. attached is a clip of the schematic's usb connection to the pcb mounted usb mini connector. the lower part shows the net pins at the controller. I used a Molex pcb connector that carries all signals to the 405 controller. I want to use a mini b female pcb connector due to board size constraints. An adapter would be used to connect the mini-b to the usb stick. If I understand correctly, does it mean that using the A to mini B adapter probably grounds the ID pin? If this is the case, it seems that power is only enabled once the adapter is plugged in, so the circuit I have should work. Does this agree with what I think you are saying? Thanks! ________________ Attachments : usb_cct.JPG : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0ne&d=%2Fa%2F0X0000000bdl%2FAyargFhsp3K0Zuitr7AgmnuvVqjSOnnxxnF8s__ApGE&asPdf=false2016-03-23 09:13 AM
> If I understand correctly, does it mean that using the A to mini B adapter probably grounds the ID pin? If this is the case, it seems that power is only enabled once the adapter is plugged in, so the circuit I have should work. Does this agree with what I think you are saying?
That's right. If your mini-B adapter wouldn't ground the ID pin, you could replace the board receptacle with micro-B. There are so many variations of micro-B ''OTG'' adapter products for Android on the market, (''OTG adapter'' = ID pin is grounded) For example, Tsuneo2016-03-28 08:27 PM