Arduino's Serial (Serial - Arduino Reference) library is very good!
It is easy to use and satisfies most needs.
However, sometime we need more.
In my application, I need to change the direction of a transmit/receive multiplexer when transmission finishes. Timing is critical! Thus I need to know when Serial.write or Serial.print finish its job.
Is there a generic way of testing (or waiting until) if a Serial send function finishes its job?
Based on your message, I assume that for Serial, I need to have the following code;
Serial.print("xyz");
while (!(UCSR0A & _BV(TXC0)));
digitalWrite(Multiplex_Direction, LOW); // Change the multiplex direction pin
What about Serial1, Serial2, Serial3?
IS THIS CORRECT?
Serial1.print("xyz");
while (!(UCSR1A & _BV(TXC1)));
digitalWrite(Multiplex_Direction, LOW); // Change the multiplex direction pin
Serial2.print("xyz");
while (!(UCSR2A & _BV(TXC2)));
Seria3.print("xyz");
while (!(UCSR3A & _BV(TXC3)));