AnsweredAssumed Answered

STM32F4 USB CDC Transfer Problems

Question asked by woods.alex on Feb 3, 2016
Latest reply on Feb 4, 2016 by FTITI.Walid
Hello,

My first post here, so please let me know if I leave any important information out.

I am using the MCU as a USB CDC device attached to a BeagleBone Black, with the following settings:

__USB_OTG_FS_CLK_ENABLE();
hpcd.Instance = USB_OTG_FS;
hpcd.Init.dev_endpoints = 4;
hpcd.Init.use_dedicated_ep1 = 0;
hpcd.Init.ep0_mps = 0x40; 
hpcd.Init.dma_enable = 0;
hpcd.Init.low_power_enable = 0;
hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
hpcd.Init.Sof_enable = 0;
hpcd.Init.speed = PCD_SPEED_FULL;
hpcd.Init.vbus_sensing_enable = 0;
/* Link The driver to the stack */
hpcd.pData = pdev;
pdev->pData = &hpcd;
/*Initialize LL Driver */
HAL_PCD_Init(&hpcd);
 
HAL_PCD_SetRxFiFo(&hpcd, 0x80);
HAL_PCD_SetTxFiFo(&hpcd, 0, 0x40);
HAL_PCD_SetTxFiFo(&hpcd, 1, 0x80);

If it matters, I am using a baud rate of 115200, with 8N1 settings on the virtual com port. These match the settings MCU.

When performing a short data transfer, everything works great. However, if I try to transfer large amounts of data (e.g., 1644 bytes) I get corrupt data on the BBB side.

The data is just a series of floating point numbers (32bit) but on the receiving side, one of the numbers is always just slightly off. I send a checksum with the packet, and check it against a calculated one on the receiving side, and am consistently getting a mismatch between the two.

Consistently, the number which is corrupted is the 178th number, which is somewhere in the range of 712th - 716th byte I think. I have not narrowed down the exact bit though. I can't make any sense of this pattern.

For even longer transfers (e.g., 12012 bytes) I get similar errors within the data (149th number, 589th - 592 numbers) where the numbers are just not quite right (as if a bit is off or something). In addition to these errors, I also get a cutoff in data at the 1023rd number. After that, I get all zeros. 

SOMETIMES  (~5% of the time), the midrange transfers go through just fine. Cable length? I didn't think USB suffered from this limitation though. I think it must be a software thing. 

Any help is much appreciated. Thank you!
Alex

Outcomes