We are trying to implement a Dual Mode USB interface on a custom Stellaris LM3S9D90 board. The problem I am having presently is determining when a connection is made and whether the connection is to a host or device.Is there a particular interrupt or interrupt status that I need to look for?
We are using the same USB circuitry as is found on the ek-lm3s9d90 eval board, except that we are using a 4-pin A type USB Connector. The USB0ID pin is left floating.
Bill,
It sounds like what you are looking for is USB OTG(On The Go). However, this requires a Micro-USB AB connector with the USB0ID pin. It is through this pin where the type of connection is determined. An A type connection is dedicated to the host side only.
Take a look at this link which gives a good description of the different connector types:
http://www.cablestogo.com/resources/usb.asp
Once you have the proper connector for OTG, we have examples specifically for OTG detection:
"<StellarisWare install directory>\boards\dk-lm3s9d96\otg_detect"
You can use this example as a jumping off point for your application.
-Dave
Thanks for the response. Unfortunately we have an industrial application that requires the 4 pin connector that allows a thumb drive to be inserted without an adapter. In addition we also need to connect a PC for serial comm (CDC) with our board as device. I've gotten both of these working separately using the Stellarisware demo projects, but I have to toggle the ID pin for either host or device operation. So what I really need is to be able to tell at connect time whether the connection is being made by a host or device without relying on the ID pin. We can modify the support circuitry if necessary, but the 4 pin connector is a hard and fast requirement.
Can’t you check for VBus?
If you have 5V on the VBus connection, then go in device mode, else in host mode.
It’s not USB compliant, but it should work.
I'm not sure that that would work. I'm thinking of attaching empty cable and then attaching a host, But I will definitely see what I can do in that direction.
Meanwhile, the USB standard says we should be using ADP (Attach Detection Protocol). Does any one know if this is implemented on the Stellaris chips? I don't see anything in the data sheet about it.
Ok. We decided to go with a switch on the board that the user could flip to put the board in either host or device mode. The switch is hooked to the id pin on the chip.
Now on to the next problem, which is how to implement a CDC host. I will do a separate post on that subject.
Well, I have successfully implemented a dual mode scheme with separate Type B and Type A connectors while having a default device mode scheme. When a device is inserted into the type A connector, its Vbus is forwarded to USB0VBUS via a PNP voltage follower. The USB0VBUS is also connected to the /OE of an USB switch FSUSB31 device, that effectively decouples the type B connector, to avoid messy situations. The VBUS level is polled by software and its change calls an appropriate device init or a host init function.
Alas, dual mode is not well accompanied by TI example code. I got it working with 6852 build usblib, but no longer with 8049 & 8555 builds.
Sounds good. Would it be possible to post a drawing or sketch of the circuit?
The part of the circuit that makes USB looks like this:
Nothing is perfect: this circuit not, too. The FPF2108 power switch virtually has no current limit at the very moment of enabling the output. In operation, a current limit is present, but this phenomenon yields sudden system voltage drop, which I worked around by adding a sort of software PWM enable signal during the first 30 ms...
Note: R71 and D23 are not placed (the pull-up stuff is embedded into the controller)