availableForWrite returns a number, not a true or false; under normal circumstances 0..64 (for the 32U4, the USB_EP_SIZE - FifoByteCount()).
Not sure if it will help though. I'm running a test on a Leonardo (as you might remember, I do not have a Micro) with serial monitor; measuring the time that it takes to send 1003 bytes. the results are (till now) consistent; between 7 and 10 milliseconds per write.
byte buffer[1003];
void setup()
{
Serial.begin(115200);
while(!Serial);
Serial.println("Ready ..................");
memset(buffer, '\r', sizeof(buffer));
buffer[999]='1';
buffer[1000]='0';
buffer[1001]='0';
buffer[1002]='3';
}
void loop()
{
unsigned long startTime = millis();
Serial.write(buffer, sizeof(buffer));
Serial.println();
Serial.print("\t"); Serial.println(millis() - startTime);
}
I've used '\r' because it's a printable character but the serial monitor does not show it.
The code did run without slowdown for 15 minutes. So I'm not sure what your problem is.
I've now added the (print of) availableForWrite
byte buffer[1003];
void setup()
{
Serial.begin(115200);
while (!Serial);
Serial.println("Ready ..................");
memset(buffer, '\r', sizeof(buffer));
buffer[999] = '1';
buffer[1000] = '0';
buffer[1001] = '0';
buffer[1002] = '3';
}
void loop()
{
unsigned long startTime = millis();
Serial.write(buffer, sizeof(buffer));
Serial.println();
Serial.print(Serial.availableForWrite()); Serial.print("\t"); Serial.println(millis() - startTime);
}
The beginning of the output looks like below in the serial monitor
Ready ..................
1003
19 7
1003
16 8
1003
29 8
1003
42 9
1003
55 9
1003
4 7
1003
18 8
1003
13 8
1003
17 8
1003
30 9
1003
43 9
1003
56 8
1003
5 8
1003
19 10
1003
12 7
1003
16 8
1003
29 9
1003
42 8