Hello. I have board with MCF52210. I've tried to make USB device and succeeded in it. USB device works fine. Now I try to make USB host and have problem with it.
If I detect attach of device I reset it and try to get device descriptor. There are 3 transactions:
Transaction 1: SETUP from host (just token)
Transaction 2: DATA0 from host (8-byte length request GET_DESCRIPTOR)
Transaction 3: ACK from device
I haven't transaction 3. I've used oscilloscope to decode electrical signals. I've got transactions 1 and 2 but not 3. Result for host is that I have interrupt with INT_STAT.DNE and TOK_PID = 0. It means bus timeout but INT_STAT.ERROR is clear and ERR_STAT = 0. It looks like there is no error but there is no ACK from device too.
USB device is device I've developed too. Actually it is the same device but with other software. I've tried USB flash drive but behavior is the same. My USB device decodes received GET_DESCRIPTOR request. It is 8-bytes length and has right fields. I don't know how it able not to reply with ACK. If I connect my USB device to PC it work fine.
I've tried to adopt software example. It's name is skeleton and it is provided by Rich T. I've copied functions to get device descriptor and changed names of some constants to suit in my environment. The behavior is the same: DNE + TOK_PID=0 + ERROR=0.
Let me make short conclusions:
1. My USB host sends GET_DESCRIPTOR request and doesn't receives ACK. It's proved by oscilloscope. It hasn't ACK from neither my USB device nor standard USB device (USB flash drive).
2. My USB device receives GET_DESCRIPTOR but replied ACK isn't received by host. Standard USB host (PC) works with my USB device.
3. Bus timeout isn't reported as error.
I think the problem comes from your USB stack, if you get bus turnaround error, that means you do not met timings for feedback a status when receiving data. Please use the CMX stack from http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=CMX_USB-LITE&parentCode=MCF5221X&fpsp....
You can also monitor USB traffic with USB protocol analyzer tool on http://sourceforge.net/projects/usbsnoop/.
Actualy my program sends SETUP token and sleeps till DNE interrupt. I have several choices:
1. USB device doesn't sent ACK. I don't beleive in it. Digital oscilloscope shows absense of ACK.
2. USB host doesn't wait enough for status receiving. Where should I configure these timings?
3. USB host controls USB bus too long and doesn't let USB device to send ACK. Where should I configure these timings? This choice is too bad because hardware can be damaged.
One thing I always suggest to folks when working with the USB Host driver is to turn on RETRY_DIS initially in your ENDPT0 register -- otherwise the system will appear to hang when you do something illegal from the device perspective. (When you turn on RETRY_DIS you'll see the device NAK'ing you over and over in this case.) You can turn it off again for maximum performance (and minimal CPU usage) once things work reliably.
If it helps to have yet another example of USB Host and Device code, I have a host and device driver here:
The driver works on MCF51JM128, MCF5222x, MCF5225x , and PIC32, so I'm pretty sure it would work on MCF5221x.
That archive will actually undergo a significant change tomorrow with support for even more platforms, and I'll be adding USB Host data logging to StickOS, so you can do data collection in BASIC and then log the results to a USB flash drive! :smileyhappy:
I've retried to port skeleton-usb-driver. It this time I've decided to minimize porting and used skeletons' original code, data types, constants and macroses. It works! So it looks like my hardware works After several tests I've discovered the problem: I've forgot to set EP_HSHK bit in endpoint 0.
Thank you for support.