This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

question about usb on C6747

Other Parts Discussed in Thread: STARTERWARE-C6DSP

Hi,

I want to develop usb firmware based on 6747. But I'm confused about the enumeration process. 

In my opinion,the PC starts  the  enumeration process with sending a setup packet. And I think this setup packet will be stored in endpoint 0 FIFO. But  I find that FIFO0 is 32bit,  while the setup packet is 8byte. So, I'm very confused.

How does the FIFO0 store the setup packet?

Thanks very much!

  • FIFO0 is documented as a 32-bit register but it is accessed as though it is a 8-bit register. The FIFO registers are the transfer registers from the interal 4KB RAM inside the USB controller. For endpoint 0, it hard-coded to be the first 64 bytes of that 4KB RAM. So you would read the FIFO register 8 times, on byte at a time, to read out a 8-byte setup packet. For example code, you should look at the TIs StarterWare for C6748. The C6748 has the same OTG controller.

  • dear wong,

    thanks for your replying!

    I still have a question about reading  FIFO.  when I unload the setup packet, do I need to read the low 8-bit of the FIFO0 register for 8 times? or I can directly read the setup packet from the 4KB RAM?

    Also,  I find the TIs StarterWare for C6748 at  http://processors.wiki.ti.com/index.php/StarterWare_USB  . But I haven't found the example code. Do I find the wrong file?

    Looking forward to your reply!

  • No expert at the low-level stuff. I've mainly got along using the USB library in StarterWare, u-boot or Linux. The StarterWare for C6748 package is here:

    http://www.ti.com/tool/starterware-c6dsp

    The StarterWare code does a 8-bit access read of the FIFO register. It does not do a 32-bit read and mask 8-bits out. The C674x are little endian processors, that implies it's the LSB of the 32-bits.

    I get the impression that the FIFO RAM is internal to the USB OTG controller. I did not know it was directly accessible. Not much point to doing so as it would require access and management of the head and tail indices. Reading the FIFO register does all that circular buffer handling.

  •  Got it.

    Thanks very much!

  • Hi, dear Wong

    I have some new questions about the enumeration process. In my opinion, the enumeration process should be: get device descriptor, set address, get device descriptor again, get configuration descriptor and so on.

    But in my program, the  enumeration process is: get device descriptor, set address, get device descriptor, set address,  get device descriptor, set address, it seems to be a circle. I'm confused. Do you know anything about the reason?

    Thank you very much!

  • No expert at USB and I do not access to a system to check. Your enumeration sounds correct except for the repeat. I've seen that sort of thing if the host thinks the enumeration process has failed and it restarts. Some thoughts:

    It could be due to a bad cable and bad hub. Try with a different cable and preferably without any hubs.

    The host might not like the last response and restart. Perhaps double check that the response is according to spec.

    USB transactions tend to time sensitive. Try not have any breakpoints and time consuming printfs within the message handler.

    On Windows, if a USB device fails to load for some reason or other, the OS tends to remember that device is bad. It won't try to do a complete enumeration again. You might have to remove the device via the "Device Manager" to make the OS "forget" the device so you try to enumerate again.

    You should start a new post for new questions. Verified threads tend to attract less attention. Are you using the Spectrum Digital EVM or a cusotm board?

  • Hi, Wong

    thank you for your timely reply!

    I’m using a custom board. I also think that maybe the host don‘t like the last response and restart.  And it's true that the usb transactions are time-sensitive.

    But I feel sorry that the process is still incorrect. Maybe I should start a new post  according to your advice.

    Thanks again!

  • My sympathies. Debugging USB problems are usually quite difficult.

    Did you develop the firmware on the EVM first? A custom board opens up questions of the HW design. USB is rather picky about impedances. I've found the use of a USB protocol analyser (sniffer) help to verify the wire. The only one I've used is from Ellisys. Works fairly well. Otherwise, I guess to avoid time sensitive problems, you could log debug message to memory during the enumeration and print out the messages afterwards.

    Is your code using structures to represent USB messages? You have to careful about packing, alignment and sizeof operations. All USB messages are packed tight with no padding.

  • Hi, Wong

    I haven‘t developed the firmware on the EVM before. And my code does use structures to represent USB messages.

    Maybe I should inspect it again carefully.

    So thankful to you. Best wishes.