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

Increasing USB endpoint siize on the MCBSTR9 board

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

Parents
  • Hi Tsuneo,

    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

Reply
  • Hi Tsuneo,

    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

Children
No data