I am implementing USB on a PIC 18F2550 using the universal HID interface. I configured the HID profile configuration to have one 64-byte message for both inputs and outputs.
Now it basically works. The device registers OK with windows. I can find it in my program on a PC and send and receive data. The problem is that although messages from the PC to the PIC are truncated to the EP0 endpoint buffer size.
Before I debug too much further, I want to try to clarify my understanding of USB protocols here and verify that I understood correctly.
Suppose the input buffer EP0 is 8 bytes. I understand that the end of the PC will send a control packet, which is 8 bytes. It has a length in bytes of data. And then it will send a sequence of 8 byte data packets, and the end of the PIC must acknowledge each of them.
I understand that the end of the PC knows how large each packet can be if you look in the maximum packet size field in the device descriptor and split the message into several data packets.
Before I search for more hours in code, can anyone confirm that this is mostly correct? What if the EP0 buffer size is 8 bytes, should the computer be aware of this because of the configuration field mentioned above, and send several data packets?
If I create my receive buffer on PIC 64 bytes, I get 64 bytes of message sufficient for my needs, but I don’t like it when I don’t understand why it doesn’t work with small buffers, and once I will need them anyway.
Any advice or information would be welcome.
source
share