Content originally posted in LPCWare by SeleneSW on Wed Dec 30 09:27:11 MST 2015
Hi dtesystems,
While implementing USB CDC communication in one of our projects, I had your problem too.
After some investigation, I've found that the VCOM_bulk_out_hdlr function is broken in the sense that overrides the pVcom->rx_buff buffer with new data every time the interrupt is called.
In this way if the vcom_bread function is not called fast enought we lose some packets.
I've managed to fix this, implementing a check inside the VCOM_bulk_out_hdlr function, and if there is no space in the buffer for the new packet, I just don't do the USBD_API->hw->ReadEP call (with the side effect that the interrupt will not be called any time soon, because the USB peripheral has no space), and later in the vcom_bread when I make room reading data, I call the USBD_API->hw->ReadEP enabling the interrupt again.