AnsweredAssumed Answered

Strange receive errors (corrupted data) when using RX Buffer Size of 512 Bytes

Question asked by hartung.robert on Aug 14, 2015
Latest reply on Aug 18, 2015 by hartung.robert
Hello,

I wrote my own USB Library / Device Driver ( https://gitlab.ibr.cs.tu-bs.de/stm32/generic_usb_driver/ ) to support more than one endpoint for my application and to be able to have better control of data etc.

I am using my own board with an STM32F205VCT and an external High Speed USB Phy (USB3300).

I am using one OUT and two IN endpoints in addition to EP0 (IN/OUT). All use BULK transfers at the moment. The transfer itself works really good, at least most of the time!

The problem is that the data is sometimes corrupted. As far as I know USB uses CRC, so I pretend that the data is actually transfered correctly, but somehow messed up in the Software at some point. The length of the packets is read correctly, but the data seems to be corrupted.
I can read data from the correct buffer/address at the start of it. But the data is simply wrong. I cannot make any sense of the data that is red (so no byte/bit shift or something). I attached a screen showing the memory for the received 8 byte packet.
The really strange part is, that the data sometimes is correct, and after I send a different packet in between, the next packet is corrupted. Or it happens that the first packet is wrong.

After I changed the RX Fifo size from 512 bytes to 2*(512/4+1) bytes as suggested in the reference manual, it seems to better. Now I have two questions:

- Can someone clarify the use of the RX-FIFO, do I have to flush it at some point (same goes for TX FIFOs)? Why is there only one FIFO for receiving, but multiple for transmitting?
- Does someone have an idea, what could cause this error and how I might be able to debug it?

Best Regards and Thanks for any help!
Robert

Outcomes