This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

USB controller - LPC2364

I need to write a custom USB controller to communicate with a PC. Over the USB we will perform firmware upgrades, upload new operating parameters, download device performance data, etc. The PC side will use WinUSB mechanism to manage the USB device. I need to implement the USB control using a single interface with 2 bulf transfer endpoints, input and output. Have experimented with the USB CDC device example that came with the Keil toolset. I was thinking of taking that example and modify the descriptors and remove any unneeded logic that implemeted the CDC device and add what I need for my project.

Does this seem like a reasonebly place to start? For example, are the handling of the control endpoint esentially the same regardless of device class type?

Parents
  • "As an experiment if I set the packet size to 63 or 65, I see 4 distinct packets being sent."

    65 bytes packet is not fine, because its size exceeds wMaxPacketSize (= 64 bytes).



    "how else would the host know the entire response has been received."

    As Per said, you have to send ZLP (Zero-Length Packet) to finish the transfer, when the last transaction (packet) is just 64 bytes. No other way.

    Windows usbser.sys (CDC device driver) assigns 4K bytes of real memory for DMA to the host controller, to receive each bulk IN transfer. ie. 4K bytes is the expected transfer size.
    While the device sends full (64 bytes) packets, the host controller regards that the transfer continues, and hold the data on this 4K bytes buffer. When the device sends a short packet (less than 64 bytes, including ZLP), the host controller takes it the end of transfer, and it passes the entire transfer on the buffer to the device driver.

    Short packet (including ZLP) cuts off the expected size of transfer.
    4K bytes is the page memory size of PCI bus, max real memory size for single DMA session.

    Tsuneo

Reply
  • "As an experiment if I set the packet size to 63 or 65, I see 4 distinct packets being sent."

    65 bytes packet is not fine, because its size exceeds wMaxPacketSize (= 64 bytes).



    "how else would the host know the entire response has been received."

    As Per said, you have to send ZLP (Zero-Length Packet) to finish the transfer, when the last transaction (packet) is just 64 bytes. No other way.

    Windows usbser.sys (CDC device driver) assigns 4K bytes of real memory for DMA to the host controller, to receive each bulk IN transfer. ie. 4K bytes is the expected transfer size.
    While the device sends full (64 bytes) packets, the host controller regards that the transfer continues, and hold the data on this 4K bytes buffer. When the device sends a short packet (less than 64 bytes, including ZLP), the host controller takes it the end of transfer, and it passes the entire transfer on the buffer to the device driver.

    Short packet (including ZLP) cuts off the expected size of transfer.
    4K bytes is the page memory size of PCI bus, max real memory size for single DMA session.

    Tsuneo

Children
  • Not sending the 0 length packet was indeed the problem. By the way my last post was misleading, I never attempt to send more than 64 bytes, larger packets are first broken up to smaller (max 64 bytes) packets and sent individually.

    Thanks again for your repsonse.

  • Tsuneo,

    If I may I have another question. I would like my device to detect when the host connected and disconneted. Probably not just physically connected but rather when the commuication pipe has been establised or broken. If you recall I am using a modified verstion of the Keil mass storage driver, all our communication is done over BULK endpoints. I did experiment with this a bit by setting breakpoints in the USB ISR but I either could not find what I wanted or did not hita breakpoint when I thought I should. I do sometimes have trouble with breakponts being recognized when debugging some of the USB code, code I know that is executing. Any suggestions where how to detect pipe connection events?