Skip to main content
Visitor II
May 9, 2025
Question

STM32 USBX Loopback Issue (Number of bytes dependent)

  • May 9, 2025
  • 2 replies
  • 372 views

To test a USB implementation, I have implemented a USB loopback on a Nucleo-144 Development Board (MB1404C).  Testing is showing a strange result that I have been unable to isolate:

The code is very basic:  it creates a thread for USB data handling.  In that thread, ux_device_class_cdc_acm_read is used to block until data is received from USB.   When it is received, it is send back out USB using ux_device_class_cdc_acm_write.

 

This works great if I send up to 6 bytes of data.   As soon as I send 7 or more bytes, the transmitted data is junk (though it is repeatable). 

Things I have tried and seemingly ruled out:

  1. If I don't try to loop the received data out and instead just send data out, I can send 7+ bytes so it doesn't seem to be on the PC side of send/receive data or directly in the transmit code.
  2. I have stepped all the way through the receive and transmit code (down through the USB drivers) and the data is received correctly (even 7+ bytes) and it looks good the entire time on the transmit side.
  3. I doubled the size of all stacks in case it was some type of stack overflow.
  4. I also inserted unused variables/ rearranged the order of variable declarations to try to rule out some type of overflow issue.

 

Any ideas?

 

 

 

    This topic has been closed for replies.

    2 replies

    Community Manager
    May 12, 2025

    Hello @Brett21 

    This post has been escalated to the ST Online Support Team for one-to-one assistance.  We'll contact you directly.

    Best regards,

    Lina

    Technical Moderator
    May 12, 2025

    Hi @Brett21 

    Did you refer to this example?