USB transfer IN problem on stm32g0bx when length is multiple of 64 bytes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-07-27 8:11 AM - last edited on ‎2023-08-07 8:13 AM by Amel NASRI
I am using usb hal library.
My problem is when the transfer (IN) is complete if the transfer is a multiple of 64 bytes, I don't get a callback on CDC_TransmitCplt_FS() otherwise I get a callback.
At the end of the transmission, the transfer is correct and is normally done on the host side.
In the function: USBD_CDC_DataIn() in usbd_cdc.c
A test seems to create the problem:
if ((pdev->ep_in[epnum & 0xFU].total_length > 0U) &&
((pdev->ep_in[epnum & 0xFU].total_length % hpcd->IN_ep[epnum & 0xFU].maxpacket) == 0U))
the function does not call the TransmitCplt() callback in this case.
I would like to know if it is normal not to call the TransmitCplt() function if the length of the transfer is a multiple of 64 bytes and how to process 64 bytes multiple length transfer_IN complete callback or another solution to process the end of transmission in all cases.
- Labels:
-
STM32Cube MCU Packages
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-07-27 8:40 AM
Most likely a bug which hasn't yet been fixed. See here for issue and fix:
But possibly it has been fixed in the latest HAL library.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-07-30 6:41 PM
I think in the bug you reference, packets are not transmit.
In my case the packets are transmitted to the host but at the end of the transmission the device never calls the transmitCplt callback.
I found a solution; I never transmit a length multiple of 64 bytes. In this case I add 1 byte to the packet but that's not a good solution, it's just a workaround.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-30 1:50 AM
Hello GPREV.1,
We have tested the FW from our side and it works correctly.
You can try to send packets of 128 bytes (multiple of 64 bytes) in loop mode:
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, (uint8_t*)&UserTxBufferFS[0], 128);
USBD_CDC_TransmitPacket(&hUsbDeviceFS);
Thanks.
