Hi all,
I have the MCBSTR9 board and working with the USB peripheral. I have integrated the USB HID example and is capable of communicating from the PC to device and vice versa. One thing that is troubling is that I've looked over the ST Micro data sheet for the STR91xFA and the USB endpoint packet buffer size can be bigger than 64 bytes. So my question is how can I increase the endpoint size to support bigger sizes? Any help is greatly appreciated.
Thanks, Tom
Though the endpoint has greater size than 64 bytes, the USB spec limits the max packet size of interrupt endpoint to 64 bytes on full-speed.
On the firmware, a report of greater size than 64 bytes is split into multiple packets. For example, a 200 bytes report is split into 4 packets, 64 - 64 - 64 - 8 Just the last packet is less than or equal to 64 bytes. Each packet is transferred in the interval (bInterval value) of the endpoint descriptor.
On the PC side, the report is transferred with single read/write call, regardless of its size.
If you have still interest in greater size report, we'll discuss on the implementation details.
Tsuneo
Hi Tsuneo,
I have looked over most of the threads regarding USB on this dicussion forum and you've seem to be go-to-guy on USB-related issues. I will try it out. Your input is greatly appreciated. Do you by chance know why the USB HID requires an INTERRUPT endpoint versus the BULK endpoint?
"Do you by chance know why the USB HID requires an INTERRUPT endpoint versus the BULK endpoint?"
HID class is designed to support keyboard and mouse as the main targets, though the application of HID is not limited to these devices. For these devices, low-speed is enough to carry the data traffic. Also, low-speed makes the device cost reasonable.
In low-speed, CONTROL and INTERRUPT transfers are available, but not for BULK and ISOC.
Thanks for the response. I have tried writing to the IN endpoint (device-side) with the size of 64 bytes, it works, but the writing of sizes greater than the 64 bytes fails. By fail, I mean the read from the PC application hangs. Do you know what might be causing this? Or any suggestions?
I solved the problem by increasing the USB internal packet buffer size in the ST 912 USB registers. Even though, I specified 64 bytes for the IN endpoint, I can still write buffers greater than 64 bytes because now I have the internal USB packet buffer size greater than the specified size of the endpoint. The problem before is that the specified maximum packet size of the endpoint is used to calculate the number of blocks of 32 bytes that the USB will use to send out the data. That size was calculated to 2 blocks of 32 bytes, amounting to 64 bytes. Therefore, if I had the size, for example of 96 bytes, it would not complete the write to the packet buffer memory area because the USB device decided that it didn't send out previous 64 bytes yet and there are no room to write the remaining 32 bytes of the 96 bytes.
In the file usbhw.c and in function USB_ConfigEP, the first if-condition checks the direction but it also sets transmission ADDRESS and size of the transfer. For the IN direction, nothing was specified. Therefore, it would use the max packet size of the endpoint.
This line should be added to if-condition for the first case: (pBUF_DSCRR+num)->COUNT_RXRX = ((((val-1) / 32) << 10) | 0x8000) << 16;
the variable "val" is placed into bits [25:16] of the register - describing the number of blocks.
But since the INTERRUPT endpoints only support up to 64 bytes, the variable "val" in this case could be hardcoded to any value or substituted with a hard value, i.e., in my case:
(pBUF_DSCR + num)->ADDR_TXRX = ((pBUF_DSCR + num)->ADDR_TXRX & 0xFFFF0000) | (FreeBufAddr); (pBUF_DSCR + num)->COUNT_TXRX = (((3) << 10) | 0x8000) << 16;
where 3, signifies 128 bytes according to the ST 912 data sheet.
I am not sure why this was left out for when the if-condition is satisfied or TRUE but is calculated for the else-condition. The USB packet memory size should be specified for either case.
Thanks again, Tom