SerialUSB Data freeze

Hello everyone,

I am using Arduino DUE to stream the status of an input port (32-bit value 4*8 bit buffer) the data rate is 1.79 MB/sec(sampling, storing and transmitting every 10 ms (sampling rate 1us)). I am using Arduino DUE's Serial.USB to stream the data to the computer. I am acquiring the data in software by LabVIEW. Now, after running for approximately 40~50 second the data transmission just freezes. after that, if I reset the Arduino it works fine. I think it's some kind of buffer overflow in the USB function (USB buffer).

The function I am using - SerialUSB.write((uint8_t*)realV,512);

now I have tried SerialUSB.flash() but still, it freezes after 30~50 second.

It would be really helpful if somebody can help.

Thank you.

AFAIK the maximum baud rate with SerialUSB (a far from optimized native USB code) is 849 KBytes/s, plus the maximum speed may be slower, depending on the software receiving the data stream on the PC.

Worth mentioning that the SAM3X shares a very similar USB High Speed peripheral with the SAM E70, and peak transfer rates of up to 40 MBytes/s have been measured with this last one, not including protocol overhead, which is close to the theoretical limit. This has been achieved with an ASF example code.

A workaround would be to store the data stream on an SD card with the High Speed Multimedia Card Interface peripheral (HSMCI). See this thread, reply #9:

[Arduino Forum?

topic=188360.0](SD card storage using the HSMCI interface - Arduino Due - Arduino Forum)

Thank you for your reply.

As I have read the datasheet ATSAM3x8e support USB high speed (section mentioned in the attachment). Arduino DUE utilizes USB CDC protocol for transmission. So I think it can go up to MB/sec speed.

I am actually searching a way to clear the transfer buffer on CDC protocol (assuming it’s a buffer issue) so that it doesn’t freeze.

Thank you.

You are right, 849 KBytes/s is for SerialUSB.print(), SeriaUSB.Write() is a bit faster. However SerialUSB is not an optimized code.

You may try to reduce (e.g. 256) or increase (e.g. 1024) the size of the buffer you send in SerialUSB.Write(), and see if there is still the issue.

BTW, the way you read the data stream can slow the uc if you don't use DMA.