2017-01-26 02:29 AM
On investigating the use of the USB device drivers provided for the STM32Lx series chips (CDC) I found an issue when trying to transfer a packet to the PC which is an exact multiple of 64 bytes. In such a case the data is not transferred as desired because the low level USB driver decides that it can send the 64 bytes in a single packet, which does not work.
The behaviour that I observed is described in the post here:
My setup:
If I send more that 64 bytes the driver code correctly splits this into more packets, which works fine as long as is not a multiple of 64 and that there is an empty byte for the PC side to pick up on. Specifically this is done on line.559 of stm32l4xx_ll_usb.c:
USBx_INEP(ep->num)->DIEPTSIZ |= (USB_OTG_DIEPTSIZ_PKTCNT & (((ep->xfer_len + ep->maxpacket -1)/ ep->maxpacket) << 19)) ;
My question is, should the driver code not check to see if the transfer size is an exact multiple of 64, then handle this accordingly? If not, is there a reason why?
Best Regards,
Anthony
#stm32l4 #vcp #usb-cdc #max-packet #usb-cdc-max-packet2017-10-27 06:54 AM
To add to this, discovered a document which details this:
https://blog.brichacek.net/wp-content/uploads/2015/10/STM32F4-and-USB.pdf
Ant
2017-11-07 09:07 AM
I'm having the exact same problem on an L496 using the 1.8 framework.
Looking back in the source control commits, I fixed this exact same error two years on an L1 processor using the 1.4 framework but using a less than ideal workaround at the layer above the HAL.
This issue seems like a glaring oversight, Anthony and I can't be the only ones that have been bitten by this.