0

Okay, hello everyone !

I'm a little bit confused with USB possibility and stm32 MCU !

I have a stm32l433rb and it has just an usb full speed (device) capabilities. In the other hand, on my hardware, I wanted to add a USB typeA connector.

So I'm not OTG, so can my STM32 can be host anyway to read some data from an usb key plug on the USB-A ? Or I can just be device ? In the guideline for hardware implementation : http://comm.eefocus.com/media/download/index/id-1010928, they show me how to implement a downstream line without OTG, so in this mode, i'm host, and I read data from a device but ... i don't understand how to do this without OTG ?

And If I use the stm32l475RC, with an OTG port, I think I can force the MCU to be host with a USB type A connector (put ID pin to ground no ?) so I can read a usb key but if I want to transfer data from my MCU to a PC, can I be seen like a device or my pin ID put to ground will block this ? (maybe a host can talk to a host ... ?).

Thanks for reading !

2 Answers2

2

The STM32L433 can only operate as a USB device. It cannot act as a host.

The STM32L475 can be used as a USB host. Use a USB Micro-AB socket, and wire the ID pin to OTG_FS_ID (PA10). The USB peripheral will perform ID line detection and switch roles as appropriate -- if a USB OTG adapter is plugged in, for instance, it will detect the grounded ID pin and switch roles to a host. See the reference manual for details.

  • OK. And if I use an stm32l475 with an USB typeA. If I put the OTG_FS_ID pin to ground, my stm32 will be host only no ? In the later time, I will a standard USBA cable from my stm32 to a PC, do you think I can use my stm32 like a mass storage device in that case ?! The PC will no find pin ID on the cable, so it will be seen as a host and my stm32 will detect the PC ? – user1568445 Feb 10 '18 at 15:00
  • Entering host mode is a *software* function - grounding the ID pin is the (defacto) standard way of requesting this, but it is only going to work if you write firmware for the STM32 which does that in response. You also need to supply VBus or not as appropriate to the chosen role. Probably you should first spend some time learning how to be a full-time embedded host with firmware on an eval board which you write to accomplish *only* that, before you worry about role switching. – Chris Stratton Feb 10 '18 at 16:35
  • Question on connecting that ID pin (4th pin) of the micro-B side of the USB cable to the OTG_FS_ID(PA10) pin of the cortex M4 MCU: -Should I avoid making that connection if I intend to use the MCU as a device and not as a host? I saw another post saying that for a device, the ID pin should be floating. My current design has the ID connected to PA10 and my board operates as a device correctly. I'm buffled because ID is grounded on the A-side (PC side=host), so how come the same ID pin (which is grounded) doesn't force device's PA10 to gnd and set it as a host as well? – Geo Nov 11 '20 at 02:39
0

USB host can't talk to another USB host.

You seem to have a design constraint to have a Type-A receptacle. Understandable, to read a USB key. But change the data role in your design will be problematic then.

You can start with your design having Type-A receptacle and set the OTG_FS_ID low. It will be a legitimate USB host.

However, for your design to be a USB device, you can't use Type-A receptacle, it must be Type-B receptacle.

What you can do is to add another Type-B connector, and de-multiplex USB data to it using a dedicated IC USB switch, because the D+/D- data lines are already muxed inside the MCU.

Since Type-A nor Type-B standard connectors don't have ID pin, the switch can be done by manually selecting the mode (set OTG_FS_ID low or high). The direction of data switch should correspond to the position of manual OTG switch.

Alternatively, you can use VBUS=high signal on Type-B port to make this switch for you. You will have then a priority of device function over host function if a stadard B - A cable is connected to a PC host. This all might be a heck of confusion to customers, but this is the price to go with old USB connectors.

Ale..chenski
  • 38,845
  • 3
  • 38
  • 103
  • Ok. Thanks for your answer but I don't understand why a USB A can't do device ?If I use a power switch do detect Vbus IN/OUT (usbkey, I power Vbus myself, and with a PC, Vbus is power by himself), I should could use the same USB connector and switch with Vbus detection the ID PIN no ? – user1568445 Feb 12 '18 at 07:48
  • @user1568445, If you are making some hack device in your garage, it is OK, you can assign any function to USB-A **receptacle**, you can do whatever you want. But if it is a product to use by others, it will be illegal from USB specification standpoint. And you will need a Type-A to Type-A cable, which rarely exist, as another USB hack. On reflection, there used to be USB external hard drives that use Type-A receptacles, and they came with short A-A cables. But they never were USB-IF certified, and can never be. – Ale..chenski Feb 12 '18 at 08:08