2023-06-12 06:48 AM
I'm debugging an issue where my application is using device mode USB with CDC-ACM and when I come to transmit a data packet on a bulk IN endpoint that is either 64 or 128 bytes in length, the data is not received by the host until either a different length data packet is tx'd or a certain number of 64 byte tx is done.
System details:
As far as I can tell, everything is going through the HAL/LL layers correctly:
The end point config (DIEPCTL2) has a MPSIZ=0x40 (64 bytes).
When it comes to transmit the data, DIEPTSIZ2 gets set with XFERSIZ=0x40, PKTCNT=1, MCNT=0 and the endpoint is enabled (within USB_EPStartXfer in the HAL).
The ITTXFE interrupt is enabled so the function `PCD_WriteEmptyTxFifo` gets called as expected and `USB_WritePacket()` is called to shift the 64 bytes in to the FIFO.
However, running wireshark on the PC side shows no IN data at all. If I transmit 63 bytes from the device then all is good. If I tx 64 bytes then some other non 64-byte multiple then the PC IN endpoint will get the missing data.
I can't quite see how this is failing so any advise will be good!
Solved! Go to Solution.
2023-06-12 06:52 AM
Have you heard about "short packet' or "zero length packet" (ZLP) ? Google.
2023-06-12 06:52 AM
Have you heard about "short packet' or "zero length packet" (ZLP) ? Google.
2023-06-12 07:33 AM
I had but had forgotten about it! Thanks - that was exactly it. :thumbs_up: The USBX stack has a setting `UX_DEVICE_CLASS_CDC_ACM_WRITE_AUTO_ZLP` that'll send the ZLP when the data packet is a multiple of max packet size. This #define was commented out in my code.
2023-06-12 08:03 AM
Hi @AHugh.3 ,
I recommande to refer to this applications example:
you can see in ux_uer.h defined macros option used by cdc acm application:
Best Regards,
Mohamed
2023-06-12 08:11 AM
Thanks. If you look at the equivalent example for the Nucleo-U575 (which is what I based my code on) the UX_DEVICE_CLASS_CDC_ACM_WRITE_AUTO_ZLP macro is commented out. Might be worth updating the example.
2023-06-12 10:19 AM
@AHugh.3 ther ux_user.h that you point from Host CDC ACM application