usbwinusb

How to use multiple endpoints (IN and OUT) in Bulk Mode for USB comm in PIC24FJGB410


In my project I am configuring USB endpoints (Bulk Mode) for both In and Out from the Host. I'm using PIC24FJ256GB410 and Microchip example code “Vendor throughput“ configured with PIC24FSTARTER KIT.

Everything works OK if I’m using Endpoint 1, 2,3 for OUT and Endpoint 1 for IN.

The moment I configure Endpoint 1, 2, 3 for OUT and Endpoint 81 for IN. Data OUT works Fine but Data IN doesn’t work at all.

I’m using VC++ as frontend and WINUSB write pipe use Endpoint 1 for OUT and Endpoint 81 for IN.

I’m totally confused. In general Endpoint Numbers for both Host side and Device side should match but in my case the moment I try to match it doesn’t work.

The complete code is attached for debugging and your valuable advice.

CODE LINK ARE AS UNDER


USB Descriptor & USB CONFIGURATION


USB DATA IN & OUT CODE


Solution

  • O.K. Well, I have been working on this code and have found something interesting which I wanted to share with readers. Please correct if I’m wrong.

    I think the problem is resolved or actually, there is no problem at all. USB is a Host based protocol so data OUT from host will be always 1,2,3,4 and IN will be 81, 82, 83.regardless of how you are sending from DEVICE. On Device while initializing USB descriptor we have done EP1,2,3 OUT and EP 81,82 IN but actually when we send/receive , we do out thru 1,2,3 and IN thru 1,2 instead of 81, 82. The IN Endpoint conversion from 1, 2 to 81, 82 is done by USB Descriptor. Additionally on reading PIC 24fj manual I can only find 0-15 endpoints. No endpoints on the name of 81, 82 is defined. So In nutshell there is nothing wrong the way it’s working.

    At This moment I choose to used EP1, 2, 3 for OUT and IN EP 4, 5, 6 (configured in VC++ as 84, 85, 86) to move ahead and all is well.