# Parameter is incorrect error with usb 2.0 but not with usb 3.0 with C# serial program

I've been struggling to understand an error that is happening. I've got a simple program that sends/receives bytes over serial, and up until yesterday I figured was working 100%.

Basically, the issue is that my program works perfectly with any USB 3.0 ports, but fails on all USB 2.0 ports. I am only using Windows, and tested on both versions 7 and 10. The software is written in C#, and the AVR side is an Arduino, using an adapter with a large 512Mbit Flash memory on it.

I found an issue once I tried it on my spare laptop, which doesn't have any USB 3.0 options, and as soon as the program tries to send the serial data to my external AVR it crashes with a "The parameter is incorrect" error. Googling that error brings up a few hundred thousand results, all with completely different issues, so that error is super generic.

I'm using Dtrenable and Rtsenable, as suggested in other posts. My baud rate is a standard 9600. Here's how I'm initializing it.

private void Init(string portName)
{
myport = new SerialPort(portName);
myport.BaudRate = 9600;
myport.Parity = Parity.None;
myport.DataBits = 8;
myport.StopBits = StopBits.One;
myport.Handshake = Handshake.None;
}


Portname is set in a different section where I pull the available COM ports, and Dtr / Rts are being enabled right before I open the port to send the data.

Again, this works flawlessly on USB 3.0 ports on any computer I've tested, but fails on every USB 2.0 port. I should note that the AVR device is being powered by the USB port, but draws less than 100ma.

Any help understanding this would be great, thanks!

EDIT: Just checked something, and it only seems to fail if the file size being transferred is over 4MBytes. Any file smaller than that seems to write fine, even on USB 2.0. Anything larger than that fails on USB 2.0, but works fine on 3.0 ports.

## 1 Answer

Microsoft Windows has transfer size limitations for OHCI, UHCI, and EHCI (USB 1.1 and USB2.0) controllers, see this publication. For HS and FS modes it is 4MB for most types of transactions. Bulk transactions have 32MB limit on xHCI (USB 3.x) controllers.

• This makes sense, and I've marked it as my answer... But the thing still confusing me is that one of my computers (the one I do my development on) is able to handle even 64MB files with no trouble. It has USB 3.0 ports and no USB 2.0 ports, which is part of why I didn't know there was an issue until just recently. If USB 3 only supports up to 32MB tranfers, how am I able to handle larger transfers than that on this one PC? Feb 19, 2019 at 20:55
• @mikerakesh, there could be several variants. There are two kinds of USB 3,x ports. Before 2015 all port controllers were separated into xHCI + EHCI. After 2015, "6th Gen Intel" PCH have EHCI removed, and all modes are handled quietly over xHCI. intel.com/content/dam/www/public/us/en/documents/white-papers/… So there should be different drivers on Microsoft side that are not reflected in older publication. Feb 19, 2019 at 22:08